Skip to content

shader, runtime: lower mesh table texture loads and refuse integer views - #3712

Open
lukaslw-lab wants to merge 6 commits into
R0Y00:mainfrom
lukaslw-lab:shader/mesh-table-texture-load
Open

lukaslw-lab wants to merge 6 commits into
R0Y00:mainfrom
lukaslw-lab:shader/mesh-table-texture-load

Conversation

@lukaslw-lab

@lukaslw-lab lukaslw-lab commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Change

The mesh frontend accepted image loads only through the Texture1D heap slot map of #3638. Any other image_load stopped at mesh image load lacks a remapped Texture1D heap contract.

It now also routes an image_load (MIMG opcode 0, no D16) whose eight descriptor words come from a descriptor table to the shared image_io, as the other stages do. That lowering:

  • checks the opcode, the modifiers and that the descriptor words are contiguous and untouched;
  • binds the table record as a texture SRV of the encoded dimension;
  • emits textureLoad.

Under a narrowed EXEC each written channel is a partial write, as buffer loads already are.

Runtime: the lowering declares every table texture with a float result (Texture2D<float4>, textureLoad.f32), but a table record can hold an integer view such as R8G8B8A8_UINT. The slot 86 binder now checks each material-texture record in mesh86_table_texture (native_mesh86.inl) before anything is bound or uploaded. A UINT or SINT view refuses the draw with native Mesh86 material texture has an integer format. The root-SRV path of #3639 is untouched.

This is item 4 of #3703. The 18 captured slot 86 requests behind the scalar loop use only this form: image_load 2D, DMASK 0x2, unorm, through a table record, about four per program. On main 158ef794 with #3707 (802f682d) and this PR (9781e798), all 18 translate. Each binds a 2D table texture, four table buffers, root constants, and the 128-byte root SRV of root parameter 3. So at draw time they wait on #3639. Refs #3703, #3641, #3639.

Verification

Build release at 9781e798 (Windows 10 19045, MSVC 2022, DXC 1.9.2609):

python -B tests/native_direct_mesh_check.py <compile_dxil.exe> <dxc dir>  -> passed
python -B tests/docs_links_check.py                                       -> passed
ctest --test-dir out/build/release -R "^(startup_mesh86_|startup_indirect_mesh|startup_indirect_draw|startup_indirect_translated|native_direct|native_fixed_mesh|mesh_)"
  -> 183 tests: 103 passed, 62 capability skips (77), 18 failed

All 18 failures are _hardware tests on this host (Windows 10 without the Agility SDK; NVIDIA RTX 3080 Ti, driver 32.0.16.1047, debug layer on). 14 are on this host's known-failure list. The other 4 (startup_indirect_mesh_cache_texture_map, _heap_wide, native_fixed_mesh57_published_pair, _refusal) stop at serialize root failed (HRESULT 0x80070057) before any binding code runs, and their WARP twins are capability skips. startup_mesh86_table_texture_probe_warp and _hardware, native_direct_mesh and native_direct_container pass.

New cases in native_direct_mesh_check.py, next to root-branch. Each runs s_load_dwordx8 from table 1, then image_load v1, v[1:2], s[24:31] dmask:0x2 dim:2D unorm:

  • table-texture-load and -xy (DMASK 0x3) check the Texture2D handle and the two-coordinate textureLoad.
  • table-texture-load-skip runs the same load into v3 under v_cmpx and an EXECZ skip.
  • table-texture-load-skip-read-after sets v3 to 0 for every lane before the skip; reading it after full EXEC returns is refused (graphics register undefined on an incoming path: 259).
  • -d16 and -overwritten keep unsupported image dimension or D16 and non-contiguous resource descriptor.

startup_mesh86_table_texture_probe_{warp,hardware} (new, binder side) creates one R8G8B8A8_TYPELESS 2D texture through the guest API. It writes guest SRVs of it into a guest heap and runs each 32-byte record through mesh86_table_texture, using the fixture export x2w_mesh86_table_texture_probe, the same pattern as the committed-root probe of #3718:

  • R8G8B8A8_UNORM 2D: bound;
  • R8G8B8A8_UINT 2D and R8G8B8A8_SINT 2D: refused, integer format;
  • R8G8B8A8_UNORM 2D array: refused, does not resolve to the expected SRV;
  • all-zero record: bound as a typed null.

