From 04e533742fb6c2353beb3e66a8274bc87bc0fa07 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 22 Feb 2021 17:03:12 +0000 Subject: [PATCH] Adjust pitch calculation in saved DDS files to match spec. Closes #2189 * The spec is not particularly clear but this matches the DirectXTex behaviour which is as close to 'official' as we'll get most likely. --- renderdoc/common/dds_readwrite.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renderdoc/common/dds_readwrite.cpp b/renderdoc/common/dds_readwrite.cpp index 4625c5d03..bf9a0c54b 100644 --- a/renderdoc/common/dds_readwrite.cpp +++ b/renderdoc/common/dds_readwrite.cpp @@ -774,7 +774,8 @@ bool write_dds_to_file(FILE *f, const write_dds_data &data) (data.format.type == ResourceFormatType::BC1 || data.format.type == ResourceFormatType::BC4) ? 8 : 16; - header.dwPitchOrLinearSize = RDCMAX(1U, ((header.dwWidth + 3) / 4)) * blockSize; + header.dwPitchOrLinearSize = + RDCMAX(1U, ((header.dwWidth + 3) / 4)) * blockSize * RDCMAX(1U, data.height / 4); } else {