From 3deb60c13bc091f2b8361301e95f173ab4473b7c Mon Sep 17 00:00:00 2001 From: lukaslw-lab <291379150+lukaslw-lab@users.noreply.github.com> Date: Tue, 1 Dec 2026 08:52:59 +0100 Subject: [PATCH 1/4] shader: lower table texture loads in the mesh frontend 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 --- .../native-mesh-table-texture-load.md | 42 +++++++++++++++++++ src/gfx1013_direct_mesh.inl | 8 ++++ tests/native_direct_mesh_check.py | 25 +++++++++++ 3 files changed, 75 insertions(+) create mode 100644 docs/experiments/native-mesh-table-texture-load.md diff --git a/docs/experiments/native-mesh-table-texture-load.md b/docs/experiments/native-mesh-table-texture-load.md new file mode 100644 index 0000000000..ca8d0c783b --- /dev/null +++ b/docs/experiments/native-mesh-table-texture-load.md @@ -0,0 +1,42 @@ +# Texture loads through a descriptor table in the mesh frontend + +The C++ mesh frontend (`lower_mesh`) accepted image loads only through the Texture1D heap slot map (#3638). Any other +`image_load` stopped with `mesh image load lacks a remapped Texture1D heap contract`, or, without the slot map, with +`unsupported mesh instruction or EXEC state: image_load`. + +It now also accepts an `image_load` (MIMG opcode 0, without D16) whose eight descriptor words were loaded from a +descriptor table. Like every other stage, it goes to the shared `image_io`, which: + +- checks the opcode, the modifiers and that the eight descriptor words are contiguous and untouched; +- binds the table record as a texture SRV of the encoded dimension; +- emits `textureLoad`. + +The slot 86 runtime already resolves such a texture SRV from the table record (`native_mesh86.inl`, 1D, 2D and 2D +array). Under a narrowed EXEC each written channel is marked as a partial write, as buffer loads already are. + +## Checks + +`tests/native_direct_mesh_check.py`, next to `root-branch`: `s_load_dwordx8` reads a descriptor from table 1, then +`image_load v1, v[1:2], s[24:31] dmask:0x2 dim:2D unorm` reads one channel. + +- `table-texture-load` and `-xy` (DMASK 0x3): a `Texture2D` handle and a two-coordinate `textureLoad`. +- `table-texture-load-skip`: the same load into v3 under `v_cmpx` and an EXECZ skip. +- `table-texture-load-skip-read-after`: v3 is 0 for every lane before the skip. Reading it after full EXEC returns is + refused (`graphics register undefined on an incoming path: 259`), because only some lanes overwrote it. +- `table-texture-load-d16` and `-overwritten` keep `unsupported image dimension or D16` and + `non-contiguous resource descriptor`. + +Controls: + +- 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. + +## Local requests + +The 18 captured slot 86 requests behind the scalar loop of #3703 use only this form: `image_load` 2D, DMASK 0x2, +unorm, through a table record, about four per program. With #3702, #3704 and #3707 applied, all 18 now translate. +Each binds a 2D table texture, four table buffers, root constants, and the 128-byte root SRV of root parameter 3 +(#3639). These are counts only, from `compile_dxil gfx1013-container-ms-texture-heap .m86 +.cso`. diff --git a/src/gfx1013_direct_mesh.inl b/src/gfx1013_direct_mesh.inl index 575612d031..91558ef8c2 100644 --- a/src/gfx1013_direct_mesh.inl +++ b/src/gfx1013_direct_mesh.inl @@ -1521,6 +1521,14 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout if (full_exec) uniform_values.insert(word); else if (whole_wave_execution() && !branch) active_uniform[word]={lane_active,word}; } + } else if (i.enc==Encoding::Image && i.op==0 && !(i.b>>31) && (full_exec || exec_skip) && + ((i.b>>16)&31)*4+8<=106 && state[((i.b>>16)&31)*4].type==Symbol::Type::descriptor) { + // A load through a descriptor-table texture (#3703): the shared lowering checks the opcode and the + // eight descriptor words and binds the table record as a texture SRV of the encoded dimension, which + // the slot 86 runtime resolves from the table. It writes one VGPR per DMASK channel. + alu.image_io(i,state); + if (!full_exec) + for (unsigned mask=(i.a>>8)&15, j=0; mask; mask&=mask-1, ++j) partial_writes.insert(256+i.dst+j); } else if (i.enc==Encoding::Image && i.op==0 && layout.texture_heap_slot_map && (full_exec || exec_skip)) { const auto base=((i.b>>16)&31)*4; diff --git a/tests/native_direct_mesh_check.py b/tests/native_direct_mesh_check.py index 7fa7767e90..26a1306483 100644 --- a/tests/native_direct_mesh_check.py +++ b/tests/native_direct_mesh_check.py @@ -599,6 +599,31 @@ def run(name, words, expected=None): for marker in ('cbufferLoadLegacy','rawBufferLoad','phi i32','storeVertexOutput'): assert marker in text, marker + # A load through a descriptor-table texture (#3703): s_load_dwordx8 s[24:31], s[16:17], 0 reads the eight + # descriptor words; image_load v1, v[1:2], s[24:31] dmask:0x2 dim:2D unorm reads one channel at (v1, v2). + texture_load = [0xbe910380, 0xf40c0608, 0xfa000000, 0xbf8cc07f] # s_mov_b32 s17, 0; load; s_waitcnt + def table_texture(image=(0xf0001208, 0x00060101), extra=(), skip=False, after=()): + body = [*extra, *image] + if skip: # v3 = 0 for every lane; then under v_cmpx_eq_u32 1, v0 and an EXECZ skip; then full EXEC + body = [0x7e060280, 0x7da40081, 0xbf880000 | len(body), *body, 0xbefe04c1, *after] + return texture_load + program[:7] + body + program[7:] + texture_2d = r'%dx\.types\.ResourceProperties \{ i32 2, i32 1033 \}' # Texture2D<4 x f32> + texture_read = r'@dx\.op\.textureLoad\.f32\(i32 66, %dx\.types\.Handle %[\w.]+, i32 0, i32 %[\w.]+, i32 %[\w.]+, i32 undef' + skip_into_v3 = (0xf0001208, 0x00060301) # the same load into v3 + for name, words_in in (('table-texture-load', table_texture()), + ('table-texture-load-xy', table_texture(image=(0xf0001308, 0x00060101))), + ('table-texture-load-skip', table_texture(image=skip_into_v3, skip=True))): + text = run(name, words_in) + assert re.search(texture_2d, text) and re.search(texture_read, text), text + # Under the skip only some lanes overwrite v3, so its value once full EXEC returns is not one value for + # every lane and reading it is refused (without marking the load's write as partial, it would be accepted). + run('table-texture-load-skip-read-after', + table_texture(image=skip_into_v3, skip=True, after=[0x7e020303]), # v_mov_b32 v1, v3 + 'graphics register undefined on an incoming path: 259') + run('table-texture-load-d16', table_texture(image=(0xf0001208, 0x80060101)), 'unsupported image dimension or D16') + run('table-texture-load-overwritten', table_texture(extra=[0xbe990380]), # s_mov_b32 s25, 0 + 'non-contiguous resource descriptor') + # s20 = root0[0]; v_cmp_gt_u32_e64 vcc, s20, 6. copy_root = [0xbe940315] compare_root = [0xd4c4006a, 0x00010c14] From 9781e79831cf1f73c9b6dd3674ee2ff171801fd8 Mon Sep 17 00:00:00 2001 From: lukaslw-lab <291379150+lukaslw-lab@users.noreply.github.com> Date: Tue, 1 Dec 2026 20:29:04 +0100 Subject: [PATCH 2/4] runtime: refuse integer views for slot 86 table textures The mesh frontend lowers a 2D table load to Texture2D 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 --- CMakeLists.txt | 3 + .../native-mesh-table-texture-load.md | 24 +++++++- src/startup_stubs/d3d12_xs_device.cpp | 17 ++++++ src/startup_stubs/native_mesh86.inl | 24 ++++++-- tests/startup_indirect_draw_indexed.cpp | 56 ++++++++++++++++++- 5 files changed, 118 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5b4d5e5d5..34e1a0193a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1972,6 +1972,9 @@ if(EXISTS "${INTAKE_PYTHON}") add_test(NAME startup_mesh86_committed_root_probe_${backend} COMMAND "$" ${backend} mesh86-committed-root-probe) set_tests_properties(startup_mesh86_committed_root_probe_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77) + add_test(NAME startup_mesh86_table_texture_probe_${backend} COMMAND "$" + ${backend} mesh86-table-texture-probe) + set_tests_properties(startup_mesh86_table_texture_probe_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77) foreach(mode IN ITEMS ordered_control skip-wait dual dual-skip-srv dual-skip-argument dual-init-only loose-root) set(test_name startup_indirect_mesh_lease_${backend}_${mode}) add_test(NAME ${test_name} COMMAND "${INTAKE_PYTHON}" -B diff --git a/docs/experiments/native-mesh-table-texture-load.md b/docs/experiments/native-mesh-table-texture-load.md index ca8d0c783b..1426b87055 100644 --- a/docs/experiments/native-mesh-table-texture-load.md +++ b/docs/experiments/native-mesh-table-texture-load.md @@ -14,6 +14,11 @@ descriptor table. Like every other stage, it goes to the shared `image_io`, whic The slot 86 runtime already resolves such a texture SRV from the table record (`native_mesh86.inl`, 1D, 2D and 2D array). Under a narrowed EXEC each written channel is marked as a partial write, as buffer loads already are. +The lowering declares the texture with a float result (`Texture2D`, `textureLoad.f32`), but a table record can +hold an integer view, for example `R8G8B8A8_UINT`. The slot 86 binder therefore checks each material texture record +in `mesh86_table_texture` before it binds or uploads anything. A UINT or SINT view refuses the draw with `native +Mesh86 material texture has an integer format`. An all-zero record still binds a typed null. + ## Checks `tests/native_direct_mesh_check.py`, next to `root-branch`: `s_load_dwordx8` reads a descriptor from table 1, then @@ -26,17 +31,34 @@ array). Under a narrowed EXEC each written channel is marked as a partial write, - `table-texture-load-d16` and `-overwritten` keep `unsupported image dimension or D16` and `non-contiguous resource descriptor`. +`startup_mesh86_table_texture_probe_{warp,hardware}` checks the binder side. It creates one `R8G8B8A8_TYPELESS` 2D +texture through the guest API and writes guest SRVs of it into a guest heap. It then runs each 32-byte record through +the binder's check, using the fixture export `x2w_mesh86_table_texture_probe`, which is the same function the binder +calls: + +| 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) | + +It checks the binding decision only, and submits no draw. + Controls: - 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. +- Without the integer-format check, the probe binds the UINT record and fails. ## Local requests The 18 captured slot 86 requests behind the scalar loop of #3703 use only this form: `image_load` 2D, DMASK 0x2, -unorm, through a table record, about four per program. With #3702, #3704 and #3707 applied, all 18 now translate. +unorm, through a table record, about four per program. With #3707 applied on top of `main` (which has #3702 and #3704), all +18 now translate. Each binds a 2D table texture, four table buffers, root constants, and the 128-byte root SRV of root parameter 3 (#3639). These are counts only, from `compile_dxil gfx1013-container-ms-texture-heap .m86 .cso`. diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index 0a3ddf5832..53e5f81a76 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -5637,6 +5637,23 @@ extern "C" __declspec(dllexport) int x2w_mesh86_committed_root_probe(void* list, return 1; } +#ifdef X2W_NATIVE_SHADERS +// Fixture export (startup_indirect_draw_indexed mesh86-table-texture-probe): run the slot 86 binder's check of one +// 32-byte material texture table record for a 2D table load. Returns 1 when the record would be bound, 0 when the +// draw would be refused; *reason then holds the binder's refusal. +extern "C" __declspec(dllexport) int x2w_mesh86_table_texture_probe(const unsigned* words, const char** reason) +{ + if (reason) *reason = nullptr; + if (!words) return 0; + UINT record[8]; + std::memcpy(record, words, sizeof(record)); + Mesh86Texture texture; + const char* refusal = mesh86_table_texture(record, D3D12_SRV_DIMENSION_TEXTURE2D, false, texture); + if (reason) *reason = refusal; + return refusal ? 0 : 1; +} +#endif + #ifdef X2W_NATIVE_SHADERS // Xbox list slot 129 (vtable offset 0x408): DispatchMesh(x, y, z). void __stdcall list_dispatch_mesh(Wrapper* self, UINT x, UINT y, UINT z) diff --git a/src/startup_stubs/native_mesh86.inl b/src/startup_stubs/native_mesh86.inl index c699f03321..bbdb1fb12d 100644 --- a/src/startup_stubs/native_mesh86.inl +++ b/src/startup_stubs/native_mesh86.inl @@ -284,6 +284,22 @@ D3D12_SHADER_RESOURCE_VIEW_DESC mesh86_null_texture(D3D12_SRV_DIMENSION dimensio return view; } +// The 32-byte table record of one material texture, checked before anything is bound or uploaded. An all-zero +// record is a typed null. The frontend declares every table texture with a float result (Texture2D with +// textureLoad.f32 or a sample), so an integer view would bind an SRV the shader cannot read. +const char* mesh86_table_texture(const UINT (&words)[8], D3D12_SRV_DIMENSION dimension, bool compare, + Mesh86Texture& texture) +{ + if (std::all_of(std::begin(words), std::end(words), [](UINT word) { return !word; })) { + texture.view = mesh86_null_texture(dimension, compare); + return nullptr; + } + if (!mesh86_texture(words, texture) || texture.view.ViewDimension != dimension) + return "native Mesh86 material texture does not resolve to the expected SRV"; + if (integer_uav_format(texture.view.Format)) return "native Mesh86 material texture has an integer format"; + return nullptr; +} + x2w_upload::Allocation mesh86_upload(Wrapper* list, UINT64 bytes) { auto* data = list_allocate_upload(list, bytes, D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT); @@ -414,10 +430,10 @@ const char* bind_native_mesh86(Wrapper* self, Pass& pass, ID3D12GraphicsCommandL Mesh86Texture texture; const auto dim = source.image_dimension == 0 ? D3D12_SRV_DIMENSION_TEXTURE1D : source.image_dimension == 1 ? D3D12_SRV_DIMENSION_TEXTURE2D : D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - if (std::all_of(std::begin(words), std::end(words), [](UINT word) { return !word; })) - texture.view = mesh86_null_texture(dim, source.kind == Kind::comparison_texture_srv); - else if (!mesh86_texture(words, texture) || texture.view.ViewDimension != dim || !image(texture)) - return "native Mesh86 material texture does not resolve to the expected SRV"; + if (const char* reason = mesh86_table_texture(words, dim, source.kind == Kind::comparison_texture_srv, + texture)) + return reason; + if (!image(texture)) return "native Mesh86 material texture does not resolve to the expected SRV"; descriptors[slot] = {texture.resource, texture.view}; } else { const char* reason = nullptr; diff --git a/tests/startup_indirect_draw_indexed.cpp b/tests/startup_indirect_draw_indexed.cpp index 02b7c56c32..5f389bcefc 100644 --- a/tests/startup_indirect_draw_indexed.cpp +++ b/tests/startup_indirect_draw_indexed.cpp @@ -3068,6 +3068,7 @@ int main(int argc, char** argv) try DrawKind kind = DrawKind::indexed; const bool lease_writer = argc == 3 && std::strcmp(argv[2], "mesh-lease-writer") == 0; const bool committed_root_probe = argc == 3 && std::strcmp(argv[2], "mesh86-committed-root-probe") == 0; + const bool table_texture_probe = argc == 3 && std::strcmp(argv[2], "mesh86-table-texture-probe") == 0; const bool skip_argument_wait = argc == 3 && std::strcmp(argv[2], "mesh-xmem-arguments-skip-wait") == 0; const bool lease_arguments = skip_argument_wait || (argc == 3 && std::strcmp(argv[2], "mesh-xmem-arguments") == 0); if (lease_arguments) { @@ -3130,7 +3131,7 @@ int main(int argc, char** argv) try kind = DrawKind::mesh; else if (rect) kind = DrawKind::indexed_rect; else if (argc != 2 && !count_control && !translated_indexed && !lease_writer && !bucket_case && !stream_key_case && - !committed_root_probe) + !committed_root_probe && !table_texture_probe) return 2; const bool indexed = kind == DrawKind::indexed || kind == DrawKind::indexed_rect; const bool mesh = kind == DrawKind::mesh; @@ -3193,6 +3194,59 @@ int main(int argc, char** argv) try if (bucket_case) return run_bucket_refusal_case(device.Get(), guest.Get(), bucket_name, bucket_control); if (stream_key_case) return run_mesh57_stream_key(device.Get(), guest.Get()); if (fixed_create_fixture) return fixed_mesh_create_contract(guest.Get()) ? 0 : 1; + if (table_texture_probe) { + // A 2D table load in a guest mesh shader lowers to Texture2D and textureLoad.f32 (#3712). The + // same table slot may hold a float or an integer view of one typeless texture; the slot 86 binder must + // bind the UNORM record and refuse the UINT and SINT records before the draw. + using Probe = int (WINAPI*)(const unsigned*, const char**); + const auto probe = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"d3d12_xs.dll"), + "x2w_mesh86_table_texture_probe")); + if (!probe) { + std::puts("mesh86 table texture probe capability skip: built without X2W_NATIVE_SHADERS"); + return 77; + } + using Create = HRESULT (WINAPI*)(IUnknown*, const D3D12_HEAP_PROPERTIES*, UINT, const D3D12_RESOURCE_DESC*, + UINT, const void*, void*, UINT, const void*, REFIID, void**); + using View = void (WINAPI*)(IUnknown*, IUnknown*, const D3D12_SHADER_RESOURCE_VIEW_DESC*, UINT64); + using Handle = UINT64 (WINAPI*)(IUnknown*); + const D3D12_HEAP_PROPERTIES props{D3D12_HEAP_TYPE_DEFAULT}; + const D3D12_RESOURCE_DESC desc{D3D12_RESOURCE_DIMENSION_TEXTURE2D, 0, 2, 2, 1, 1, DXGI_FORMAT_R8G8B8A8_TYPELESS, + {1, 0}, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_NONE}; + ComPtr texture; + check(slot(guest.Get(), 127)(guest.Get(), &props, 0, &desc, D3D12_RESOURCE_STATE_COMMON, nullptr, nullptr, + 0, nullptr, IID_PPV_ARGS(&texture)), "create typeless table texture"); + // Guest views written into a guest heap hold the 32-byte table records the title copies into its tables. + const UINT step = guest->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + check(step >= 32 ? S_OK : E_FAIL, "guest descriptor step holds a 32-byte record"); + const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 4, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE}; + ComPtr heap; + check(guest->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap)), "create guest table heap"); + const UINT64 base = slot(heap.Get(), 9)(heap.Get()); + const auto record = [&](UINT index, DXGI_FORMAT format, D3D12_SRV_DIMENSION dimension) { + D3D12_SHADER_RESOURCE_VIEW_DESC view{format, dimension, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING}; + view.Texture2D.MipLevels = 1; + if (dimension == D3D12_SRV_DIMENSION_TEXTURE2DARRAY) view.Texture2DArray.ArraySize = 1; + slot(guest.Get(), 18)(guest.Get(), texture.Get(), &view, base + index * step); + return reinterpret_cast(base + index * step); + }; + const auto expect = [&](const unsigned* words, int bound, const char* reason, const char* label) { + const char* why = nullptr; + const int result = probe(words, &why); + const bool ok = result == bound && (reason ? why && std::strcmp(why, reason) == 0 : !why); + std::printf("%s: %s (%s)\n", label, result ? "bound" : "refused", why ? why : "no refusal"); + check(ok ? S_OK : E_FAIL, label); + }; + const unsigned none[8]{}; + constexpr auto integer = "native Mesh86 material texture has an integer format"; + expect(record(0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_SRV_DIMENSION_TEXTURE2D), 1, nullptr, "UNORM view is bound"); + expect(record(1, DXGI_FORMAT_R8G8B8A8_UINT, D3D12_SRV_DIMENSION_TEXTURE2D), 0, integer, "UINT view is refused"); + expect(record(2, DXGI_FORMAT_R8G8B8A8_SINT, D3D12_SRV_DIMENSION_TEXTURE2D), 0, integer, "SINT view is refused"); + expect(record(3, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_SRV_DIMENSION_TEXTURE2DARRAY), 0, + "native Mesh86 material texture does not resolve to the expected SRV", "2D array view is refused"); + expect(none, 1, nullptr, "empty record binds a typed null"); + return 0; + } if (committed_root_probe) { ComPtr allocator; check(guest->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator)), From a7fe90dec405a64614960f1325fcbc2af784b5ad Mon Sep 17 00:00:00 2001 From: lukaslw-lab <291379150+lukaslw-lab@users.noreply.github.com> Date: Wed, 2 Dec 2026 03:21:16 +0100 Subject: [PATCH 3/4] tests: count the mesh86 table texture probe export in standin_exports_check Co-Authored-By: Claude Opus 5.5 --- tests/standin_exports_check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/standin_exports_check.py b/tests/standin_exports_check.py index 2d8c733941..3ddf03ccab 100644 --- a/tests/standin_exports_check.py +++ b/tests/standin_exports_check.py @@ -116,7 +116,7 @@ def test_real_catalogs(): expected = set(modules[:8]) | {"xgameruntime.dll"} check(set(catalogs) == expected, f"load_catalogs keys {sorted(catalogs)} != {sorted(expected)}") - counts = {"xmem": 54, "d3d12_xs": 79, "acphal": 10, "chad": 5, + counts = {"xmem": 54, "d3d12_xs": 80, "acphal": 10, "chad": 5, "xapu": 6, "xcrdapi": 3, "xg_xs": 2, "gameinput": 2} for stem, path in DEFAULT_DEFS.items(): catalog = catalogs[stem + ".dll"] @@ -155,7 +155,7 @@ def test_real_catalogs(): == Counter({"trap": 9, "implemented": 1}), "acphal status counts differ") check(Counter(e.status for e in catalogs["d3d12_xs.dll"].entries.values()) - == Counter({"implemented": 35, "unmeasured": 44}), + == Counter({"implemented": 35, "unmeasured": 45}), "d3d12_xs status counts differ") check(Counter(e.status for e in catalogs["xgameruntime.dll"].entries.values()) == Counter({"implemented": 38}), From f8bc2888e68af7b5269f05dd0b898945b1207265 Mon Sep 17 00:00:00 2001 From: lukaslw-lab <291379150+lukaslw-lab@users.noreply.github.com> Date: Wed, 2 Dec 2026 04:02:25 +0100 Subject: [PATCH 4/4] runtime: refuse stencil-plane views for Mesh86 table textures Co-Authored-By: Claude Opus 5.5 --- src/startup_stubs/native_mesh86.inl | 6 +++++- tests/startup_indirect_draw_indexed.cpp | 27 +++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/startup_stubs/native_mesh86.inl b/src/startup_stubs/native_mesh86.inl index b0bd9dda35..41882a8256 100644 --- a/src/startup_stubs/native_mesh86.inl +++ b/src/startup_stubs/native_mesh86.inl @@ -301,7 +301,11 @@ const char* mesh86_table_texture(const UINT (&words)[8], D3D12_SRV_DIMENSION dim } if (!mesh86_texture(words, texture) || texture.view.ViewDimension != dimension) return "native Mesh86 material texture does not resolve to the expected SRV"; - if (integer_uav_format(texture.view.Format)) return "native Mesh86 material texture has an integer format"; + // The stencil plane of a depth-stencil texture is an integer view too. + const auto format = texture.view.Format; + if (integer_uav_format(format) || format == DXGI_FORMAT_X24_TYPELESS_G8_UINT || + format == DXGI_FORMAT_X32_TYPELESS_G8X24_UINT) + return "native Mesh86 material texture has an integer format"; return nullptr; } diff --git a/tests/startup_indirect_draw_indexed.cpp b/tests/startup_indirect_draw_indexed.cpp index 884e736fbe..89953cb8c2 100644 --- a/tests/startup_indirect_draw_indexed.cpp +++ b/tests/startup_indirect_draw_indexed.cpp @@ -3265,7 +3265,8 @@ int main(int argc, char** argv) try if (table_texture_probe) { // A 2D table load in a guest mesh shader lowers to Texture2D and textureLoad.f32 (#3712). The // same table slot may hold a float or an integer view of one typeless texture; the slot 86 binder must - // bind the UNORM record and refuse the UINT and SINT records before the draw. + // bind the UNORM record and refuse the UINT and SINT records before the draw. The stencil plane of a + // depth-stencil texture is an integer view as well; its depth plane is a float view. using Probe = int (WINAPI*)(const unsigned*, const char**); const auto probe = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"d3d12_xs.dll"), "x2w_mesh86_table_texture_probe")); @@ -3283,19 +3284,31 @@ int main(int argc, char** argv) try ComPtr texture; check(slot(guest.Get(), 127)(guest.Get(), &props, 0, &desc, D3D12_RESOURCE_STATE_COMMON, nullptr, nullptr, 0, nullptr, IID_PPV_ARGS(&texture)), "create typeless table texture"); + const auto depth_texture = [&](DXGI_FORMAT format, const char* label) { + const D3D12_RESOURCE_DESC stencil_desc{D3D12_RESOURCE_DIMENSION_TEXTURE2D, 0, 2, 2, 1, 1, format, {1, 0}, + D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL}; + ComPtr resource; + check(slot(guest.Get(), 127)(guest.Get(), &props, 0, &stencil_desc, D3D12_RESOURCE_STATE_COMMON, + nullptr, nullptr, 0, nullptr, IID_PPV_ARGS(&resource)), label); + return resource; + }; + const auto depth24 = depth_texture(DXGI_FORMAT_R24G8_TYPELESS, "create D24S8 table texture"); + const auto depth32 = depth_texture(DXGI_FORMAT_R32G8X24_TYPELESS, "create D32S8 table texture"); // Guest views written into a guest heap hold the 32-byte table records the title copies into its tables. const UINT step = guest->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); check(step >= 32 ? S_OK : E_FAIL, "guest descriptor step holds a 32-byte record"); - const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 4, + const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 8, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE}; ComPtr heap; check(guest->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap)), "create guest table heap"); const UINT64 base = slot(heap.Get(), 9)(heap.Get()); - const auto record = [&](UINT index, DXGI_FORMAT format, D3D12_SRV_DIMENSION dimension) { + const auto record = [&](UINT index, DXGI_FORMAT format, D3D12_SRV_DIMENSION dimension, + ID3D12Resource* resource = nullptr, UINT plane = 0) { D3D12_SHADER_RESOURCE_VIEW_DESC view{format, dimension, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING}; view.Texture2D.MipLevels = 1; + view.Texture2D.PlaneSlice = plane; if (dimension == D3D12_SRV_DIMENSION_TEXTURE2DARRAY) view.Texture2DArray.ArraySize = 1; - slot(guest.Get(), 18)(guest.Get(), texture.Get(), &view, base + index * step); + slot(guest.Get(), 18)(guest.Get(), resource ? resource : texture.Get(), &view, base + index * step); return reinterpret_cast(base + index * step); }; const auto expect = [&](const unsigned* words, int bound, const char* reason, const char* label) { @@ -3312,6 +3325,12 @@ int main(int argc, char** argv) try expect(record(2, DXGI_FORMAT_R8G8B8A8_SINT, D3D12_SRV_DIMENSION_TEXTURE2D), 0, integer, "SINT view is refused"); expect(record(3, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_SRV_DIMENSION_TEXTURE2DARRAY), 0, "native Mesh86 material texture does not resolve to the expected SRV", "2D array view is refused"); + expect(record(4, DXGI_FORMAT_X24_TYPELESS_G8_UINT, D3D12_SRV_DIMENSION_TEXTURE2D, depth24.Get(), 1), 0, integer, + "D24S8 stencil plane view is refused"); + expect(record(5, DXGI_FORMAT_X32_TYPELESS_G8X24_UINT, D3D12_SRV_DIMENSION_TEXTURE2D, depth32.Get(), 1), 0, + integer, "D32S8 stencil plane view is refused"); + expect(record(6, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, D3D12_SRV_DIMENSION_TEXTURE2D, depth24.Get()), 1, nullptr, + "D24S8 depth plane view is bound"); expect(none, 1, nullptr, "empty record binds a typed null"); return 0; }