It checks the binding decision only and submits no draw.

Controls:

  • Without the integer-format check, the probe binds the UINT record and fails (exit 3).
  • Without the frontend change, table-texture-load fails with unsupported mesh instruction or EXEC state: image_load.
  • Without the partial-write marking, table-texture-load-skip-read-after compiles, so its expected refusal is missing.

Evidence and follow-up

Source-built words only. The 18-request counts are local and offline (compile_dxil ... gfx1013-container-ms-texture-heap); the outputs are valid DXIL mesh shaders (dxc -dumpbin). Note: docs/experiments/native-mesh-table-texture-load.md.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

🤖 Generated with Claude Code

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new 2D table-load path emits a Texture2D declaration and textureLoad.f32. An otherwise valid mesh table entry can carry DXGI_FORMAT_R8G8B8A8_UINT. mesh86_texture preserves that format, and mesh86_realize_texture checks the dimension, mip range and component mapping without checking the numeric type. The runtime can therefore create an integer SRV in the shader-visible heap for a shader that expects a float result.

Please reject incompatible integer views before issuing the draw, or select a shader variant whose result type matches the bound view. Cover the same guest mesh shader with R8G8B8A8_UNORM and R8G8B8A8_UINT in a binding test. The added DXIL fixture verifies the float declaration but does not bind either view.

lukaslw-lab and others added 2 commits December 1, 2026 20:12
The mesh frontend accepted image loads only through the Texture1D heap
slot map. Route an image_load (opcode 0, no D16) whose eight descriptor
words come from a descriptor table to the shared image_io, as the other
stages do: it checks the opcode, modifiers and descriptor words, binds
the table record as a texture SRV of the encoded dimension and emits
textureLoad. The slot 86 runtime already resolves such a view from the
table record. Under a narrowed EXEC each written channel is a partial
write, as for buffer loads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mesh frontend lowers a 2D table load to Texture2D<float4> and
textureLoad.f32, but a table record can hold an integer view such as
R8G8B8A8_UINT. Check each material texture record in mesh86_table_texture
before anything is bound or uploaded, and refuse UINT and SINT views.

startup_mesh86_table_texture_probe runs guest UNORM, UINT, SINT, 2D-array
and empty records of one typeless texture through the same check via a
fixture export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukaslw-lab
lukaslw-lab force-pushed the shader/mesh-table-texture-load branch from ba82316 to 9781e79 Compare December 1, 2026 19:42
@lukaslw-lab lukaslw-lab changed the title shader: lower table texture loads in the mesh frontend shader, runtime: lower mesh table texture loads and refuse integer views Dec 1, 2026
@lukaslw-lab

Copy link
Copy Markdown
Contributor Author

Thanks, that was a real gap. Fixed in 9781e798, with the branch rebased on main 158ef794. I took the first option you suggested: incompatible integer views are rejected before the draw.

Binder. The slot 86 material-texture branch now checks each table record in one function, mesh86_table_texture, before anything is bound or uploaded. The lowering declares every table texture with a float result, so a UINT or SINT view refuses the draw with native Mesh86 material texture has an integer format. UNORM, other float formats and the all-zero typed null bind as before.

Binding test. startup_mesh86_table_texture_probe_{warp,hardware} creates one R8G8B8A8_TYPELESS 2D texture through the guest API. It writes guest SRVs of that texture into a guest heap, then runs each 32-byte record through the binder's check. The check is reached through the fixture export x2w_mesh86_table_texture_probe, the same pattern as the committed-root probe of #3718.

Record Result
R8G8B8A8_UNORM, Texture2D bound
R8G8B8A8_UINT, Texture2D refused: integer format
R8G8B8A8_SINT, Texture2D refused: integer format
R8G8B8A8_UNORM, Texture2DArray refused: does not resolve to the expected SRV
all zero bound (typed null)

Control: without the integer check, the UINT row is bound and the test fails.

The test checks the binding decision, not a submitted DispatchMesh. No test drives the native slot 86 binder through a real draw yet: the existing Mesh86 draw fixtures go through the published-cache path. If you want the full draw, I can add it as a follow-up.

The pre-existing Texture1D heap map (plan.mesh / plan.pixel_heap in bind_native_mesh86) also feeds textureLoad.f32 from guest records without a numeric-type check. I left it alone to keep this PR to the table path, but mesh86_table_texture's format check could be reused there. Your call.

