Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/gfx1013_direct_mesh.inl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout
DirectCompute alu{emitter};
// A container stage reflects its table records; an IDXEN raw load takes its record stride from them.
alu.graphics_interface=reflected;
alu.graphics_half_writes=layout.texture_heap_slot_map;
// The mesh tracks which half of a VGPR a 16-bit write defined: a mixed
// f16 fma writes one half, and a later read may consume the whole word
// only when both halves have been written.
alu.graphics_half_writes=true;
GuestShaderStage fixed_outputs{};
fixed_outputs.output_signature.push_back({"SV_Position",0,1,3,0,15,15});
GraphicsStage graphics{reflected ? *reflected : fixed_outputs,alu,false};
Expand Down
25 changes: 25 additions & 0 deletions tests/native_direct_mesh_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ def _sop1(op, dst, src):
return 0xBE800000 | ((dst & 0x7F) << 16) | ((op & 0xFF) << 8) | (src & 0xFF)


def assert_export_column(text, value, column):
"""A 32-bit SSA value reaches one POS0 column through uitofp and bitcasts."""
value_re = r"%[\w.]+"
as_float = re.search(rf"(?P<float>{value_re}) = uitofp i32 {re.escape(value)} to float\n", text)
assert as_float, text
bits = re.search(rf"(?P<bits>{value_re}) = bitcast float {re.escape(as_float['float'])} to i32\n", text)
assert bits, text
back = re.search(rf"(?P<back>{value_re}) = bitcast i32 {re.escape(bits['bits'])} to float\n", text)
assert back, text
assert re.search(rf"call void @dx\.op\.storeVertexOutput\.f32\(i32 171, i32 \d+, i32 0, i8 {column}, "
rf"float {re.escape(back['back'])},", text), text


def _inline_u32(value):
if 0 <= value <= 64:
return 128 + value
Expand Down Expand Up @@ -741,6 +754,18 @@ def skip_load(body, seed=True):
'graphics register read includes undefined bits: 276')
run('mesh-full-read-of-partial-half',half_frontend+[0x7e340314]+program,
'graphics register read includes undefined bits: 276')
# A mixed f16 pair writes the low and high halves of one VGPR; only
# both together make the whole word readable.
half_pair = [0xcc210014, 242 | (242 << 9) | (242 << 18), # v_fma_mixlo_f16 v20, 1, 1, 1
0xcc220014, 242 | (242 << 9) | (242 << 18)] # v_fma_mixhi_f16 v20, 1, 1, 1
layout.write_text('mesh1 128 3 1 2 128 64')
text = run('mesh-mixed-half-pair', program[:5] + half_pair + [0x7e020314] + program[6:])
assert 'legacyF32ToF16' in text
packed = re.findall(r'(%[\w.]+) = or i32 ', text)
assert len(packed) >= 2, text
assert_export_column(text, packed[-1], 0)
run('mesh-mixed-half-single', program[:5] + half_frontend + [0x7e020314] + program[6:],
'graphics register read includes undefined bits: 276')
# GPU-selected slot through a view token: the heap byte offset is a dword read from a root-table buffer SRV,
# times 32. The token at that address names the view; the shader checks it before reading the heap.
select_word = [0xbe910380, # s_mov_b32 s17, 0 (table high word)
Expand Down
Loading