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: 3 additions & 2 deletions src/gfx1013_direct_mesh.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout
alu.write(i.dst,ir.binary("or",high ? ir.binary("lshr",a,"16") : ir.binary("and",a,"65535"),
high ? ir.binary("and",b,"4294901760") : ir.binary("shl",b,"16")));
} else if (i.enc==Encoding::Sop2 && i.dst<106 && (i.name=="s_lshr_b32" || i.name=="s_lshl_b32" ||
i.name=="s_or_b32" || i.name=="s_and_b32")) {
i.name=="s_or_b32" || i.name=="s_and_b32" || i.name=="s_xor_b32")) {
const auto known=[&](unsigned r) {
return constant32(i,r).has_value() ||
(alu.graphics_registers.count(r) && !alu.graphics_registers.at(r).empty());
Expand All @@ -1551,7 +1551,8 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout
const auto a=alu.operand32(i,i.src[0]), b=alu.operand32(i,i.src[1]);
const bool shift=i.name=="s_lshl_b32" || i.name=="s_lshr_b32";
const auto value=ir.binary(i.name=="s_lshl_b32" ? "shl" : i.name=="s_lshr_b32" ? "lshr" :
i.name=="s_or_b32" ? "or" : "and",a,shift ? ir.binary("and",b,"31") : b);
i.name=="s_or_b32" ? "or" : i.name=="s_xor_b32" ? "xor" : "and",
a,shift ? ir.binary("and",b,"31") : b);
if (i.name=="s_lshl_b32" && a==wave_number && constant32(i,i.src[1])==(layout.wave32 ? 5u : 6u))
wave_bases.insert(value);
const auto bits=root_values.find(a);
Expand Down
14 changes: 14 additions & 0 deletions tests/native_direct_mesh_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,20 @@ def run(name, words, expected=None):
run(scalar_vcc_case,
program[:7] + [0x7d880080, scalar_vcc_word, 0x02020285] + program[7:],
'+0x20: mesh scalar write to VCC')
# s_movk_i32 s20, 0xfffe sign-extends to -2; s_xor_b32 s21, s20, -1 gives 1, which feeds
# v_and_b32 v1, s21, v0 and so the exported X position.
text = run('scalar-movk-xor', program[:5] + [0xb014fffe, 0x8915c114, 0x36020015] + program[6:])
xor = re.search(r'(%[\w.]+) = xor i32 -2, -1\n', text)
assert xor, text
assert_position_x(text, r'and i32 ' + re.escape(xor[1]) + ',')
for scalar_k_case, scalar_k_word, scalar_k_reason in (
('scalar-movk-vcc', 0xb06afffe, 'unsupported mesh instruction or EXEC state: s_movk_i32'),
('scalar-movk-exec', 0xb07efffe, 'unsupported mesh instruction or EXEC state: s_movk_i32'),
('scalar-movk-m0', 0xb07cfffe, 'unsupported mesh instruction or EXEC state: s_movk_i32'),
('scalar-xor-exec', 0x897ec114, 'unsupported mesh instruction or EXEC state: s_xor_b32'),
('scalar-xor-vcc', 0x896ac114, 'unsupported mesh instruction or EXEC state: s_xor_b32'),
):
run(scalar_k_case, program[:5] + [scalar_k_word] + program[5:], '+0x14: ' + scalar_k_reason)
# The three primitive slots are 9-bit indices with the edge flag in
# bit 9. 0x20280600 encodes (0,1,2) with all three edge flags set.
edge = program.copy()
Expand Down
Loading