From 3474dd6716fb91ff3c5f6f9a0f90474379852479 Mon Sep 17 00:00:00 2001 From: gensokyo-dev Date: Wed, 2 Dec 2026 00:46:50 +0000 Subject: [PATCH] fix(artifacts): report a DDS with no payload bytes as truncated Every DDS surface holds at least one texel, so a file that ends at its payload offset is truncated even when the format's exact size is not derived, such as planar video formats. Fixes #15674 Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --- docs/gpu-asset-headers.md | 3 ++- src/artifacts/gpuAsset/GpuAssetLayouts.ts | 8 ++++++++ tests/acceptance/gpuAssetHeadersCli.test.ts | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/gpu-asset-headers.md b/docs/gpu-asset-headers.md index 0f3f8a6fd4e..cdae0b9b83a 100644 --- a/docs/gpu-asset-headers.md +++ b/docs/gpu-asset-headers.md @@ -58,7 +58,8 @@ Detection reads the bytes, so the file name does not matter: disagreement is reported as a fact, not a refusal: - A truncated DDS keeps its partial `payload.bin` and reports - `payload_bytes` next to `expected_payload_bytes`. + `payload_bytes` next to `expected_payload_bytes`. A DDS that ends at its + payload offset is `truncated` even when its size is not derived. - A GLB, KTX or KTX2 region that ends past the file is not listed. A region is never clipped. A limitation names the region and the file end. - Bytes after every declared region are counted in a limitation. diff --git a/src/artifacts/gpuAsset/GpuAssetLayouts.ts b/src/artifacts/gpuAsset/GpuAssetLayouts.ts index 9040ddbbe47..f115c8df864 100644 --- a/src/artifacts/gpuAsset/GpuAssetLayouts.ts +++ b/src/artifacts/gpuAsset/GpuAssetLayouts.ts @@ -205,6 +205,14 @@ export const ddsLayout = ( `DDS payload holds ${String(payloadBytes)} byte(s) but its declared dimensions, mips and format need ${String(expected)}; the file is ${extent === "truncated" ? "truncated" : "followed by undeclared bytes"}.`, ); } + // Every DDS surface holds at least one texel, so an empty payload is short + // even when the format's exact size is not derived. + if (expected === null && payloadBytes === 0) { + extent = "truncated"; + limitations.push( + "DDS payload holds 0 bytes but the header declares at least one texel; the file is truncated.", + ); + } if (expected === null) limitations.push( mips === undefined diff --git a/tests/acceptance/gpuAssetHeadersCli.test.ts b/tests/acceptance/gpuAssetHeadersCli.test.ts index 738f156e492..939a08b059d 100644 --- a/tests/acceptance/gpuAssetHeadersCli.test.ts +++ b/tests/acceptance/gpuAssetHeadersCli.test.ts @@ -134,6 +134,13 @@ cliTest.for([ expected: 65_536, extent: "truncated", }, + { + label: "an NV12 header with no payload", + dxgiFormat: 103, + payloadBytes: 0, + expected: null, + extent: "truncated", + }, ] as const)( "checks the DDS extent of $label through the CLI", async ({ dxgiFormat, payloadBytes, expected, extent }, { cli }) => {