gpu: follow-up to #671/#682 — a lit, shadowed scene through the translated mesh and pixel stages #724

Open
opened 2026-11-22 23:25:34 +00:00 by roansystemlabs · 13 comments
roansystemlabs commented 2026-11-22 23:25:34 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-22T23:25:34Z.


Problem

#682 (grahamster2, on the issue you defined in #671) runs the translated compute → mesh → pixel chain from the shim EXE's PE entry, and native Windows, pe_map and AOT agree on every published byte. Depth occlusion between two translated mesh draws is verified separately in #639 (descent81), and texture reuse across EXE-driven draws in #705 (RonLogic).

What no fixture covers yet is lighting and shadowing with translated stages:

  • No fixture computes lighting in a translated pixel stage (a normal from the mesh, N·L in the pixel stage).
  • No fixture draws a two-pass shadow (depth from the light, then a comparison sample). That needs image_sample_c_lz → SampleCmpLevelZero, which is our open #718 (your review asked for a filter-boundary case; we're working on it).
  • Depth, texture, lighting and shadow have never been drawn together in one translated scene, inside the EXE path or outside it.

Proposal

A small next step after #682, not a new demo: a lit, shadowed scene built from translated stages. We'd like to take it, one small PR at a time, each opened only after the previous one is reviewed:

  1. Lit fixture (outside the EXE path). The translated mesh exports a normal in a second parameter; the translated pixel stage computes N·L. Axis-aligned normals and exactly representable light values keep the readback bit-exact on WARP and hardware. An independent CPU reference, plus negative controls (inverted light, normal ignored).
  2. Shadow fixture, only after #718 has merged. Two passes with translated stages: depth from the light, then SampleCmpLevelZero. Controls: swapped LESS/GREATER comparison and a stale shadow map.
  3. Combined scene, still outside the EXE: a small object on a plane, with texture, depth, light and shadow. Readback compared pixel by pixel.
  4. EXE hookup: new X2W_SHIM_DRAW_CASE values on the draw_request/draw_frame contract from #560/#682, with no signature or import-table change, compared across native, pe_map and AOT, with a stale-input control like chain-stale.
  5. (Optional) Presentation through a swapchain, with a backbuffer readback. No fixture creates a swapchain today, and this step adds little evidence, so we'd leave it last or drop it.

#721 remains our priority. We won't start step 1 until you reply here.

Alternatives

  • One large "scene" PR. That's harder to review, and it mixes our work with code that grahamster2, descent81 and RonLogic wrote. Small steps keep each check on its own.
  • Lighting only, with no shadow. Shorter, but the comparison sampling from #718 would never run inside a scene.
  • Starting from the EXE. It changes the shared provider before the scene is verified. Doing it last keeps the #560 contract untouched until there's something worth wiring.

Verification

  • Every step runs as a focused CTest on WARP and on an RTX 3070 with the D3D12 debug layer enabled, in both the dev and release presets. We'll record the tested SHA, commands and results.
  • References come from Python and do not depend on D3D12, like shim_chain_check.py. Every RGBA byte must match. Each negative control must produce a known, nonzero mismatch while the uncovered pixels still match.
  • Step 4: the three runners must agree on stderr, exit status and all published bytes. #560's and #682's existing cases must still pass unchanged.
  • Adapters without mesh shaders report a capability skip, as cpu_shim_chain_hardware already does.

Questions

  1. Would you rather keep the EXE hookup (step 4) under main development, as you wrote on #218? If so, we'll stop at step 3.
  2. Should we coordinate with grahamster2, descent81 and RonLogic directly, or announce shared edits on #218 as #682 did?
  3. Is a 32×32 target with a small object on a plane enough for the scene, or would you prefer other acceptance criteria?

AI-assisted: yes

