Skip to content

Commit 8efa432

Browse files
author
Utkarsh Dalal
committed
diag: add WRAPPER_DIAG_TEX texture-path dump
WRAPPER_DIAG_TEX=1 records, for each BCn CPU upload, the real parameters (source stride, target format, and the destination image's format / extent / mip count / tiling / usage / flags) and dumps the leading source BC7 bytes plus our transcode output to wrapper_tex_<appid>.txt. This localizes a corrupt- texture case (e.g. Xclipse renders BC7 as static even via RGBA-CPU): the transcode can be verified byte-for-byte offline against the reference decoder, and any stride/format/tiling mismatch in how the image is uploaded becomes visible. Off unless set; instruments the CPU path (run with WRAPPER_BCN_GPU=0).
1 parent 46cb04b commit 8efa432

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

src/vulkan/wrapper/wrapper_device.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,57 @@ wrapper_bcn_do_copy(struct wrapper_command_buffer *wcb,
17411741
int src_w = copy_region.bufferRowLength ? (int)copy_region.bufferRowLength : w;
17421742
decompress_bcn_format(wb->mapped_address, staging_wb->mapped_address, w, h, src_w, format, offset);
17431743

1744+
/* Texture-path diagnostic (WRAPPER_DIAG_TEX=1): for each BCn CPU upload,
1745+
* record the real parameters (source stride, target format, image tiling/
1746+
* extent/usage) and dump the leading source BC7 bytes + our transcode
1747+
* output, so the transcode can be verified byte-for-byte offline against
1748+
* the reference decoder and any stride/format/tiling mismatch is visible. */
1749+
{
1750+
static int tex_diag = -1;
1751+
if (tex_diag == -1)
1752+
tex_diag = getenv("WRAPPER_DIAG_TEX") ? atoi(getenv("WRAPPER_DIAG_TEX")) : 0;
1753+
if (tex_diag) {
1754+
static int tex_n = 0;
1755+
struct wrapper_image *twi = get_wrapper_image_from_handle(device, dstImage);
1756+
VkFormat tgt = get_format_for_bcn(format);
1757+
const char *aid = getenv("WRAPPER_DIAG_APPID");
1758+
char tp[256];
1759+
snprintf(tp, sizeof(tp),
1760+
"/data/data/app.gamenative/files/imagefs/usr/tmp/wrapper_tex_%s.txt",
1761+
(aid && aid[0]) ? aid : "unknown");
1762+
FILE *tf = fopen(tp, tex_n ? "a" : "w");
1763+
if (tf) {
1764+
fprintf(tf,
1765+
"[TEX %d] bc=%d %dx%d mip=%u rowLen=%u imgH=%u off=%d srcStride=%d"
1766+
" -> target=%d uploadSize=%llu",
1767+
tex_n, format, w, h, copy_region.imageSubresource.mipLevel,
1768+
copy_region.bufferRowLength, copy_region.bufferImageHeight,
1769+
offset, src_w, tgt, (unsigned long long)upload_size);
1770+
if (twi)
1771+
fprintf(tf, " | img: fmt=%d extent=%ux%ux%u mips=%u tiling=%d usage=0x%x flags=0x%x",
1772+
twi->info.format, twi->info.extent.width, twi->info.extent.height,
1773+
twi->info.extent.depth, twi->info.mipLevels, twi->info.tiling,
1774+
twi->info.usage, twi->info.flags);
1775+
fprintf(tf, "\n");
1776+
if (tex_n < 4) {
1777+
unsigned char *src = (unsigned char *)wb->mapped_address + offset;
1778+
unsigned char *out = (unsigned char *)staging_wb->mapped_address;
1779+
int ns = 96, no = (upload_size < 256) ? (int)upload_size : 256;
1780+
fprintf(tf, " src:");
1781+
for (int b = 0; b < ns; b++) fprintf(tf, "%02x", src[b]);
1782+
fprintf(tf, "\n out:");
1783+
for (int b = 0; b < no; b++) fprintf(tf, "%02x", out[b]);
1784+
fprintf(tf, "\n");
1785+
}
1786+
fclose(tf);
1787+
}
1788+
fprintf(stderr, "[WRAPPER_TEX] #%d bc=%d %dx%d rowLen=%u -> target=%d tiling=%d\n",
1789+
tex_n, format, w, h, copy_region.bufferRowLength, tgt,
1790+
twi ? (int)twi->info.tiling : -1);
1791+
tex_n++;
1792+
}
1793+
}
1794+
17441795
copy_region.bufferOffset = 0;
17451796
copy_region.bufferRowLength = 0;
17461797
copy_region.bufferImageHeight = 0;

0 commit comments

Comments
 (0)