diff --git a/CMakePresets.json b/CMakePresets.json index f6416a06a..37f7c0746 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -34,7 +34,7 @@ "xmem_shim_test_controls", "startup_stub_xcrdapi", "startup_stub_xcrdapi_break_window_control", "xmem_run_break_readers_check", "xmem_run_break_readers_control", "xmem_cross_call_merge_check", "xmem_placeholder_split_check", "xmem_map_split_first_check", "startup_dstorage_break_window_check", - "xmem_page_runs_device_check", "linear_buffer_backing_check", "existing_heap_shared_buffer_check", + "xmem_page_runs_device_check", "linear_buffer_backing_check", "existing_heap_shared_buffer_check", "mesh86_typed_vsharp_check", "mesh86_typed_vsharp_wide_format_mut", "mesh86_typed_vsharp_any_map_mut", "mesh86_typed_vsharp_any_swizzle_mut", "mesh86_typed_vsharp_any_tid_mut", "bcpack_formats_check", "startup_stub_consumer", "startup_inline_retire", "startup_resource_retire_title", "startup_table_lock", "native_compute_ir_dump", "native_pixel_ir_dump", "native_store_replay", "native_raw_buffer_view_check" ] @@ -50,7 +50,7 @@ "displayName": "Windows pull request smoke tests", "filter": { "include": { - "name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_mesh57_real_shape|startup_mesh57_runtime(_[a-z]+)?_warp|native_fixed_mesh57_published_pair(_refusal)?_warp|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_indirect_mesh_cache_heap(_wide)?_warp|runtime_mesh86_cache_cli_check|startup_shader_cache_key|startup_present_readback|startup_present_planes(_control)?|startup_present_composite_(warp|overlay_removed_control_warp)|startup_mesh_title_snapshot_warp|startup_list_copy_(warp|title_snapshot_warp|validation(_[a-z_]+_control)?)|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|existing_heap_shared_buffer(_offset_control)?_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference|native_.*_(ir|dxil|controls)|native_direct_mesh|startup_triage_run)$" + "name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_mesh57_real_shape|startup_mesh57_runtime(_[a-z]+)?_warp|native_fixed_mesh57_published_pair(_refusal)?_warp|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_indirect_mesh_cache_heap(_wide)?_warp|runtime_mesh86_cache_cli_check|startup_shader_cache_key|startup_present_readback|startup_present_planes(_control)?|startup_present_composite_(warp|overlay_removed_control_warp)|startup_mesh_title_snapshot_warp|startup_list_copy_(warp|title_snapshot_warp|validation(_[a-z_]+_control)?)|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|existing_heap_shared_buffer(_offset_control)?_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference|native_.*_(ir|dxil|controls)|native_direct_mesh|startup_triage_run|mesh86_typed_vsharp_[a-z_]+)$" } } }, diff --git a/src/gfx1013_direct_mesh.inl b/src/gfx1013_direct_mesh.inl index 6db74c887..f0a26698a 100644 --- a/src/gfx1013_direct_mesh.inl +++ b/src/gfx1013_direct_mesh.inl @@ -1581,6 +1581,13 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout alu.write(i.dst+j,j>=1 && j<=3 ? texture_metadata[j-1] : string{}); } state=next; + } else if (i.name=="buffer_load_format" && i.op==0 && (full_exec || exec_skip) && + ((i.a&0x3ffff)==0x2000 || (i.a&0x3ffff)==0) && + state[((i.b>>16)&31)*4].type==Symbol::Type::descriptor) { + // A V# read whole from a bound descriptor table: the shared typed-buffer SRV path checks the + // table binding and all four descriptor words, as it does for vertex and pixel shaders. + alu.memory(i,state); + if (!full_exec) partial_writes.insert(256+i.dst); } else if (i.name=="buffer_load_format" && i.op==0 && (full_exec || exec_skip) && ((i.a&0x3ffff)==0x2000 || (i.a&0x3ffff)==0)) { const auto base=((i.b>>16)&31)*4; diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index f400a96e8..c85af6416 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -14,6 +14,7 @@ #define X2W_TRAP_MODULE_ID 7 #include "startup_stubs/indexed_resource_list.h" #include "startup_stubs/indirect_cross_list_copy.h" +#include "startup_stubs/mesh86_typed_vsharp.h" #include "startup_stubs/trap.h" #include "x2w_build_rev.h" #include "xmem_page_batch.h" diff --git a/src/startup_stubs/mesh86_typed_vsharp.h b/src/startup_stubs/mesh86_typed_vsharp.h new file mode 100644 index 000000000..aee6530b9 --- /dev/null +++ b/src/startup_stubs/mesh86_typed_vsharp.h @@ -0,0 +1,30 @@ +// Slot 86 typed buffer sources (buffer_load_format_x) read from a guest V# that is not a view token. +// The desktop view is R32_UINT with 4-byte elements, so the V# must not reorder or drop channels and +// must name a format whose X channel is the stored dword. +#pragma once + +#include + +namespace x2w_startup { + +// Word 3 bits 11:0: DST_SEL_X..W = X, Y, Z, W (4, 5, 6, 7). +inline bool mesh86_typed_identity_map(std::uint32_t word3) +{ + return (word3 & 0xfffu) == 0xfacu; +} + +// Word 3 bits 18:12: BUF_FMT_32_UINT (20), BUF_FMT_32_SINT (21) or BUF_FMT_32_FLOAT (22). +inline bool mesh86_typed_dword_format(std::uint32_t word3) +{ + const std::uint32_t format = (word3 >> 12) & 0x7fu; + return format >= 20u && format <= 22u; +} + +// Element i at base + i * stride: word 1 bit 31 (SWIZZLE_ENABLE) and word 3 bit 23 (ADD_TID_ENABLE) clear. +// Either bit changes which bytes a lane reads, and a linear desktop view would not. +inline bool mesh86_typed_linear(std::uint32_t word1, std::uint32_t word3) +{ + return !(word1 & 0x80000000u) && !(word3 & 0x00800000u); +} + +} // namespace x2w_startup diff --git a/src/startup_stubs/native_mesh86.inl b/src/startup_stubs/native_mesh86.inl index 4f5baf5f0..b1fb9b749 100644 --- a/src/startup_stubs/native_mesh86.inl +++ b/src/startup_stubs/native_mesh86.inl @@ -72,14 +72,16 @@ x2w_startup::ComPtr make_native_mesh86_root( const bool indexed_raw = view.kind == Kind::indexed_raw_srv; const bool scalar = view.kind == Kind::buffer_srv || view.kind == Kind::raw_vector_srv || view.kind == Kind::byte_window_srv || view.kind == Kind::root_buffer_srv || indexed_raw; - require(view.shader_register == i && view.root_parameter < guest.size() && (image || scalar) && + // buffer_load_format_x from a V# in a descriptor table: one 32-bit component per element. + const bool typed = view.kind == Kind::typed_buffer_srv && view.required_bytes == 4; + require(view.shader_register == i && view.root_parameter < guest.size() && (image || scalar || typed) && (!image || view.image_dimension == 0 || view.image_dimension == 1 || view.image_dimension == 5), "unsupported native Mesh86 SRV shape"); const auto type = guest[view.root_parameter].type; const bool table = type == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; require(table ? !(view.byte_offset & 31) : - !image && !indexed_raw && !view.byte_offset && (type == D3D12_ROOT_PARAMETER_TYPE_SRV || - type == D3D12_ROOT_PARAMETER_TYPE_CBV), + !image && !indexed_raw && !typed && !view.byte_offset && + (type == D3D12_ROOT_PARAMETER_TYPE_SRV || type == D3D12_ROOT_PARAMETER_TYPE_CBV), "invalid native Mesh86 SRV source"); require(!indexed_raw || (view.array_count == 1 && view.required_bytes && !(view.required_bytes % 4) && view.required_bytes <= 2048), @@ -404,6 +406,25 @@ const char* bind_native_mesh86(Wrapper* self, Pass& pass, ID3D12GraphicsCommandL buffer_states.emplace_back(view.resource, view.upload); return nullptr; }; + // A buffer_load_format_x source, from a heap slot or a table: an R32_UINT view of 4-byte elements. + // A raw V# must address elements linearly, and a table V# must also name a 32-bit data format (see + // mesh86_typed_vsharp.h), so the R32_UINT view returns the same dword the guest format load would. + const auto typed_dword = [&](UINT slot, const UINT (&words)[8], bool table = false) -> const char* { + Mesh86Texture typed; + if (words[0] == view_token_magic && + (!mesh86_texture(words, typed) || typed.view.ViewDimension != D3D12_SRV_DIMENSION_BUFFER || + typed.view.Format != DXGI_FORMAT_R32_UINT || typed.view.Buffer.Flags || typed.view.Buffer.StructureByteStride)) + return "native Mesh86 typed buffer slot is not R32_UINT"; + if (words[0] != view_token_magic && !x2w_startup::mesh86_typed_identity_map(words[3])) + return "native Mesh86 typed buffer descriptor uses another component map"; + if (words[0] != view_token_magic && !x2w_startup::mesh86_typed_linear(words[1], words[3])) + return "native Mesh86 typed buffer descriptor is swizzled or adds the thread ID"; + if (table && words[0] != view_token_magic && !x2w_startup::mesh86_typed_dword_format(words[3])) + return "native Mesh86 typed buffer descriptor is not a 32-bit format"; + const auto view = indirect_table_buffer(self, words, false, nullptr, 16u << 20, 4, true); + if (view.stride != 4) return "native Mesh86 typed buffer view has the wrong stride"; + return buffer(slot, view, true); + }; const auto image = [&](Mesh86Texture& texture) { if (!mesh86_realize_texture(self, pass, texture)) return false; return !texture.resource || !texture_states.insert(texture.resource).second || @@ -427,6 +448,12 @@ const char* bind_native_mesh86(Wrapper* self, Pass& pass, ID3D12GraphicsCommandL else if (!mesh86_texture(words, texture) || texture.view.ViewDimension != dim || !image(texture)) return "native Mesh86 material texture does not resolve to the expected SRV"; descriptors[slot] = {texture.resource, texture.view}; + } else if (source.kind == Kind::typed_buffer_srv) { + UINT words[8]; + if (!mesh86_read_record(pass.view_tables[source.root_parameter], source.byte_offset, words)) + return "native Mesh86 typed buffer descriptor is outside its table"; + if (const char* reason = typed_dword(slot, words, true)) return reason; + strides[source.shader_register] = 4; } else { const char* reason = nullptr; UINT words[8]{}; @@ -482,16 +509,7 @@ const char* bind_native_mesh86(Wrapper* self, Pass& pass, ID3D12GraphicsCommandL UINT words[8]; if (slot >= pass.mesh_heap_slots || !mesh86_read_record(pass.title_view_heap, UINT64{slot} * 32, words)) return "native Mesh86 typed buffer slot is outside the bound heap"; - Mesh86Texture typed; - if (words[0] == view_token_magic && - (!mesh86_texture(words, typed) || typed.view.ViewDimension != D3D12_SRV_DIMENSION_BUFFER || - typed.view.Format != DXGI_FORMAT_R32_UINT || typed.view.Buffer.Flags || typed.view.Buffer.StructureByteStride)) - return "native Mesh86 typed buffer slot is not R32_UINT"; - if (words[0] != view_token_magic && (words[3] & 0xfffu) != 0xfacu) - return "native Mesh86 typed buffer descriptor uses another component map"; - const auto view = indirect_table_buffer(self, words, false, nullptr, 16u << 20, 4, true); - if (view.stride != 4) return "native Mesh86 typed buffer view has the wrong stride"; - if (const char* reason = buffer(slot, view, true)) return reason; + if (const char* reason = typed_dword(slot, words)) return reason; } const auto add_image = [&](Mesh86Texture& texture) { if (descriptors.size() >= D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1) return no_index; diff --git a/tests/cmake/mesh86_typed_vsharp.cmake b/tests/cmake/mesh86_typed_vsharp.cmake new file mode 100644 index 000000000..2145c3a48 --- /dev/null +++ b/tests/cmake/mesh86_typed_vsharp.cmake @@ -0,0 +1,53 @@ +# Unit tests for src/startup_stubs/mesh86_typed_vsharp.h: the V# word 3 checks slot 86 applies before it binds +# a buffer_load_format_x source from a descriptor table as an R32_UINT view. Header-only, no device. +add_executable(mesh86_typed_vsharp_check tests/mesh86_typed_vsharp_check.cpp) +target_include_directories(mesh86_typed_vsharp_check PRIVATE src) +target_compile_features(mesh86_typed_vsharp_check PRIVATE cxx_std_17) +foreach(mesh86_typed_vsharp_case IN ITEMS identity_map dword_formats other_formats linear_addressing guest_words) + add_test(NAME mesh86_typed_vsharp_${mesh86_typed_vsharp_case} + COMMAND mesh86_typed_vsharp_check ${mesh86_typed_vsharp_case}) + set_tests_properties(mesh86_typed_vsharp_${mesh86_typed_vsharp_case} PROPERTIES TIMEOUT 60) +endforeach() + +# Mutation controls: each builds the check against a copy of the header with one guard changed and runs the +# case that guard must catch. Each control must fail (WILL_FAIL TRUE). +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS src/startup_stubs/mesh86_typed_vsharp.h) +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/startup_stubs/mesh86_typed_vsharp.h" mesh86_typed_vsharp_text) +foreach(mesh86_typed_vsharp_mut IN ITEMS wide_format any_map any_swizzle any_tid) + if(mesh86_typed_vsharp_mut STREQUAL "wide_format") + # The 32-bit formats widened by one: other_formats sees 23 accepted. + set(mesh86_typed_vsharp_from "format <= 22u") + set(mesh86_typed_vsharp_to "format <= 23u") + set(mesh86_typed_vsharp_case other_formats) + elseif(mesh86_typed_vsharp_mut STREQUAL "any_swizzle") + # SWIZZLE_ENABLE is no longer checked: linear_addressing sees a swizzled V# accepted. + set(mesh86_typed_vsharp_from "!(word1 & 0x80000000u)") + set(mesh86_typed_vsharp_to "(word1 == word1)") + set(mesh86_typed_vsharp_case linear_addressing) + elseif(mesh86_typed_vsharp_mut STREQUAL "any_tid") + # ADD_TID_ENABLE is no longer checked: linear_addressing sees a thread-ID V# accepted. + set(mesh86_typed_vsharp_from "!(word3 & 0x00800000u)") + set(mesh86_typed_vsharp_to "(word3 == word3)") + set(mesh86_typed_vsharp_case linear_addressing) + else() + # The component map is no longer checked: identity_map sees a swizzle accepted. + set(mesh86_typed_vsharp_from "return (word3 & 0xfffu) == 0xfacu;") + set(mesh86_typed_vsharp_to "return word3 == word3;") + set(mesh86_typed_vsharp_case identity_map) + endif() + string(REPLACE "${mesh86_typed_vsharp_from}" "${mesh86_typed_vsharp_to}" + mesh86_typed_vsharp_mutated "${mesh86_typed_vsharp_text}") + if(mesh86_typed_vsharp_mutated STREQUAL mesh86_typed_vsharp_text) + message(FATAL_ERROR "mesh86_typed_vsharp.h lost the anchor for mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}_mut") + endif() + set(mesh86_typed_vsharp_dir "${CMAKE_CURRENT_BINARY_DIR}/mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}") + file(MAKE_DIRECTORY "${mesh86_typed_vsharp_dir}/startup_stubs") + file(WRITE "${mesh86_typed_vsharp_dir}/startup_stubs/mesh86_typed_vsharp.h" "${mesh86_typed_vsharp_mutated}") + add_executable(mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}_mut tests/mesh86_typed_vsharp_check.cpp) + target_include_directories(mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}_mut BEFORE PRIVATE + "${mesh86_typed_vsharp_dir}" src) + target_compile_features(mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}_mut PRIVATE cxx_std_17) + add_test(NAME mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}_mut + COMMAND mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}_mut ${mesh86_typed_vsharp_case}) + set_tests_properties(mesh86_typed_vsharp_${mesh86_typed_vsharp_mut}_mut PROPERTIES WILL_FAIL TRUE TIMEOUT 60) +endforeach() diff --git a/tests/mesh86_typed_vsharp_check.cpp b/tests/mesh86_typed_vsharp_check.cpp new file mode 100644 index 000000000..084d1d6a8 --- /dev/null +++ b/tests/mesh86_typed_vsharp_check.cpp @@ -0,0 +1,94 @@ +// Unit and header-mutation tests for src/startup_stubs/mesh86_typed_vsharp.h: the V# word 3 checks that +// let slot 86 bind a buffer_load_format_x source from a descriptor table as an R32_UINT view. +// +// Usage: mesh86_typed_vsharp_check [] (no argument runs all cases) +// Every mismatch prints "FAIL: : ..." to stderr and exits non-zero. +#include "startup_stubs/mesh86_typed_vsharp.h" + +#include +#include +#include +#include + +using x2w_startup::mesh86_typed_dword_format; +using x2w_startup::mesh86_typed_identity_map; +using x2w_startup::mesh86_typed_linear; + +namespace { +int failures = 0; + +void expect(const char* name, bool ok, const char* what) +{ + if (!ok) { + std::fprintf(stderr, "FAIL: %s: %s\n", name, what); + ++failures; + } +} + +std::uint32_t with_format(std::uint32_t format) { return 0xfacu | (format << 12); } + +void identity_map(const char* n) +{ + expect(n, mesh86_typed_identity_map(0xfacu), "XYZW accepted"); + expect(n, mesh86_typed_identity_map(0xffffffacu), "upper bits ignored"); + expect(n, !mesh86_typed_identity_map(0xfadu), "DST_SEL_X = Y refused"); + expect(n, !mesh86_typed_identity_map(0x688u), "ZYX0 refused"); + expect(n, !mesh86_typed_identity_map(0u), "all-zero map refused"); +} + +void dword_formats(const char* n) +{ + for (std::uint32_t format : {20u, 21u, 22u}) + expect(n, mesh86_typed_dword_format(with_format(format)), "32-bit format accepted"); +} + +void other_formats(const char* n) +{ + for (std::uint32_t format : {0u, 1u, 19u, 23u, 56u, 77u, 127u}) + expect(n, !mesh86_typed_dword_format(with_format(format)), "non-32-bit format refused"); +} + +void linear_addressing(const char* n) +{ + expect(n, mesh86_typed_linear(0x00040000u, 0x31016facu), "stride 4, no swizzle, no thread ID accepted"); + expect(n, mesh86_typed_linear(0x7fffffffu, 0xff7fffffu), "other word 1 and word 3 bits ignored"); + expect(n, !mesh86_typed_linear(0x80040000u, 0x31016facu), "SWIZZLE_ENABLE refused"); + expect(n, !mesh86_typed_linear(0x00040000u, 0x31816facu), "ADD_TID_ENABLE refused"); +} + +void guest_words(const char* n) +{ + // Word 3 of the V#s the title synthesizes for root SRVs: 32_UINT and 32_FLOAT, identity map. + for (std::uint32_t word3 : {0x11014facu, 0x31016facu}) { + expect(n, mesh86_typed_identity_map(word3), "guest map accepted"); + expect(n, mesh86_typed_dword_format(word3), "guest format accepted"); + expect(n, mesh86_typed_linear(0u, word3), "guest word 3 adds no thread ID"); + } +} + +struct Case { + const char* name; + void (*run)(const char*); +}; + +const Case cases[]{{"identity_map", identity_map}, + {"dword_formats", dword_formats}, + {"other_formats", other_formats}, + {"linear_addressing", linear_addressing}, + {"guest_words", guest_words}}; +} // namespace + +int main(int argc, char** argv) +{ + bool found = argc < 2; + for (const auto& c : cases) { + if (argc >= 2 && std::strcmp(argv[1], c.name)) continue; + found = true; + c.run(c.name); + } + if (!found) { + std::fprintf(stderr, "FAIL: unknown case %s\n", argv[1]); + return 2; + } + return failures ? 1 : 0; +} diff --git a/tests/native_direct_mesh_check.py b/tests/native_direct_mesh_check.py index 77e213534..0bd207aae 100644 --- a/tests/native_direct_mesh_check.py +++ b/tests/native_direct_mesh_check.py @@ -891,6 +891,28 @@ def skip_load(body, seed=True): 'unsupported mesh instruction or EXEC state: buffer_load_format_xy') run('typed-heap-xy-skip', skip_load([0xe0042000, 0x80080a01]), 'unsupported mesh instruction or EXEC state: buffer_load_format_xy') + # The same load from a V# read whole out of a bound descriptor table (root parameter 1, t0) goes + # through the shared typed-buffer SRV path instead of the resource heap. + heap_layout = layout.read_text() + layout.write_text('mesh1 128 3 1 2 128 64\nconstants 21 0 1\ntable 16 1') + table_setup = [0xbe910380, 0xf4080608, 0xfa000000] # s_mov_b32 s17, 0; s_load_dwordx4 s[24:27], s[16:17], 0 + table_idxen = [0xe0002000, 0x80060a01] # buffer_load_format_x v10, v1, s[24:27], 0 idxen + def table_load(body, seed=True): + pre = [0x7e140287] if seed else [] # v_mov_b32 v10, 7 + return table_setup + exported[:7] + pre + [0x7da40081, 0xbf880000 | len(body), *body, 0xbefe04c1] + exported[7:] + text = run('typed-table', table_setup + [0x7e020280] + table_idxen + exported) # v1 = 0 + assert 'bufferLoad.i32' in text and 'createHandleFromHeap' not in text, text + text = run('typed-table-lane-skip', table_load(table_idxen)) + assert 'bufferLoad.i32' in text and 'createHandleFromHeap' not in text, text + assert re.search(r'select i1 %[\w.]+, i32 %[\w.]+, i32 7\b', text), text + assert re.search(r'phi i32 \[ 7, %mesh_empty\d+ \]', text), text + run('typed-table-lane-skip-undef', table_load(table_idxen, seed=False), + 'graphics register undefined on an incoming path: 266') + run('typed-table-xy', table_setup + [0x7e020280, 0xe0042000, 0x80060a01] + exported, + 'unsupported mesh instruction or EXEC state: buffer_load_format_xy') + run('typed-table-no-skip', table_setup + exported[:7] + [0x7e140287, 0x7da40081, *table_idxen, 0xbefe04c1] + + exported[7:], 'unsupported mesh instruction or EXEC state: buffer_load_format_x') + layout.write_text(heap_layout) run('typed-heap-offset-skip', skip_load([0xe0002004, 0x80080a01]), 'formatted load requires zero or a single linear index') # Inside a whole-wave lane-limit skip (v_cmpx_gt_u32 + s_cbranch_execz), a fresh destination VGPR keeps its @@ -1034,7 +1056,7 @@ def assert_token_guard(text, reads): 'heap_tokens') result, out = compile_mesh('token-root-route', typed+exported) assert result.returncode == 0 and 'requires_heap_tokens' not in result.stdout, result.stdout + result.stderr - # Negative controls: another scale, no scale, a raw read, an overwritten descriptor word and a table descriptor in a skip. + # Negative controls: another scale, no scale, a raw read and an overwritten descriptor word. layout.write_text(token_layout) unaligned = 'mesh heap token byte offset is not a proven multiple of 32' run('token-shift4',select_word+[0x8f248424]+heap_base+selected_fetch+formatted+exported,unaligned) @@ -1045,7 +1067,11 @@ def assert_token_guard(text, reads): 'overwritten mesh heap descriptor') table_in_skip = (select_word[:3] + exported[:7] + [0x7e140287, 0x7da40081, 0xbf880002, 0xe0002000, 0x80080a01, 0xbefe04c1] + exported[7:]) - run('typed-table-in-skip', table_in_skip, 'formatted mesh load lacks an R32_UINT resource heap contract') + # A V# read from a bound table is not a heap slot: with heap tokens on, it still takes the typed table + # SRV route (see typed-table above) and needs no token view. + result, out = compile_mesh('typed-table-in-skip', table_in_skip) + assert result.returncode == 0 and 'requires_heap_tokens' not in result.stdout, result.stdout + result.stderr + assert 'bufferLoad.i32' in subprocess.check_output([sdk/'dxc.exe','-dumpbin',out], text=True) layout.write_text('mesh1 128 3 1 2 128 64\nconstants 21 0 1') widen_only = [ 0xbe96047e, # s_mov_b64 s[22:23], exec