shader: draw a sampled texture through translated indexed mesh UVs #633

Manually merged
github merged 1 commit from gh-pr/633/head into gh-pr/633/base 2026-11-26 22:07:29 +00:00
Owner

@⁠descent81 on GitHub · 2026-11-22 16:51 UTC · original
descent81:mesh/textured-readback → main · +178 −8 · 8 files · 1 commits · merged 2026-11-22 17:16 UTC

Change

Connect the translated indexed mesh and its PARAM0 UVs to a translated image_sample_lz pixel shader in a single D3D12 draw. The fixture uploads a source-built 2×2 RGBA8 texture, binds a point-clamp sampler and compares all four output channels at every pixel against a CPU reference.

Both shader stages use t0. The root signature gives the mesh stage a root SRV for indexed vertex data and the pixel stage a texture SRV table using separate stage visibility. The initial pipeline creation failed on both backends with D3D12 message 662: the mesh exported four TEXCOORD0 components while the sampling pixel entry declared two. The pixel lowerer now accepts the required TEXCOORD width at this call site and still samples with xy. Existing callers retain the default.

CPU references matched against full GPU readback

Left to right: baseline, texture contents changed, and horizontal UV reflection. These are CPU reference images verified byte-for-byte against GPU readbacks.

Verification

Tested 751b954 on base 1947e97 with RTX 4060 (32.0.16.1088), Microsoft WARP (10.0.26100.9818) and Windows SDK DXC 1.8.2502.11.

  • Each backend passed six draws at 32×32, covering all three cases with mesh trace instrumentation enabled and disabled. The debug layer reported zero errors and warnings.
  • Comparing either changed scene to the stale baseline gave exactly 276 pixel mismatches; the 748 clear pixels and instrumented position/index records stayed identical. Both negative controls confirmed that an image mismatch was reported rather than a trace error.
  • All ten local mesh tests passed, covering entry, indexed, attribute, CBV order and textured draws on both backends. The mesh binary fixture and full pixel binary fixture suite passed using LLVM 15. Documentation links and bidi controls passed.
ctest --preset dev --no-tests=error -R '^mesh_(textured_draw|indexed_draw|attribute_draw|entry_draw|cbv_order)_(hardware|warp)$' -V
python3 -B tests/mesh_textured_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

Evidence and follow-up

The source-written programs, texels and CPU reference are under the repository's MIT license. Refs #546 for indexed PARAM0 and #544 for the linked pipeline. This fixture validates one point-clamped single-mip texture with a source-built mesh.

AI-assisted.

**@⁠descent81** on GitHub · 2026-11-22 16:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/633) `descent81:mesh/textured-readback` → `main` · +178 −8 · 8 files · 1 commits · merged 2026-11-22 17:16 UTC ## Change Connect the translated indexed mesh and its PARAM0 UVs to a translated `image_sample_lz` pixel shader in a single D3D12 draw. The fixture uploads a source-built 2×2 RGBA8 texture, binds a point-clamp sampler and compares all four output channels at every pixel against a CPU reference. Both shader stages use `t0`. The root signature gives the mesh stage a root SRV for indexed vertex data and the pixel stage a texture SRV table using separate stage visibility. The initial pipeline creation failed on both backends with D3D12 message 662: the mesh exported four TEXCOORD0 components while the sampling pixel entry declared two. The pixel lowerer now accepts the required TEXCOORD width at this call site and still samples with xy. Existing callers retain the default. ![CPU references matched against full GPU readback](https://raw.githubusercontent.com/descent81/Xbox2Windows/751b954/docs/mesh-textured-reference.png) Left to right: baseline, texture contents changed, and horizontal UV reflection. These are CPU reference images verified byte-for-byte against GPU readbacks. ## Verification Tested `751b954` on base `1947e97` with RTX 4060 (32.0.16.1088), Microsoft WARP (10.0.26100.9818) and Windows SDK DXC 1.8.2502.11. - Each backend passed six draws at 32×32, covering all three cases with mesh trace instrumentation enabled and disabled. The debug layer reported zero errors and warnings. - Comparing either changed scene to the stale baseline gave **exactly 276 pixel mismatches**; the 748 clear pixels and instrumented position/index records stayed identical. Both negative controls confirmed that an image mismatch was reported rather than a trace error. - All ten local mesh tests passed, covering entry, indexed, attribute, CBV order and textured draws on both backends. The mesh binary fixture and full pixel binary fixture suite passed using LLVM 15. Documentation links and bidi controls passed. ```powershell ctest --preset dev --no-tests=error -R '^mesh_(textured_draw|indexed_draw|attribute_draw|entry_draw|cbv_order)_(hardware|warp)$' -V ``` ```sh python3 -B tests/mesh_textured_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` ## Evidence and follow-up The source-written programs, texels and CPU reference are under the repository's MIT license. Refs #546 for indexed PARAM0 and #544 for the linked pipeline. This fixture validates one point-clamped single-mip texture with a source-built mesh. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:07:27 +00:00
github manually merged commit 751b954451 into gh-pr/633/base 2026-11-26 22:07:29 +00:00
Author
Owner

