Repository navigation
TEST-924: every texture format the game uses, from a real game texture, through the D3D12 layer (all 20 formats) - #4251
rafaelpssz wants to merge 13 commits into
Conversation
|
Automated test:
Same machine and setup as my earlier manual reports. AI-assisted (Claude Code). |
5e5903a to
81f9197
Compare
|
Thanks @CaravelaLabs. That failure was in the runner, not the layer: Fixed in #2887 ( |
|
Independent code read + CPU unit/assembly check at
AI-assisted review. |
|
Thanks @SweatierKey, a full read of the stack and the CPU checks on Linux are a useful complement to the GPU runs. You're in Thanks. |
|
Tested 81f9197 on NVIDIA RTX 4080, driver 610.88, Windows 11: fail. The test fails on some real textures in 6 formats; I found no layer error (the format mapping looks right). Ran (MSVC 19.44 / VS 2022 BuildTools, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0, base
Ramp: pass. Worst 0.00110, mean 0.000028, 0 channels over 0.002, 0 coverage mismatches. One exported texture per format (the first 2D DX10 DDS of each format I found, not chosen for content):
Formats 41 and 56 are refused by The pass/fail depends on the texture, not the format. For the six failing formats I ran 4 textures each:
Every failing run has a tiny mean error (≤ 0.0008) and at most 249 of about 29,000 channels over. Your missed-sRGB control gives 28,829 over, so these don't look like a wrong format or decode. A hypothesis I haven't checked: my model covers fewer pixels, so 256–512-texel textures are minified by 3× or more with only mip 0 bound. On high-contrast content, a tiny difference between the GPU's and the CPU's interpolated UV then lands on a different texel. Your tolerances were set on one texture per format, picked for ≥ 64 distinct values on a larger footprint. As written, the gate (
Game data stayed local; formats, counts and error magnitudes only. AI-assisted. |
|
Tested 81f9197 on NVIDIA GeForce RTX 5070, driver 621.01, Windows 11 Pro 26300, i7-14700K / 64 GB, MSVC 14.44 RelWithDebInfo (
Baseline on No game files. AI-assisted (Claude Code). |
|
Thanks @throny, this is the review the gate needed. You're right: as written, pass or fail depends on which texture and model the tester picks. My tolerances were set on one texture per format with my model's footprint, and that doesn't hold in general. Two things already show it on my side:
The plan, to be checked against a reproduction before I push:
A wrong format, swizzle or missed sRGB decode is a global error, so it still fails by orders of magnitude (I'll keep the BC1-sRGB-as-UNORM control in the tests). I'm exporting the first 4 textures of each of your six formats now to reproduce it here. Thanks too @traeb0n: 150/150 under validation, and the one extra runner skip being |
|
Follow-up at Automated test:
Same machine and setup as my earlier manual reports. AI-assisted (Claude Code). |
…apping @throny's run on another model failed 6 formats on a few hundred of 29,000 channels with a tiny mean (ItsNotRexed#4251). Reproduced here on three more game models; two rasteriser effects explained every failing channel: - A pixel centre 1e-5 px off an edge went to one triangle by the exact float test, while the GPU (vertices snapped to 1/256 px) gave it to the one behind. uv_map now measures edge distance in pixels: within EDGE_PX (1/128 px) a sample is an edge sample, reported when the candidates' UVs differ. - At up to 37 texels per pixel (mip 0 only) the same shift moves the UV by a tenth of a texel. expected_band.raw holds, per pixel and channel, how much the reference changes when the sample moves BAND_PX (1/32 px) along the triangle's UV gradient; the harness adds it to the tolerance. Float formats (values up to 34) get a relative tolerance, and a flattened 3D model may report up to 5% of its pixels (1.4% measured). 4 models x 37 textures (all 20 formats): 148/148 pass on an RTX 3060; the missed-sRGB control still fails (9,992 channels over). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@throny, fixed in
Also as planned: float formats (R16F, RGBA16F, BC6H, values up to 34) get a relative tolerance. A seam-heavy flattened model may report up to 5% of its pixels instead of 1% (one model measures 1.4%). Result (RTX 3060):
A rerun with your model and textures would be the real confirmation. You and @traeb0n are in Thanks. @CaravelaLabs, thanks for the follow-up: RADV 192/210 with |
|
Tested on an AMD Radeon RX 9060 XT (RDNA4), AMD Software 26.11.2 (Vulkan driver 2.0.416), Windows 11 26H2 (26300), MSVC 19.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8: pass for everything that runs without a game copy. This is AMD's Windows driver, next to the RTX 5070 and RADV runs above. At
At
I didn't run the ramp or the game-texture cases: both draw with the game's VS and PS from a work folder, and I didn't use a game copy for this check. AI-assisted (Claude Code). No game files. |
|
Thanks @SpositoDouglas. That is the first AMD Windows driver run (RDNA4) of this stack, and it agrees with the NVIDIA and RADV runs. The |
…apping @throny's run on another model failed 6 formats on a few hundred of 29,000 channels with a tiny mean (ItsNotRexed#4251). Reproduced here on three more game models; two rasteriser effects explained every failing channel: - A pixel centre 1e-5 px off an edge went to one triangle by the exact float test, while the GPU (vertices snapped to 1/256 px) gave it to the one behind. uv_map now measures edge distance in pixels: within EDGE_PX (1/128 px) a sample is an edge sample, reported when the candidates' UVs differ. - At up to 37 texels per pixel (mip 0 only) the same shift moves the UV by a tenth of a texel. expected_band.raw holds, per pixel and channel, how much the reference changes when the sample moves BAND_PX (1/32 px) along the triangle's UV gradient; the harness adds it to the tolerance. Float formats (values up to 34) get a relative tolerance, and a flattened 3D model may report up to 5% of its pixels (1.4% measured). 4 models x 37 textures (all 20 formats): 148/148 pass on an RTX 3060; the missed-sRGB control still fails (9,992 channels over). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f50b484 to
8820f1f
Compare
…apping @throny's run on another model failed 6 formats on a few hundred of 29,000 channels with a tiny mean (ItsNotRexed#4251). Reproduced here on three more game models; two rasteriser effects explained every failing channel: - A pixel centre 1e-5 px off an edge went to one triangle by the exact float test, while the GPU (vertices snapped to 1/256 px) gave it to the one behind. uv_map now measures edge distance in pixels: within EDGE_PX (1/128 px) a sample is an edge sample, reported when the candidates' UVs differ. - At up to 37 texels per pixel (mip 0 only) the same shift moves the UV by a tenth of a texel. expected_band.raw holds, per pixel and channel, how much the reference changes when the sample moves BAND_PX (1/32 px) along the triangle's UV gradient; the harness adds it to the tolerance. Float formats (values up to 34) get a relative tolerance, and a flattened 3D model may report up to 5% of its pixels (1.4% measured). 4 models x 37 textures (all 20 formats): 148/148 pass on an RTX 3060; the missed-sRGB control still fails (9,992 channels over). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8820f1f to
96eb48d
Compare
|
Rebased the stack on
On an RTX 3060: |
|
Tested 96eb48d on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
|
Tested
AI-Assisted (Antigravity - Gemini). |
…ples a T# (TEST-524) d3d12_first_light_textured_test draws the first-light mesh through the D3D12 layer with the game's VS and $PS_PassthroughCopy, picked by census (780 of 12,101 PS do one image_sample and nothing else; 148 of those link with the VS). The PS loads its T# through the table pointer in s8 and samples with a literal S#; the root signature puts a one-SRV table at s8:s9 behind eight padding constants. first_light.py --texture ramp writes texture.bin, a 64x64 coordinate ramp (texel (x, y) holds its own centre, so bilinear sampling gives back the UV), and expected.raw, the CPU reference at every covered pixel's UV. RTX 3060: 12,804 pixels, the same coverage as d3d12_first_light, worst channel error 0.00028 against a 0.002 tolerance; point sampling is off by up to 1/128, which is what this draw gave before ItsNotRexed#2887. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d reference A sample on a shared edge between triangles that give it different UVs belongs to whichever triangle the rasteriser's tie-break rule picks; uv_map let the last one win, so a correct draw could fail at a seam. Those pixels are now marked in expected.raw (alpha -2): coverage is still checked, the colour is not, and the test counts them. Found by @whattheflop's diagonal-quad fixture, which is now a unit test. The first-light model has no seam pixels; its result is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nterior one An earlier edge no longer exempts a pixel that a later interior owns (@whattheflop's nested-triangle fixture), and a lone edge over an older interior with another UV is ambiguous. Edge hits after the last interior that share one UV are an edge both triangles share, which the tie-break gives to one of them: not ambiguous. Without that rule the flattened first-light model's front layer, drawn over its back layer, marked 188 pixels; with it, 0, and all 12,804 are compared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Equal UVs don't make two triangles share an edge. The rasteriser gives one owner only to triangles on opposite sides of a common edge with identical endpoints, so the shortcut now requires such a pair among the later edge hits; a sample on a vertex never takes it. @whattheflop's overlapping right edges (same side, different endpoints) stay ambiguous. The first-light model: 8 ambiguous samples, 12,796 compared, unchanged worst error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h _dupenv_s MSVC warns about std::getenv (C4996); pe_loader_test reads its environment the same way. Reported by @JRamos1993. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mes no option that doesn't exist Reported by @zzEmmazz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s harness path Since the rebase onto 7e1aecf, --texture ramp exited with a TypeError: write_textured_inputs stored "texture": "ramp" and files["texture"], which harness_env reads as the --dds dict. The ramp's keys are now layer_texture*; a unit test feeds harness_env a ramp manifest (fails on the old keys). The vk_harness tests skip a ramp folder, which only the D3D12-layer test can draw. docs/first_light.md §7: the command names its --out, and the count without ItsNotRexed#2887 is 19,041 channels (measured here and on three other GPUs). Found by @zzEmmazz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… PS (13 game copy shaders pass) d3d12_first_light_textured fixed the table at s8 and the T# at slot 0. It now reads layer_ptr_sgpr (from the index's user_sgpr_reads) and layer_tsharp_offset (the PS's first s_load_dwordx8 offset), pads the root signature to that SGPR and puts the SRV in that slot, so any 2D copy PS can be checked. Of the 24 copy PS that link with the first-light VS, all 13 comparable ones pass on an RTX 3060 with worst error 0.00028 (11 plain copies, 2 that remap channels, checked per channel); 7 transform the UV and 4 use array/cube textures. docs/first_light.md §7 has the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… through the D3D12 layer first_light.py --texture-dds writes a DDS's mip 0 in its own format (BC blocks included) and a CPU reference from ttpf_mips.decode_pixels with each format's channel rules (sRGB linearised before filtering, A8, R8, BC4, BC5); d3d12_first_light_textured uploads block formats and skips the channels the reference can't predict. Tolerances are per format, set by measurement: the BC1/BC3 palette and BC6H are where hardware rounding legitimately differs from the CPU decode, and a missed sRGB decode (the negative control) is off by 0.31. On an RTX 3060, one game texture per format (17 of the package's 20 formats, all but 10 textures): every one passes. docs/first_light.md §8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ayer RGBA16F (256x2) and RGBA16 UNORM (128x4) pass; RGBA8 sRGB's only 2D texture is a uniform 4x4, so its row is marked as weak (its sRGB decode is covered by BGRA8 sRGB and the BC sRGB rows). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…apping @throny's run on another model failed 6 formats on a few hundred of 29,000 channels with a tiny mean (ItsNotRexed#4251). Reproduced here on three more game models; two rasteriser effects explained every failing channel: - A pixel centre 1e-5 px off an edge went to one triangle by the exact float test, while the GPU (vertices snapped to 1/256 px) gave it to the one behind. uv_map now measures edge distance in pixels: within EDGE_PX (1/128 px) a sample is an edge sample, reported when the candidates' UVs differ. - At up to 37 texels per pixel (mip 0 only) the same shift moves the UV by a tenth of a texel. expected_band.raw holds, per pixel and channel, how much the reference changes when the sample moves BAND_PX (1/32 px) along the triangle's UV gradient; the harness adds it to the tolerance. Float formats (values up to 34) get a relative tolerance, and a flattened 3D model may report up to 5% of its pixels (1.4% measured). 4 models x 37 textures (all 20 formats): 148/148 pass on an RTX 3060; the missed-sRGB control still fails (9,992 channels over). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n landed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96eb48d to
bd7b456
Compare
|
Rebased onto |
|
Re-tested the current head Without the package
With the package
Where the worst error is above the format's tolerance, the count over the tolerance is still 0. Those pixels are within the per-pixel Negative control. I kept the BC1 sRGB folder's An observation for anyone choosing a model. Before A and B, I tried 10 random AI-assisted (Claude Code). |
…ixels The 5% seam-pixel limit depends on the model: thin models covering 500 to 1,600 pixels reached 5 to 8% and failed it before any colour was compared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@465d6a0eac Thanks for the re-run and the negative control. Good point on model choice: §9 now says to pick a model that covers a few thousand pixels, since thin models of 500 to 1,600 covered pixels can reach 5 to 8% seam pixels and fail that check before any colour is compared (39c6360). |
|
Tested 7/7 cases passed using the same exported OBJ and shader pair throughout. Each run compared 12,732 pixels, with zero coverage mismatches and zero color channels over tolerance.
The six DDS textures came from my local 1.0.2.1 export. Game files and raw GPU output stayed local. AI-assisted. |
Claim (new TEST item).
Depends on: #2906 (and through it on #2887). Its commits are the base here; only the top commit,
b90d802b, is new.What
This checks every texture format the game actually uses by sampling a real game texture through the D3D12 layer, each in its own format, BC blocks included.
The package's 357,115 TTPF descriptors use 20 DXGI formats, counted on my 1.0.2.1 copy:
The changes:
first_light.py --texture-dds <file>reads a DX10 DDS's mip 0 (asttpf_mips.py exportwrites it) intotexture.binin its own format. It writes the CPU reference toexpected.raw, decoded withttpf_mips.decode_pixelsand these per-format rules:d3d12_first_light_textureduploads block-compressed formats (rows of 4×4 blocks) and skips NaN channels.dds_tolerance).Result: RTX 3060, driver 616.64, one game texture per format with ≥ 64 distinct values
| RGBA16F (256×2), RGBA16 UNORM (128×4) | ≤ 0.0045 | 2/255 | pass |
| RGBA8 sRGB (4×4, uniform: a weak case) | 0 | 2/255 | pass |
All 20 formats pass. RGBA8 sRGB's only 2D texture in the package is a uniform 4×4. Its sRGB decode is the same one that BGRA8 sRGB and the BC sRGB rows exercise with real content.
Why some tolerances are wider (a measurement, not a guess). It's the decoder arithmetic, not the layer. I regenerated the BC1/BC3 reference with different palette arithmetic: integer weights
(43a + 21b + 32) >> 6match the RTX 3060's output 5–7× better than the exact(2a + b) / 3thatttpf_mipsuses (the channels over 2/255 drop from 287 to 40 for BC1 and from 892 to 355 for BC3). BC4/BC5 interpolate their palette above 8 bits.Negative control. I declared the BC1 sRGB texture as BC1 UNORM, the bug a layer that drops the sRGB decode would have. That gives a worst error of 0.31 with 28,829 channels over, and the test fails. Every tolerance is under 0.05, which a unit test pins.
Tests without the package
tests/test_first_light.py, 32 run (4 package-gated skips):The ramp result from #2906 is unchanged (worst 0.00028).
No texture data, shaders or images are in the PR; everything stays in the user's work folder.
Thanks
ps_m2_literalmissing from the GPU runner's harness map (fixed in d3d12: a pipeline registers its shaders' literal S#s (they sampled through the fallback) #2887,5cd7fe73).81f91972(Linux).f50b4844).ps_m2_literalchecks pass).bd7b4567with two models (28/28 draws, plus the missed-sRGB control), and for the note on model choice, now in §9 (39c63602).Update: the reference allows for sub-pixel snapping (
f50b4844)@throny's run on another model failed on a few hundred channels. Two rasteriser effects explained every one:
The reference now treats a sample within 1/128 px of an edge as an edge sample. It also writes a per-pixel band,
expected_band.raw: how much its value changes when the sample moves 1/32 px along the UV gradient. Float formats get a relative tolerance.Re-run on 4 game models × 37 textures (all 20 formats): 148/148 pass, 0 channels over. The missed-sRGB control still fails (9,992 channels over).
By @rafaelpssz, with Claude Code (AI-assisted).