Local, Windows Release, 9781e798:

  • startup_mesh86_table_texture_probe_warp and _hardware: pass.
  • native_direct_mesh and native_direct_container: pass.
  • The wider startup_mesh86_|startup_indirect_mesh|startup_indirect_draw|native_direct|native_fixed_mesh|mesh_ set: 4 new failures, all _hardware tests that stop at serialize root failed on this host without the Agility SDK. Their WARP twins are capability skips.

cc mumba17: #3770 adds a branch right after this one in the same binder loop. git merge-tree merges the two cleanly.

@lukaslw-lab
lukaslw-lab requested a review from Leyukaka December 1, 2026 19:42

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

The new UINT/SINT controls cover color SRVs. integer_uav_format() omits the stencil SRV formats DXGI_FORMAT_X24_TYPELESS_G8_UINT and DXGI_FORMAT_X32_TYPELESS_G8X24_UINT. mesh86_realize_texture() explicitly accepts their stencil plane when the SRV and resource are compatible, so this float-result table path can still bind an integer stencil SRV. Please reject these SRV formats too and add a stencil-plane negative control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukaslw-lab

Copy link
Copy Markdown
Contributor Author

Thanks. Fixed in f8bc2888: mesh86_table_texture now also refuses DXGI_FORMAT_X24_TYPELESS_G8_UINT and DXGI_FORMAT_X32_TYPELESS_G8X24_UINT, with the same "integer format" refusal. The check stays local to the Mesh86 table path, and the shared integer_uav_format() is unchanged.

startup_mesh86_table_texture_probe gains three records on depth-stencil textures:

Record Expected WARP and hardware
D24S8 stencil plane (X24_TYPELESS_G8_UINT, plane 1) refused refused
D32S8 stencil plane (X32_TYPELESS_G8X24_UINT, plane 1) refused refused
D24S8 depth plane (R24_UNORM_X8_TYPELESS, plane 0) bound bound

Verification, release build, Windows 10 19045, RTX 3080 Ti (driver 32.0.16.1047, debug layer):

  • ctest --preset release -R 'mesh86_table_texture_probe|native_direct_mesh$': startup_mesh86_table_texture_probe_{warp,hardware} and native_direct_mesh pass.
  • With the new check removed, the D24S8 stencil record is bound and the probe fails.
  • Not caused by this change: startup_mesh86_indexed_raw_hardware (runtime: bind indexed_raw_srv table buffers in native Mesh86 (Part of #3703) #3807) fails here with serialize root failed (HRESULT 0x80070057), and fails the same way on main without this PR.

AI-assisted.

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 1620be9d (fixes in 9781e798 and f8bc2888, then a merge of main). Read the diff and the CI log; not built or run.

The finding from my earlier review is addressed. mesh86_table_texture (src/startup_stubs/native_mesh86.inl) now checks each table record before anything is bound. integer_uav_format() covers the UINT/SINT color formats, and the two stencil SRV formats from the follow-up (X24_TYPELESS_G8_UINT, X32_TYPELESS_G8X24_UINT) are refused in the same place, while the depth plane still binds. startup_mesh86_table_texture_probe_{warp,hardware} exercises the same function with UNORM, UINT, SINT, wrong-dimension, both stencil-plane, D24 depth-plane and all-zero records. I agree that a full DispatchMesh through the native binder can be a follow-up.

About the failing Build and test on Windows check on 1620be9d: the only failure (1 of 273) is startup_indirect_mesh_cache_heap_wide_warp. It stops at tests/startup_indirect_mesh_cache_check.py:205, where marker, = work.glob('req_*.m86') finds no file. This PR does not modify that test. Its source part is a placeholder envelope with no shader code, so the new lower_mesh image branch is not reached, and the log shows the draw refused at mesh_profile_missing before any binding, so mesh86_table_texture is not reached either. The same test passed on f8bc2888, and it passes on #3707 and #3825, which include a newer main. I don't think the failure comes from this change. Could the job be rerun so the required check covers the current head?

Optional and not blocking: as you noted, the Texture1D heap-map path in bind_native_mesh86 could reuse the same format check. A linked issue would keep track of it.

Approving 1620be9d; the rerun still has to pass before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants