diff --git a/src/gfx1013_direct_mesh.inl b/src/gfx1013_direct_mesh.inl index 131b6a4969..fd43432088 100644 --- a/src/gfx1013_direct_mesh.inl +++ b/src/gfx1013_direct_mesh.inl @@ -1620,7 +1620,8 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout i.name=="v_mad_u32_u24" || i.name=="v_add3_u32" || i.name=="v_bfe_u32" || i.name=="v_mov_b32" || i.name=="v_add_nc_u32" || i.name=="v_sub_nc_u32" || i.name=="v_subrev_nc_u32" || i.name=="v_add_co_ci_u32" || i.name=="v_lshlrev_b32" || i.name=="v_lshrrev_b32" || i.name=="v_or_b32" || i.name=="v_or3_b32" || i.name=="v_and_b32" || i.name=="v_xor_b32" || i.name=="v_lshl_add_u32" || i.name=="v_cvt_f32_u32" || i.name=="v_cvt_f32_i32" || - i.name=="v_mul_f32" || i.name=="v_add_f32" || i.name=="v_fma_f32")) { + i.name=="v_mul_f32" || i.name=="v_add_f32" || i.name=="v_fma_f32" || i.name=="v_bfm_b32" || + i.name=="v_bcnt_u32_b32")) { const bool flat=i.name=="v_lshl_add_u32" && alu.operand32(i,i.src[0])==wave_number && constant32(i,i.src[1])==(layout.wave32 ? 5u : 6u) && whole_lane.count(alu.operand32(i,i.src[2])); @@ -1630,7 +1631,7 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout const unsigned sources=accumulator || i.name=="v_fmaak_f32" ? 2 : rule!=alu_rules.end() ? rule->second.arity : i.name=="v_mad_legacy_f32" || i.name=="v_mad_u32_u24" || i.name=="v_add3_u32" ? 3 : - pair || i.name=="v_mul_legacy_f32" ? 2 : + pair || i.name=="v_mul_legacy_f32" || i.name=="v_bfm_b32" || i.name=="v_bcnt_u32_b32" ? 2 : i.name=="v_trunc_f32" || i.name=="v_fract_f32" || i.name=="v_cos_f32" || i.name.substr(0,15)=="v_cvt_f32_ubyte" ? 1 : 0; const auto uniform_source=[&](unsigned r) { diff --git a/tests/native_direct_mesh_check.py b/tests/native_direct_mesh_check.py index 4d2d2b8921..e148c47d81 100644 --- a/tests/native_direct_mesh_check.py +++ b/tests/native_direct_mesh_check.py @@ -176,6 +176,20 @@ def run(name, words, expected=None): text = run('v-mul-hi-u32', program[:5] + program[6:7] + mul_hi + program[7:]) assert 'mul i32' in text assert_position_x(text, r'add i32') + # VOP3 0x363: v_bfm_b32 v1, v0, 2 gives ((1 << (v0 & 31)) - 1) << 2. + bfm = [0xd7630001, 256 | (130 << 9)] + text = run('v-bfm-b32', program[:5] + program[6:7] + bfm + program[7:]) + value = r'%[\w.]+' + width = re.search(rf'(?P{value}) = shl i32 1, {value}\n\s*(?P{value}) = sub i32 (?P=one), 1\n' + rf'\s*(?P{value}) = and i32 2, 31\n\s*{value} = shl i32 (?P=mask), (?P=at)\n', text) + assert width, text + assert_position_x(text, rf'shl i32 {re.escape(width["mask"])}, {re.escape(width["at"])}') + # VOP3 0x364: v_bcnt_u32_b32 v1, v0, 5 adds 5 to the bit count of v0. + bcnt = [0xd7640001, 256 | (133 << 9)] + text = run('v-bcnt-u32-b32', program[:5] + program[6:7] + bcnt + program[7:]) + count = re.search(rf'(?P{value}) = call i32 @dx\.op\.unaryBits\.i32\(i32 31, i32 {value}\)', text) + assert count, text + assert_position_x(text, rf'add i32 {re.escape(count["count"])}, 5\b') # Pack the thread ID, the inline constant 2 and the sign-extended immediate in s7. pack_position = [0xb0078000, 0xd7720001, 256 | (130 << 9) | (7 << 18)] text = run('v-or3-b32', program[:5] + program[6:7] + pack_position + program[7:])