Repository navigation
Shaders: cube face and multisampled image loads - #1956
RaghavVijayanand wants to merge 2 commits into
Conversation
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
6e13f29 to
2e7466c
Compare
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.
144 passed / 0 failed / 2 ignored. Cube face and multisampled image loads — texture-dimension coverage for cube/MSAA paths.
|
Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at |
Offline measurement on a retail dumpResult: no count change against I merged head 2e7466c onto No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
GFX10 image loads, stores and atomics with dim CUBE address the cube as the 2D array it is (x, y, face); the translator refused them, accepting cubes only for samples, gathers and size queries. Unordered access (stores, atomics, loads of a UAV) now goes through a 2D array handle: D3D12 has no cube UAVs, so the title's view of a cube for unordered access is a 2D array, faces as slices. A shader view is the title's TextureCube, and DXIL loads no texel of a cube. Annotating the handle as a 2D array does not make the view one: tried, the load read zeros on the default hardware adapter and only face 0 on WARP (the D3D12 debug layer is not installed here to name the mismatch). The view is made before any shader reads it, so victory-gpu cannot choose another for these loads; instead a cube load becomes a point-filtered sampleLevel at the texel's centre on that face, at the load's level, through a clamped point immediate sampler. Shortcuts, noted at `cube_load`: out-of-range texels or levels clamp where the console reads zeros, a face past 5 reads face 0 (cube arrays, as for samples), and integer formats cannot be sampled. New end-to-end tests (emit/image_dim_tests.rs) assemble GFX10 programs, validate the DXIL with dxil.dll and run on the default hardware adapter and WARP: image_load of all 96 texels of a 4x4 cube SRV, image_load_mip of level 1 of a two-level cube (some channels), image_store then image_load through a 6-slice 2D-array UAV, and image_atomic_add with the old value returned on an R32_UINT 2D-array UAV. The host harness gains 2D-array UAVs read back slice by slice (the mip test's cube is main's View::MippedCube). Swapping the face coordinates in `cube_load` fails both SRV tests; leaving the UAV handle a cube fails the store test in validation and the atomic test at pipeline creation. The workspace tests pass (700, 10 ignored) apart from five that fail on main itself here (victory-gpu's dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, victory-shader's two heap-buffer stride tests and gathers_at_a_level_match_the_hardware), as do clippy with and without all features.
GFX10 image_load with dim 2D_MSAA or 2D_MSAA_ARRAY takes x, y (and the slice), then the sample; the translator refused both dimensions. Such loads now go to DXIL's textureLoad on a Texture2DMS or Texture2DMSArray handle, the sample in the operand where a level would be. image_get_resinfo on them gives width, height and layers (the level operand left undefined, as DXIL takes none for multisampled views). Shortcut, noted at the load: the console's last address is a fragment, the sample itself unless the view's FMASK remaps it. Still refused, each with its reason in the code: image_msaa_load (one channel of four samples, four data dwords where the decoder gives one, and which four is not established), stores, atomics and other accesses to multisampled images, unordered multisampled views (writable MSAA UAVs are SM 6.7), and the fourth resinfo channel, where DXIL gives the sample count and the console's value for a multisampled view is not known. The host test harness gains multisampled R32_FLOAT views: as texels cannot be copied into a multisampled texture, each sample of each pixel is drawn as a depth, by a depth-only draw (a hand-built pass-through vertex shader) scissored to the pixel with only that sample in the pipeline's sample mask. New tests in emit/image_dim_tests.rs, validated with dxil.dll and run on the default hardware adapter and WARP: every sample of every pixel of a 4x4 four-sample texture, every slice and sample of a two-slice array, and the sizes of both. With the sample operand replaced by 0 both load tests fail. The workspace tests pass (703, 10 ignored) apart from the five that fail on main itself here (see the cube commit), as do clippy with and without all features.
2e7466c to
8d1bdac
Compare
|
Rebased onto
Each commit builds. On an RTX 5060 Laptop: the cube, multisampled, image store/atomic and |
The translator refused image accesses on cube and MSAA dimensions except for sampling ("an image dimension (cube loads or MSAA)"). Two commits.
Cube (dim 3)
image_get_resinfo: the handle is now a 2D array (kind 7). D3D12 has no cube UAVs, so a UAV over a cube is a 2D-array view with the faces as slices, which matches GFX10's (x, y, face) addressing. Before, resinfo used an invalid cube-UAV kind.sampleLevelat the texel's centre on that face, through a new clamped point immediate sampler.cube_load: out-of-range reads clamp instead of returning zero, cube arrays are not handled, and integer formats can't be sampled.MSAA (dims 6 and 7)
image_loadbecomes textureLoad on Texture2DMS (kind 3) or Texture2DMSArray (kind 8), with the sample index as the sample operand. The console's last address is the fragment index, which equals the sample unless FMASK remaps it; this is noted in the code.image_get_resinforeturns width, height and layers.image_msaa_load, MSAA stores, atomics, sampling andimage_load_mip, and the 4th resinfo channel.Tests: the new
emit/image_dim_tests.rs(7 tests) covers:image_atomic_addon a 2D-array UAVEach program is validated with dxil.dll and run on the default hardware adapter and WARP. Swapping the face coordinates, leaving the UAV handle as a cube, or zeroing the sample operand each makes tests fail. The cube mip test uses main's
View::MippedCube; the test host gains only 2D-array UAVs and the multisampled depth view.Not covered: main's newer descriptor-as-data path (
descriptor_datainlower.rs) still refuses cube and MSAA ("an image dimension (cube or MSAA)"). This PR does not touch it.This PR and #1955 (image stores) both touch
image()inemit/lower.rs, so merging both needs a small manual merge.Rebased onto current main (940d32f). On this machine, 5 tests fail on main itself, with or without this change:
descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views, the twostride_tests::a_heap_buffer_read_*tests, andsynthetic_tests::gathers_at_a_level_match_the_hardware. Everything else passes, and clippy passes with-D warnings, with and without--all-features.