From 1e3fc0e32092abbdde5b4eac54be56801c4f4c14 Mon Sep 17 00:00:00 2001 From: Theodore Cipicchio Date: Sun, 25 Apr 2021 22:24:00 -0700 Subject: [PATCH] Fix row count calculation when writing block-compressed DDS data Block-compressed textures with dimensions that are not evenly divisible by the block size are typically padded internally to align with the block size. load_dds_from_file() was previously corrected to account for this alignment when calculating the number of rows of blocks to read from a DDS file, but the fix was not applied to write_dds_to_file(), resulting in missing rows of texels or loading failures when attempting to open a DDS file generated by RenderDoc from a texture whose dimensions are not a multiple of four. --- renderdoc/common/dds_readwrite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renderdoc/common/dds_readwrite.cpp b/renderdoc/common/dds_readwrite.cpp index 8d557be80..e8f51fc45 100644 --- a/renderdoc/common/dds_readwrite.cpp +++ b/renderdoc/common/dds_readwrite.cpp @@ -924,7 +924,7 @@ bool write_dds_to_file(FILE *f, const write_dds_data &data) // pitch/rows are in blocks, not pixels, for block formats. if(blockFormat) { - numRows = RDCMAX(1U, numRows / 4); + numRows = RDCMAX(1U, (numRows + 3) / 4); uint32_t blockSize = (data.format.type == ResourceFormatType::BC1 || data.format.type == ResourceFormatType::BC4)