Skip to content
Merged
4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"d3d12_sdk_check", "era_heap_check", "xmem_shim", "offscreen_check",
"cpu_fuzz_lifted", "cpu_fuzz_lifted_o2", "pe_map", "intake_candidate",
"archive_gpu_reader", "archive_codec_gpu", "archive_texture_gpu_lifted", "startup_launch_probe",
"startup_indirect_dispatch", "startup_indirect_draw_indexed", "startup_present_readback_check",
"compile_dxil", "startup_indirect_dispatch", "startup_indirect_draw_indexed", "startup_present_readback_check",
"startup_present_planes", "startup_present_composite_warp",
"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",
Expand All @@ -49,7 +49,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_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_shader_cache_key|startup_present_readback|startup_present_planes(_control)?|startup_present_composite_(warp|overlay_removed_control_warp)|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|startup_stage_package|startup_compute_packed_d16_x_uav_reference)$"
"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_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_shader_cache_key|startup_present_readback|startup_present_planes(_control)?|startup_present_composite_(warp|overlay_removed_control_warp)|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|startup_stage_package|startup_compute_packed_d16_x_uav_reference)$"
}
}
},
Expand Down
79 changes: 79 additions & 0 deletions docs/experiments/native-fixed-mesh57.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,82 @@ pixel entry. A creation archive alone preserves the two register blocks but
does not assign hardware register meanings to their offsets. Reproduce the
source-built positive and altered-stage controls with
`ctest --preset dev --no-tests=error -R '^native_direct_mesh$'`.

## Real-shape v6 group-index exchange

The native mesh frontend now reads the zero-address VGPR from the first
`v_mov_b32_e32` of the group-index exchange instead of requiring v0. The
source-built 85-word fixture also has a formatted heap read through
`v_readfirstlane_b32`, three DS writes and reads, five barriers,
`GS_ALLOC_REQ` and pos0/prim exports. `compile_dxil gfx1013-raw-ms` produces
a 4,876-byte MS and `gfx1013-raw-mesh-ps` a 2,386-byte PS. Changing the zero
VGPR to v5 while the DS fields still name v6 must be refused.

An output count without a proven upper bound is clamped to the layout's
declared maximum vertices or primitives. This moves the real title request
past the count exchange; it stops later on an undefined incoming VGPR.

## Partial-EXEC VGPRs (opt-in)

A VGPR defined under a partial EXEC mask and read after an LDS branch is
refused by default because the merge cannot prove which lanes observed the
write. `X2W_MESH57_PARTIAL_ZERO=1` keeps the last partial value for mesh reads
and exports and materializes a missing merge edge as zero. This lets the first
captured title request compile (MS 12,680 bytes, PS 2,310 bytes), while the
default still refuses it. The mode is a heuristic for lanes the shader has not
proven defined; it is not the reviewed semantic replacement for per-VGPR EXEC
tracking.

The source-built test adds a scalar join before the count exchange whose
pos0.w source (`v9`) exists on the fall-through edge only. It is refused by
default at `+0x148` with `graphics register undefined on an incoming path:
265` and accepted with the switch, where the IR selects `0` on the edge that
did not write the VGPR. This covers the general `reg>=256` merge rule, not
only registers already marked partial. The wrong-zero-VGPR control asserts
the exact `+0x4` `mesh group-index exchange shape or entry state is not
covered` refusal in both modes. No GPU draw exercises the opt-in yet: the
existing `native_fixed_mesh57_*` fixtures submit different MS bytes.

For profile authoring, `X2W_MESH_DUMP_LAYOUT=1` on a `guest_root` raw mesh
request prints the derived SGPR, root parameter and constant count for every
root input, plus the resource-heap SGPR. One captured title request yields
`s16/s17/s18` tables, `s19` root SRV, `s21` root-4 constants of two words
and heap `s23`; that is the mapping used by the first generated
`Mesh57Profile`.

The mesh scalar/vector subset also accepts the ordinary integer forms
`v_sub_nc_u32`, `v_subrev_nc_u32`, `v_add_co_ci_u32`, `s_cmpk_lg_i32` and
`s_lshl2_add_u32`. On twelve captured live requests this moved every
remaining multi-byte request past its first ALU refusal: three now stop at
heap-slot provenance, two at `v_readfirstlane_b32`, two at a raw root buffer
descriptor and one at an unmapped export target. Four depth-only requests
already compile.

The source-built test compiles each of the five forms. `v_add_co_ci_u32`
needs a reaching VCC carry word; the mesh entry defines none, so the same
instruction without a preceding `s_mov_b64 vcc, 0` is refused with
`unproven mesh entry register 106`. `v_sub_co_ci_u32` stays outside the
subset.

