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
14 changes: 8 additions & 6 deletions tests/test_rdna2spirv_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,25 +280,27 @@ def test_straight_line_pops_pixel_shader_emits_begin_and_end_interlock(self):
gen.uses_pops = True
gen.body = ["OpNoOp"]
spv = rdna2spirv.assemble(gen)
self.assertIn("OpBeginInvocationInterlockEXT", spv)
self.assertIn("OpEndInvocationInterlockEXT", spv)
self.assertEqual(spv.count("OpBeginInvocationInterlockEXT"), 1)
self.assertEqual(spv.count("OpEndInvocationInterlockEXT"), 1)
self.assertLess(spv.index("OpBeginInvocationInterlockEXT"), spv.index("OpEndInvocationInterlockEXT"))

def test_branching_pops_pixel_shader_emits_begin_and_end_interlock(self):
gen = rdna2spirv.Gen("ps")
gen.uses_pops = True
gen.blocks = [["OpNoOp"]]
gen.succ = [[]]
spv = rdna2spirv.assemble(gen)
self.assertIn("OpBeginInvocationInterlockEXT", spv)
self.assertIn("OpEndInvocationInterlockEXT", spv)
self.assertEqual(spv.count("OpBeginInvocationInterlockEXT"), 1)
self.assertEqual(spv.count("OpEndInvocationInterlockEXT"), 1)
self.assertLess(spv.index("OpBeginInvocationInterlockEXT"), spv.index("OpEndInvocationInterlockEXT"))

def test_non_pops_pixel_shader_omits_interlock_ops(self):
gen = rdna2spirv.Gen("ps")
gen.uses_pops = False
gen.body = ["OpNoOp"]
spv = rdna2spirv.assemble(gen)
self.assertNotIn("OpBeginInvocationInterlockEXT", spv)
self.assertNotIn("OpEndInvocationInterlockEXT", spv)
self.assertEqual(spv.count("OpBeginInvocationInterlockEXT"), 0)
self.assertEqual(spv.count("OpEndInvocationInterlockEXT"), 0)


if __name__ == "__main__":
Expand Down
18 changes: 18 additions & 0 deletions tests/test_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ def test_mrtz_depth_only_from_an_enabled_x(make_shader, export, depth):
assert ("BuiltIn FragDepth" in spvasm) == depth
assert ("DepthReplacing" in spvasm) == depth


@pytest.mark.parametrize("body", [
"", # straight line (SHADER-350)
"s_cmp_eq_u32 s20, 0\ns_cbranch_scc1 1\nv_mov_b32 v0, 1.0\n", # branching control flow
], ids=["straight-line", "branch"])
def test_pops_interlock_begins_and_ends_once(make_shader, body):
"""A PS that reads src_pops_exiting_wave_id runs in one fragment-shader interlock: one
OpBeginInvocationInterlockEXT, then one OpEndInvocationInterlockEXT (SPV_EXT_fragment_shader_interlock: each
exactly once, begin before end). Validated against spirv-val."""
shader = make_shader("v_mov_b32 v0, 0.5\ns_mov_b32 s20, src_pops_exiting_wave_id\n" + body +
"exp mrt0 v0, v0, v0, v0 done vm\ns_endpgm\n", "ps_pops")
spvasm = shader.translate()
shader.validate(spvasm)
assert "PixelInterlockOrderedEXT" in spvasm
assert spvasm.count("OpBeginInvocationInterlockEXT") == 1
assert spvasm.count("OpEndInvocationInterlockEXT") == 1
assert spvasm.index("OpBeginInvocationInterlockEXT") < spvasm.index("OpEndInvocationInterlockEXT")

def test_a16_sample_gradients_use_full_vgprs(make_shader):
path = os.path.join(ROOT, "runtime", "test", "shaders", "ps_texture_grad_a16.asm")
with open(path, encoding="utf-8") as fixture:
Expand Down