Checklist

  • I checked for an existing issue or pull request for this change. (No issue or PR mentions lighting, diffuse shading, a shadow scene or a swapchain. The only comparison-sampling items are our #710/#718 for pixel_aot and #670 for the SPIR-V bridge. #682 and #705 are merged, and RonLogic/Xbox2Windows#1 changes shim_draw_gpu.cpp for multi-frame draws, not lighting.)
  • I did not include game files, dumps, distribution links or credentials.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6549183769 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-22T23:25:34Z. --- ### Problem #682 (grahamster2, on the issue you defined in #671) runs the translated compute → mesh → pixel chain from the shim EXE's PE entry, and native Windows, `pe_map` and AOT agree on every published byte. Depth occlusion between two translated mesh draws is verified separately in #639 (descent81), and texture reuse across EXE-driven draws in #705 (RonLogic). What no fixture covers yet is lighting and shadowing with translated stages: - No fixture computes lighting in a translated pixel stage (a normal from the mesh, N·L in the pixel stage). - No fixture draws a two-pass shadow (depth from the light, then a comparison sample). That needs `image_sample_c_lz` → `SampleCmpLevelZero`, which is our open #718 (your review asked for a filter-boundary case; we're working on it). - Depth, texture, lighting and shadow have never been drawn together in one translated scene, inside the EXE path or outside it. ### Proposal A small next step after #682, not a new demo: a lit, shadowed scene built from translated stages. We'd like to take it, one small PR at a time, each opened only after the previous one is reviewed: 1. **Lit fixture** (outside the EXE path). The translated mesh exports a normal in a second parameter; the translated pixel stage computes N·L. Axis-aligned normals and exactly representable light values keep the readback bit-exact on WARP and hardware. An independent CPU reference, plus negative controls (inverted light, normal ignored). 2. **Shadow fixture**, only after #718 has merged. Two passes with translated stages: depth from the light, then `SampleCmpLevelZero`. Controls: swapped LESS/GREATER comparison and a stale shadow map. 3. **Combined scene**, still outside the EXE: a small object on a plane, with texture, depth, light and shadow. Readback compared pixel by pixel. 4. **EXE hookup**: new `X2W_SHIM_DRAW_CASE` values on the `draw_request`/`draw_frame` contract from #560/#682, with no signature or import-table change, compared across native, `pe_map` and AOT, with a stale-input control like `chain-stale`. 5. (Optional) Presentation through a swapchain, with a backbuffer readback. No fixture creates a swapchain today, and this step adds little evidence, so we'd leave it last or drop it. #721 remains our priority. We won't start step 1 until you reply here. ### Alternatives - **One large "scene" PR.** That's harder to review, and it mixes our work with code that grahamster2, descent81 and RonLogic wrote. Small steps keep each check on its own. - **Lighting only, with no shadow.** Shorter, but the comparison sampling from #718 would never run inside a scene. - **Starting from the EXE.** It changes the shared provider before the scene is verified. Doing it last keeps the #560 contract untouched until there's something worth wiring. ### Verification - Every step runs as a focused CTest on WARP and on an RTX 3070 with the D3D12 debug layer enabled, in both the dev and release presets. We'll record the tested SHA, commands and results. - References come from Python and do not depend on D3D12, like `shim_chain_check.py`. Every RGBA byte must match. Each negative control must produce a known, nonzero mismatch while the uncovered pixels still match. - Step 4: the three runners must agree on stderr, exit status and all published bytes. #560's and #682's existing cases must still pass unchanged. - Adapters without mesh shaders report a capability skip, as `cpu_shim_chain_hardware` already does. ### Questions 1. Would you rather keep the EXE hookup (step 4) under main development, as you wrote on #218? If so, we'll stop at step 3. 2. Should we coordinate with grahamster2, descent81 and RonLogic directly, or announce shared edits on #218 as #682 did? 3. Is a 32×32 target with a small object on a plane enough for the scene, or would you prefer other acceptance criteria? AI-assisted: yes ### Checklist - [x] I checked for an existing issue or pull request for this change. (No issue or PR mentions lighting, diffuse shading, a shadow scene or a swapchain. The only comparison-sampling items are our #710/#718 for `pixel_aot` and #670 for the SPIR-V bridge. #682 and #705 are merged, and RonLogic/Xbox2Windows#1 changes `shim_draw_gpu.cpp` for multi-frame draws, not lighting.) - [x] I did not include game files, dumps, distribution links or credentials.
R0Y00 commented 2026-11-24 06:48:52 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T23:55:21Z.


Please start with the standalone lit fixture once it fits around #721. An independent pixel reference and the inverted-light and ignored-normal controls are the right first slice. Keep the shadow pass dependent on #718, and wire the combined scene into the EXE only after the standalone comparisons pass. Reuse the current draw_request/draw_frame ABI and keep the three-runner output and stale-input checks at that stage. The swapchain can stay outside this work.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7087930704 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7087930704). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T23:55:21Z. --- Please start with the standalone lit fixture once it fits around #721. An independent pixel reference and the inverted-light and ignored-normal controls are the right first slice. Keep the shadow pass dependent on #718, and wire the combined scene into the EXE only after the standalone comparisons pass. Reuse the current `draw_request`/`draw_frame` ABI and keep the three-runner output and stale-input checks at that stage. The swapchain can stay outside this work.
roansystemlabs commented 2026-11-24 06:48:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-23T00:18:48Z.


Thanks. Starting the standalone lit fixture now (independent pixel reference, inverted-light and ignored-normal controls; no shadow pass, no EXE wiring yet). I'll link the PR here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7088245103 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7088245103). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-23T00:18:48Z. --- Thanks. Starting the standalone lit fixture now (independent pixel reference, inverted-light and ignored-normal controls; no shadow pass, no EXE wiring yet). I'll link the PR here.
roansystemlabs commented 2026-11-24 06:48:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-23T00:47:45Z.


First slice is up: #749 (standalone lit fixture with an independent pixel reference; inverted-light, ignored-normal and missing-clamp controls). The shadow fixture comes next, now that #718 is in main.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7088639730 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7088639730). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-23T00:47:45Z. --- First slice is up: #749 (standalone lit fixture with an independent pixel reference; inverted-light, ignored-normal and missing-clamp controls). The shadow fixture comes next, now that #718 is in main.
R0Y00 commented 2026-11-24 06:48:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T01:23:11Z.


The standalone lighting step merged in #749. It uses the existing indexed mesh path and checks the complete lit image against an independent reference, with inverted light, ignored normal and omitted clamp as mismatch controls. #718 is also merged, so the separate depth-comparison shadow slice can proceed. The issue stays open for the combined draw and EXE hookup.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7089100687 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7089100687). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T01:23:11Z. --- The standalone lighting step merged in #749. It uses the existing indexed mesh path and checks the complete lit image against an independent reference, with inverted light, ignored normal and omitted clamp as mismatch controls. #718 is also merged, so the separate depth-comparison shadow slice can proceed. The issue stays open for the combined draw and EXE hookup.
roansystemlabs commented 2026-11-24 06:48:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-23T02:08:53Z.


Shadow slice is up: #773 (light-view depth pass with the translated mesh program, plane compared through SampleCmpLevelZero from #718, lit object from #749; independent reference; swapped-compare, stale-map, ignored-map, coverage-for-depth and missing-occluder controls). Wiring the scene into the EXE comes after it.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7089701121 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7089701121). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-23T02:08:53Z. --- Shadow slice is up: #773 (light-view depth pass with the translated mesh program, plane compared through SampleCmpLevelZero from #718, lit object from #749; independent reference; swapped-compare, stale-map, ignored-map, coverage-for-depth and missing-occluder controls). Wiring the scene into the EXE comes after it.
R0Y00 commented 2026-11-24 06:48:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T02:26:00Z.


#773 merged as 03d4fbc. The standalone fixture now checks the translated light pass and SampleCmpLevelZero camera pass. RTX 3070 and WARP matched all 4,096 color pixels and 4,096 depth texels, and the stale-map and coverage-instead-of-depth controls produced different readbacks. The normal and /O2 Windows jobs and both Linux jobs passed. The remaining step here is to wire the same scene and readback into the EXE comparison.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7089932686 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7089932686). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T02:26:00Z. --- #773 merged as `03d4fbc`. The standalone fixture now checks the translated light pass and SampleCmpLevelZero camera pass. RTX 3070 and WARP matched all 4,096 color pixels and 4,096 depth texels, and the stale-map and coverage-instead-of-depth controls produced different readbacks. The normal and /O2 Windows jobs and both Linux jobs passed. The remaining step here is to wire the same scene and readback into the EXE comparison.
R0Y00 commented 2026-11-24 06:49:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T04:54:24Z.


@roansystemlabs I’m picking up the two-frame EXE integration requested by the maintainer. I’ll reuse your #773 renderer and oracle, keep the resources live across both frames, move the occluder for frame two, and use the previous depth map as the negative control. If you already have EXE integration commits, please link them here so I can build on them. I’ll compare both outputs, cleanup and exit status across Windows, pe_map and AOT on hardware and WARP.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7091959862 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7091959862). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T04:54:24Z. --- @roansystemlabs I’m picking up the two-frame EXE integration requested by the maintainer. I’ll reuse your #773 renderer and oracle, keep the resources live across both frames, move the occluder for frame two, and use the previous depth map as the negative control. If you already have EXE integration commits, please link them here so I can build on them. I’ll compare both outputs, cleanup and exit status across Windows, pe_map and AOT on hardware and WARP.
R0Y00 commented 2026-11-24 06:49:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T05:17:21Z.


The two-frame EXE integration merged in #797 at 16b433c. Thanks @roansystemlabs for the standalone renderer and reference in #773. On RTX 4060 Laptop and WARP, native Windows, pe_map and AOT matched both color and light-depth frames, four owned surface releases and exit 42. Moving the caster four pixels in frame two made the previous-map control differ at exactly 170 second-frame color pixels on each runner, with both depth readbacks correct.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7092276360 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7092276360). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T05:17:21Z. --- The two-frame EXE integration merged in #797 at 16b433c. Thanks @roansystemlabs for the standalone renderer and reference in #773. On RTX 4060 Laptop and WARP, native Windows, pe_map and AOT matched both color and light-depth frames, four owned surface releases and exit 42. Moving the caster four pixels in frame two made the previous-map control differ at exactly 170 second-frame color pixels on each runner, with both depth readbacks correct.
R0Y00 commented 2026-11-24 06:49:05 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T09:12:39Z.


I’m taking the next integration step using the existing source-built scene and oracle from #773 and #797. The EXE will call the device creation import itself, select the shadow-map binding for each frame, and submit and wait for each frame separately. The current two-frame fixture records both frames into one command list. The comparison will cover native Windows, pe_map and AOT on WARP and a physical adapter, including the stale-map and device rejection controls and a rejected second submission that preserves the first frame. The device entry retains the existing desktop IID and null parameter block scope from #799.

CPU/PE review of the import binding and GPU review of fence and resource lifetime are welcome once the candidate is up. For independent adapter work, #810 remains open for mesh pipeline retests.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7096355845 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7096355845). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T09:12:39Z. --- I’m taking the next integration step using the existing source-built scene and oracle from #773 and #797. The EXE will call the device creation import itself, select the shadow-map binding for each frame, and submit and wait for each frame separately. The current two-frame fixture records both frames into one command list. The comparison will cover native Windows, pe_map and AOT on WARP and a physical adapter, including the stale-map and device rejection controls and a rejected second submission that preserves the first frame. The device entry retains the existing desktop IID and null parameter block scope from #799. CPU/PE review of the import binding and GPU review of fence and resource lifetime are welcome once the candidate is up. For independent adapter work, #810 remains open for mesh pipeline retests.
R0Y00 commented 2026-11-24 06:49:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T09:39:28Z.


#826 and #829 are on main. Thanks to the #773 and #797 contributors for the scene and independent reference. The source-built EXE now calls the real device import and chooses the frame and shadow-map slot before each fixture submission.

On the RTX 4060 Laptop GPU and WARP, native Windows, pe_map and AOT each produced the same 65,536 color and light-depth bytes with two submissions and fences 1 and 2. The stale binding changed 170 second-frame color pixels. The invalid second submission kept the first frame intact, released the four tracked surfaces and device, and exited 24. All four CI jobs for #829 passed.

#830 is open for claiming the next integration test. It uses the independent archive reader to drive GPU upload and readback, with a truncated second record as the cleanup control.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7096931935 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7096931935). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T09:39:28Z. --- #826 and #829 are on `main`. Thanks to the #773 and #797 contributors for the scene and independent reference. The source-built EXE now calls the real device import and chooses the frame and shadow-map slot before each fixture submission. On the RTX 4060 Laptop GPU and WARP, native Windows, `pe_map` and AOT each produced the same 65,536 color and light-depth bytes with two submissions and fences 1 and 2. The stale binding changed 170 second-frame color pixels. The invalid second submission kept the first frame intact, released the four tracked surfaces and device, and exited 24. All four CI jobs for #829 passed. #830 is open for claiming the next integration test. It uses the independent archive reader to drive GPU upload and readback, with a truncated second record as the cleanup control.
roansystemlabs commented 2026-11-24 13:00:52 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-24T12:14:38Z.


Update, outside the steps above: a larger scene through the same translated stages, rendered locally on main at 5bfafce2. It is a local harness outside the tree, not a project test; the details are here so you can judge whether any of it should become one.

One frame of the scene, 1920×1080

The full 14 s turn, downscaled GIF

Full video, 1920×1080, 14 s: scene_1920x1080.mp4

What was drawn. A round platform with six solids (hexagonal column, cube, pyramid, icosahedron, low slab, small monolith), a perspective camera swinging ±24°, and a sun at 31° elevation making one full turn in 14 s. Two framings of the same scene, 420 frames each: landscape rendered at 3840×2160 and portrait at 2160×2700, both downsampled 2×2 in linear light (to 1920×1080 and 1080×1350), with a 4096×4096 shadow map. NVIDIA GeForce RTX 3070, driver 621.01, D3D12 debug layer on.

What goes through the translator. Three source-built gfx1013 programs, assembled with the LLVM 15 chain used by the binary checks and translated from machine code by tools/mesh_entry_aot.py and tools/pixel_aot.py at 5bfafce2. Each binary translates to the same HLSL as its source text, and dxc compiles that HLSL unedited.

  • Mesh (404 bytes, 78 instructions, the #546 indexed path): camera projection and light-space coordinates from the matrices in b1 and b0. The same program, with the light matrix in b1, draws the shadow map.
  • Scene pixel (360 bytes, 68 instructions): N·L, image_sample_c_lz lowered to SampleCmpLevelZero with the bilinear comparison filter, hemisphere ambient and albedo, binary16 export as in #749 and #773.
  • Light pixel (112 bytes, 25 instructions): the #749 program as adapted in the #773 light pass.

What does not. The CPU builds the world-space triangles, the per-face constants (normal, colour, plane coefficients) and the camera and light matrices of each frame. The host is my own D3D12 program, with the #773 root signature, no window or swapchain, and readback from GPU memory. It is not the EXE path, and no title code is involved. I did not measure performance.

Checks. debug_errors=0 debug_warnings=0 on all 840 frames. In the first frame of each video, the exported mesh positions of both passes match a CPU matrix × vertex product on 6,840 vertices, with a largest error of 3.1e-6 (|got - want| / max(1, |want|)). There is no pixel reference: per frame I checked mean luma (34 to 56 of 255 landscape, 41 to 64 portrait) and the mean absolute change between consecutive frames (at most 0.63 of 255 landscape, 0.74 portrait), and I looked at full-size frames of both videos for shadows falling away from the sun.

Three translator limits this ran into (lines at 5bfafce2):

  1. When the pixel program is translated with a sampler, v_interp_p1/p2_f32 is accepted only for attr0.x and attr0.y, at entry or in whole-quad mode (pixel_aot.py#L3840-L3845), and whole-quad arithmetic on them is limited to add, fma and mul_legacy and must stay affine (#L4125-L4145). The light-space depth could not be interpolated, so the pixel program evaluates it from each face's plane (a·u + b·v + c, coefficients in b0). That is exact only because every face is flat.
  2. The number of samples must equal the number of bound textures (pixel_aot.py#L5622), so with one shadow map multi-tap PCF is not possible; the only softening is the 2×2 bilinear comparison.
  3. The mesh translation accepts a single three-vertex triangle (mesh_entry_aot.py#L581-L582), so each frame is one DispatchMesh per triangle: 1,032 in the shadow pass (casters only) and 1,248 in the camera pass.

I found no existing issue for these.

Question. Which would be more useful to you, if either?

  • (a) A deterministic mesh_scene_draw_{hardware,warp} test: a few frames with fixed lights on a small target, point comparison filter, values kept off every boundary as in #773, an independent Python reference and negative controls.
  • (b) Separate issues for the three limits, one at a time, each with a minimal program the translator refuses today.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7131165523 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7131165523). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-24T12:14:38Z. --- Update, outside the steps above: a larger scene through the same translated stages, rendered locally on `main` at `5bfafce2`. It is a local harness outside the tree, not a project test; the details are here so you can judge whether any of it should become one. ![One frame of the scene, 1920×1080](https://raw.githubusercontent.com/roansystemlabs/Xbox2Windows/23e278d6850b191b85d6028d89e63709007ec0d3/issue-730/scene_frame.png) ![The full 14 s turn, downscaled GIF](https://raw.githubusercontent.com/roansystemlabs/Xbox2Windows/23e278d6850b191b85d6028d89e63709007ec0d3/issue-730/scene_720.gif) Full video, 1920×1080, 14 s: [scene_1920x1080.mp4](https://raw.githubusercontent.com/roansystemlabs/Xbox2Windows/23e278d6850b191b85d6028d89e63709007ec0d3/issue-730/scene_1920x1080.mp4) **What was drawn.** A round platform with six solids (hexagonal column, cube, pyramid, icosahedron, low slab, small monolith), a perspective camera swinging ±24°, and a sun at 31° elevation making one full turn in 14 s. Two framings of the same scene, 420 frames each: landscape rendered at 3840×2160 and portrait at 2160×2700, both downsampled 2×2 in linear light (to 1920×1080 and 1080×1350), with a 4096×4096 shadow map. NVIDIA GeForce RTX 3070, driver 621.01, D3D12 debug layer on. **What goes through the translator.** Three source-built gfx1013 programs, assembled with the LLVM 15 chain used by the binary checks and translated from machine code by `tools/mesh_entry_aot.py` and `tools/pixel_aot.py` at `5bfafce2`. Each binary translates to the same HLSL as its source text, and dxc compiles that HLSL unedited. - Mesh (404 bytes, 78 instructions, the #546 indexed path): camera projection and light-space coordinates from the matrices in b1 and b0. The same program, with the light matrix in b1, draws the shadow map. - Scene pixel (360 bytes, 68 instructions): N·L, `image_sample_c_lz` lowered to `SampleCmpLevelZero` with the bilinear comparison filter, hemisphere ambient and albedo, binary16 export as in #749 and #773. - Light pixel (112 bytes, 25 instructions): the #749 program as adapted in the #773 light pass. **What does not.** The CPU builds the world-space triangles, the per-face constants (normal, colour, plane coefficients) and the camera and light matrices of each frame. The host is my own D3D12 program, with the #773 root signature, no window or swapchain, and readback from GPU memory. It is not the EXE path, and no title code is involved. I did not measure performance. **Checks.** `debug_errors=0 debug_warnings=0` on all 840 frames. In the first frame of each video, the exported mesh positions of both passes match a CPU matrix × vertex product on 6,840 vertices, with a largest error of 3.1e-6 (`|got - want| / max(1, |want|)`). There is no pixel reference: per frame I checked mean luma (34 to 56 of 255 landscape, 41 to 64 portrait) and the mean absolute change between consecutive frames (at most 0.63 of 255 landscape, 0.74 portrait), and I looked at full-size frames of both videos for shadows falling away from the sun. **Three translator limits this ran into** (lines at `5bfafce2`): 1. When the pixel program is translated with a sampler, `v_interp_p1/p2_f32` is accepted only for `attr0.x` and `attr0.y`, at entry or in whole-quad mode ([pixel_aot.py#L3840-L3845](https://github.com/R0Y00/Xbox2Windows/blob/5bfafce2cf75bc246643dbf0fbdacdc9e50226e1/tools/pixel_aot.py#L3840-L3845)), and whole-quad arithmetic on them is limited to `add`, `fma` and `mul_legacy` and must stay affine ([#L4125-L4145](https://github.com/R0Y00/Xbox2Windows/blob/5bfafce2cf75bc246643dbf0fbdacdc9e50226e1/tools/pixel_aot.py#L4125-L4145)). The light-space depth could not be interpolated, so the pixel program evaluates it from each face's plane (`a·u + b·v + c`, coefficients in b0). That is exact only because every face is flat. 2. The number of samples must equal the number of bound textures ([pixel_aot.py#L5622](https://github.com/R0Y00/Xbox2Windows/blob/5bfafce2cf75bc246643dbf0fbdacdc9e50226e1/tools/pixel_aot.py#L5622)), so with one shadow map multi-tap PCF is not possible; the only softening is the 2×2 bilinear comparison. 3. The mesh translation accepts a single three-vertex triangle ([mesh_entry_aot.py#L581-L582](https://github.com/R0Y00/Xbox2Windows/blob/5bfafce2cf75bc246643dbf0fbdacdc9e50226e1/tools/mesh_entry_aot.py#L581-L582)), so each frame is one `DispatchMesh` per triangle: 1,032 in the shadow pass (casters only) and 1,248 in the camera pass. I found no existing issue for these. **Question.** Which would be more useful to you, if either? - (a) A deterministic `mesh_scene_draw_{hardware,warp}` test: a few frames with fixed lights on a small target, point comparison filter, values kept off every boundary as in #773, an independent Python reference and negative controls. - (b) Separate issues for the three limits, one at a time, each with a minimal program the translator refuses today. AI-assisted.
roansystemlabs commented 2026-11-24 18:02:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-24T17:34:56Z.


Following up on limit 3 above, I'm taking it as a focused PR: let tools/mesh_entry_aot.py translate mesh programs that write several vertices and triangles, within the counts declared in PSV0 (up to 256), instead of only (3, 1). Every exported vertex and primitive index must still be covered, and the compute fallback keeps its single-triangle rule with an explicit refusal.

Verification: a source-built gfx1013 mesh program (LLVM 15 chain, as the existing mesh fixtures) drawing a two-triangle quad and a larger strip, compared per pixel against an independent CPU reference on WARP and an RTX 3070 with the debug layer on; negative controls for a swapped index, a missing primitive and a count mismatch. Limits 1 and 2 are not part of this PR (limit 2 is covered by #1702).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139407181 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7139407181). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-24T17:34:56Z. --- Following up on limit 3 above, I'm taking it as a focused PR: let `tools/mesh_entry_aot.py` translate mesh programs that write several vertices and triangles, within the counts declared in PSV0 (up to 256), instead of only `(3, 1)`. Every exported vertex and primitive index must still be covered, and the compute fallback keeps its single-triangle rule with an explicit refusal. Verification: a source-built gfx1013 mesh program (LLVM 15 chain, as the existing mesh fixtures) drawing a two-triangle quad and a larger strip, compared per pixel against an independent CPU reference on WARP and an RTX 3070 with the debug layer on; negative controls for a swapped index, a missing primitive and a count mismatch. Limits 1 and 2 are not part of this PR (limit 2 is covered by #1702). AI-assisted.
roansystemlabs commented 2026-11-24 19:01:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-24T18:42:15Z.


Following up on limit 1 above, I'm taking it as a separate focused PR, independent of #1779 (limit 3): when a pixel program is translated with a sampler, let tools/pixel_aot.py accept v_interp_p1/p2_f32 for attr0.z and attr0.w at entry as plain interpolated values, with a float4 TEXCOORD0 as the no-sampler path already declares. Only attr0.x/y remain sample coordinates. Using z or w as a coordinate, whole-quad arithmetic on them, and attr1+ stay refused. The 16-bit high-word question in #711 is not touched.

Verification: a source-built gfx1013 pixel program (LLVM 15 chain, as the existing pixel_aot fixtures) that samples a texture at attr0.xy and scales the result by attr0.z and attr0.w, with distinct per-vertex z/w values, compared per pixel against an independent CPU reference on WARP and an RTX 3070 with the debug layer on. Negative controls: swapped z/w (predicted first mismatch), z used as a sample coordinate (refused) and attr1 (refused).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141031295 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/730#issuecomment-7141031295). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-24T18:42:15Z. --- Following up on limit 1 above, I'm taking it as a separate focused PR, independent of #1779 (limit 3): when a pixel program is translated with a sampler, let `tools/pixel_aot.py` accept `v_interp_p1/p2_f32` for `attr0.z` and `attr0.w` at entry as plain interpolated values, with a `float4` TEXCOORD0 as the no-sampler path already declares. Only `attr0.x/y` remain sample coordinates. Using z or w as a coordinate, whole-quad arithmetic on them, and attr1+ stay refused. The 16-bit high-word question in #711 is not touched. Verification: a source-built gfx1013 pixel program (LLVM 15 chain, as the existing pixel_aot fixtures) that samples a texture at attr0.xy and scales the result by attr0.z and attr0.w, with distinct per-vertex z/w values, compared per pixel against an independent CPU reference on WARP and an RTX 3070 with the debug layer on. Negative controls: swapped z/w (predicted first mismatch), z used as a sample coordinate (refused) and attr1 (refused). AI-assisted.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#724
No description provided.