The raw root-buffer V# path accepts `root_stride_one_high` with the
`0x31016fac` byte-count format, and OFFEN may carry a nonzero immediate
offset. This moves the live request `314407020a96f733` from
`unsupported raw root buffer descriptor or offset` at `+0x330` to its next
refusal at `+0x614` (a resource-heap descriptor load).

The source-built compute check compiles an OFFEN load with offset 16 for both
the stride-one and the zero-stride byte-count V#; the emitted address adds the
offset. IDXEN never reaches this check: the raw-load decoder refuses it first
with `raw buffer load needs a linear byte offset and no modifiers`. The
relaxed `(i.a & 0x1000)` mask therefore only admits the immediate offset; a
missing OFFEN still refuses with `unsupported raw root buffer descriptor or
offset`.

`X2W_DUMP_SHADER_IR=<path>` on `compile_dxil` writes the DXIL text (or the
HLSL source for profiles that still emit HLSL) before `dxc`; the tests use it
to assert the clamp selects, the partial-edge phi and the OFFEN address. The
source-built mesh test is part of the Windows `pr` test filter.

Reproduce with `ctest --preset dev --no-tests=error -R '^startup_mesh57_real_shape$' -V`.
This tranche covers the compiler shape only; the direct-heap runtime profile
and the draw/readback are still to be added.
33 changes: 31 additions & 2 deletions src/gfx1013_direct_compute.inl
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Lower the shared decoded CFG to DXIL operations. A scalar register holds one
// 32-bit word per wave. Ordinary vector writes retain their old value on inactive lanes.
inline bool mesh_partial_zero()
{
const char* value=std::getenv("X2W_MESH57_PARTIAL_ZERO");
return value && value[0]=='1';
}
struct DirectCompute {
// The nine inline float constants as binary16, which an f16 operand reads instead of the f32 pattern.
static constexpr Word inline_half_words[]{0x3800, 0xb800, 0x3c00, 0xbc00, 0x4000,
Expand Down Expand Up @@ -99,6 +104,10 @@ struct DirectCompute {
std::function<string(unsigned)> graphics_input;
std::function<void(unsigned)> after_graphics_write;
std::map<unsigned, string> graphics_registers;
// Last non-empty value of a VGPR written under a partial EXEC. A mesh
// export is observed only on its guard lanes, so it may use this value
// after a full-EXEC reset erased the symbol.
std::map<unsigned, string> partial_values;
string graphics_predicate;
unsigned graphics_pc = 0;
const State *compute_state = nullptr;
Expand Down Expand Up @@ -150,6 +159,21 @@ struct DirectCompute {
string read(unsigned r) {
if (compute_state && compute_state->has_spill(r))
refuse(compute_pc, "symbolic VGPR lane read of " + reg(r));
if (graphics_input && mesh_partial_zero()) {
const auto found = graphics_registers.find(r);
if (found == graphics_registers.end() || found->second.empty()) {
const auto partial = partial_values.find(r);
if (partial != partial_values.end()) return partial->second;
}
}
return read_storage(r);
}
string read_export(unsigned r) {
if (!mesh_partial_zero()) return read_storage(r);
const auto found = graphics_registers.find(r);
if (found != graphics_registers.end() && !found->second.empty()) return found->second;
const auto partial = partial_values.find(r);
if (partial != partial_values.end()) return partial->second;
return read_storage(r);
}
bool lane_write = false; // v_writelane_b32 updates one lane of a VGPR that may hold symbolic lanes
Expand Down Expand Up @@ -894,9 +918,14 @@ struct DirectCompute {
// also reads exactly the OFFEN byte window of its root SRV.
const bool byte_bounds=s.at(base+1)==Symbol{Symbol::Type::root_address,low.value,1} &&
s.at(base+3)==Symbol{Symbol::Type::constant,0x31016fac};
if (low.offset || (!stride_one && !byte_bounds) ||
const bool stride_one_byte=s.at(base+1)==Symbol{Symbol::Type::root_stride_one_high,low.value,1} &&
s.at(base+3)==Symbol{Symbol::Type::constant,0x31016fac};
// OFFEN is mandatory and its 12-bit immediate offset is added to the
// address below. IDXEN (bit 13) never reaches this check: the raw
// load decoder refuses it, so only OFFEN has to be tested here.
if (low.offset || (!stride_one && !byte_bounds && !stride_one_byte) ||
!(s.at(base+2) == Symbol{Symbol::Type::constant, 0xffffffff}) ||
(i.a & 0x3fff) != 0x1000 || (i.b >> 24) != 128)
(i.a & 0x1000) != 0x1000 || (i.b >> 24) != 128)
refuse(i.pc, "unsupported raw root buffer descriptor or offset");
h = root_buffer_handle(low.value, 4*n);
} else {
Expand Down
Loading
Loading