@⁠thepatrickworld on GitHub · 2026-11-22 17:34 UTC · original

@⁠descent81 Independent AMD (RDNA4) result on 751b954. Measurements only, no code change.

Environment

  • Windows 11 25H2, build 26200.9711
  • MSVC 19.44.35230 (toolset 14.44.35207), Windows SDK 10.0.26100.0, DXC 1.9.2602.17
  • AMD Radeon RX 9070 XT, vendor 1002, device 7550, driver 32.0.32029.2010
  • debug_layer=unavailable (Tools.Graphics.DirectX is NotPresent), so no validation-layer evidence here — your report had a clean debug layer, mine does not.
  • Clean worktree of the PR head 751b954 on base 14daa49f10.

Commands

cmake --preset dev
cmake --build --preset dev --parallel 12 --target offscreen_check
set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT
ctest --preset dev --no-tests=error -V -R "^mesh_textured_draw_(hardware|warp)$"

Observed

1/2 Test #225: mesh_textured_draw_hardware ... Passed  1.87 sec
2/2 Test #251: mesh_textured_draw_warp ....... Passed  0.95 sec

Six draws per backend (three cases × mesh trace instrumentation enabled and disabled), each pixels=1024 mismatches=0 across all four channels, against the CPU reference.

Negative controls, both stale references:

stale_reference=1 mismatches=276
stale_reference=2 mismatches=276

276 on each — the same count as your 32×32 reference, on a different vendor.

What this adds

The pipeline-creation failure you document (D3D12 message 662: the mesh stage exporting four TEXCOORD0 components while the sampling pixel entry declared two) does not reproduce here — the draw runs end to end on RDNA 4. That is the observable consequence of accepting the required TEXCOORD width at this call site; I did not instrument how many pipeline-creation attempts were made, so I cannot say whether the first attempt succeeded.

The 2×2 RGBA8 upload with a point-clamp sampler reads back identically to the CPU reference in all three cases (baseline, changed texels, horizontal UV reflection), so the UV path from indexed mesh PARAM0 through interpolation to the sampler is correct on this adapter as well.

AI-assisted; runs executed locally.

**@⁠thepatrickworld** on GitHub · 2026-11-22 17:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/633#issuecomment-7082943823) @⁠descent81 **Independent AMD (RDNA4) result on `751b954`.** Measurements only, no code change. ### Environment - Windows 11 25H2, build **26200.9711** - MSVC **19.44.35230** (toolset 14.44.35207), Windows SDK 10.0.26100.0, DXC **1.9.2602.17** - **AMD Radeon RX 9070 XT**, vendor 1002, device 7550, driver **32.0.32029.2010** - `debug_layer=unavailable` (`Tools.Graphics.DirectX` is `NotPresent`), so no validation-layer evidence here — your report had a clean debug layer, mine does not. - Clean worktree of the PR head `751b954` on base `14daa49f10`. ### Commands ``` cmake --preset dev cmake --build --preset dev --parallel 12 --target offscreen_check set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT ctest --preset dev --no-tests=error -V -R "^mesh_textured_draw_(hardware|warp)$" ``` ### Observed ``` 1/2 Test #225: mesh_textured_draw_hardware ... Passed 1.87 sec 2/2 Test #251: mesh_textured_draw_warp ....... Passed 0.95 sec ``` Six draws per backend (three cases × mesh trace instrumentation enabled and disabled), each `pixels=1024 mismatches=0` across all four channels, against the CPU reference. Negative controls, both stale references: ``` stale_reference=1 mismatches=276 stale_reference=2 mismatches=276 ``` **276** on each — the same count as your 32×32 reference, on a different vendor. ### What this adds The pipeline-creation failure you document (D3D12 message 662: the mesh stage exporting four `TEXCOORD0` components while the sampling pixel entry declared two) does not reproduce here — the draw runs end to end on RDNA 4. That is the observable consequence of accepting the required `TEXCOORD` width at this call site; I did not instrument how many pipeline-creation attempts were made, so I cannot say whether the first attempt succeeded. The 2×2 RGBA8 upload with a point-clamp sampler reads back identically to the CPU reference in all three cases (baseline, changed texels, horizontal UV reflection), so the UV path from indexed mesh PARAM0 through interpolation to the sampler is correct on this adapter as well. _AI-assisted; runs executed locally._
This discussion has been locked. Commenting is limited to contributors.
No description provided.