gpu: follow-up to #671/#682 — a lit, shadowed scene through the translated mesh and pixel stages #730
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#730
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@roansystemlabs on GitHub · 2026-11-22 23:25 UTC · original
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_mapand 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:
image_sample_c_lz→SampleCmpLevelZero, which is our open #718 (your review asked for a filter-boundary case; we're working on 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:
SampleCmpLevelZero. Controls: swapped LESS/GREATER comparison and a stale shadow map.X2W_SHIM_DRAW_CASEvalues on thedraw_request/draw_framecontract from #560/#682, with no signature or import-table change, compared across native,pe_mapand AOT, with a stale-input control likechain-stale.#721 remains our priority. We won't start step 1 until you reply here.
Alternatives
Verification
shim_chain_check.py. Every RGBA byte must match. Each negative control must produce a known, nonzero mismatch while the uncovered pixels still match.cpu_shim_chain_hardwarealready does.Questions
AI-assisted: yes
Checklist
pixel_aotand #670 for the SPIR-V bridge. #682 and #705 are merged, and RonLogic/Xbox2Windows#1 changesshim_draw_gpu.cppfor multi-frame draws, not lighting.)@R0Y00 on GitHub · 2026-11-22 23:55 UTC · original
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_frameABI and keep the three-runner output and stale-input checks at that stage. The swapchain can stay outside this work.@roansystemlabs on GitHub · 2026-11-23 00:18 UTC · original
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 on GitHub · 2026-11-23 00:47 UTC · original
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 on GitHub · 2026-11-23 01:23 UTC · original
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 on GitHub · 2026-11-23 02:08 UTC · original
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 on GitHub · 2026-11-23 02:26 UTC · original
#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 on GitHub · 2026-11-23 04:54 UTC · original
@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 on GitHub · 2026-11-23 05:17 UTC · original
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 on GitHub · 2026-11-23 09:12 UTC · original
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 on GitHub · 2026-11-23 09:39 UTC · original
#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_mapand 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 on GitHub · 2026-11-24 12:14 UTC · original
Update, outside the steps above: a larger scene through the same translated stages, rendered locally on
mainat5bfafce2. 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.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.pyandtools/pixel_aot.pyat5bfafce2. Each binary translates to the same HLSL as its source text, and dxc compiles that HLSL unedited.image_sample_c_lzlowered toSampleCmpLevelZerowith the bilinear comparison filter, hemisphere ambient and albedo, binary16 export as in #749 and #773.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=0on 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):v_interp_p1/p2_f32is accepted only forattr0.xandattr0.y, at entry or in whole-quad mode (pixel_aot.py#L3840-L3845), and whole-quad arithmetic on them is limited toadd,fmaandmul_legacyand 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.DispatchMeshper 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?
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.AI-assisted.
@roansystemlabs on GitHub · 2026-11-24 17:34 UTC · original
Following up on limit 3 above, I'm taking it as a focused PR: let
tools/mesh_entry_aot.pytranslate 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 on GitHub · 2026-11-24 18:42 UTC · original
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.pyacceptv_interp_p1/p2_f32forattr0.zandattr0.wat entry as plain interpolated values, with afloat4TEXCOORD0 as the no-sampler path already declares. Onlyattr0.x/yremain 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.