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>
This commit is contained in:
gensokyo-devandgensokyo-dev authored and Ysopwnable committed 2026-12-02 09:03:56 +08:00
1 parent ea8b79b362
commit 3474dd6716
3 files changed
+17 -1

No files matched your search

+2 -1
View File
@@ -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.
@@ -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
@@ -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 }) => {