Files
renderdoc/util/test/tests/GL/GL_Shader_ISA.py
T
baldurk 748e089b15 Fix remaining static analysis identified issues in python test code
* This includes:
  - Incorrect comparisons
  - Missing type annotations where it can't be inferred
  - Variable shadowing and bad use
  - Unused imports
  - asserts for non-None on types
* Passes clean on strict pyright checking except for
  `reportMissingParameterType`, `reportUnusedVariable`, and
  `reportOptionalMemberAccess` which are all too spammy and low value to be
  worth addressing.
2026-09-11 15:04:05 +01:00

86 lines
3.3 KiB
Python

import renderdoc as rd
import rdtest
class GL_Shader_ISA(rdtest.TestCase):
demos_test_name = 'GL_Shader_ISA'
def check_capture(self):
action = self.find_action("GPU=")
assert action is not None
is_amd = 'AMD' in action.customName
self.controller.SetFrameEvent(action.nextAction.eventId, False)
pipe = self.controller.GetPipelineState()
refl = pipe.GetShaderReflection(rd.ShaderStage.Vertex)
assert refl is not None
isas = self.controller.GetDisassemblyTargets(True)
if isas == []:
raise rdtest.TestFailureException("Expected some disassembly targets, got none!")
# Generic testing can't do much, we just ensure that we can successfully get a non-empty disassembly string
for isa in isas:
# The AMD disassembler does an audible ping when it fails, so skip ones we know won't work
if not is_amd and ('GCN (' in isa or 'RDNA (' in isa or 'RDNA2 (' in isa or isa == 'AMDIL'):
rdtest.log.print(f"Skipping {isa} as we know it will fail")
continue
disasm = self.controller.DisassembleShader(pipe.GetGraphicsPipelineObject(), refl, isa)
if len(disasm) < 32:
raise rdtest.TestFailureException(f"Disassembly for target '{isa}' is degenerate: {disasm}")
rdtest.log.success("All disassembly targets successfully fetched and seem reasonable")
# Unfortunately AMD's GL shader compiler can't be used offline, so only test this on AMD replay
if not is_amd:
rdtest.log.print("Not testing GCN disassembly outside AMD")
else:
# We make this a hard failure. Users can fix this by installing the plugins, and we don't want automated
# overnight tests to suddenly stop checking
if 'AMDIL' not in isas:
raise rdtest.TestFailureException(
"AMDIL is not an available disassembly target. Are you missing plugins?")
disasm = self.controller.DisassembleShader(pipe.GetGraphicsPipelineObject(), refl, 'AMDIL')
expected = [
'il_vs',
'dcl_output_position',
'end',
]
for fragment in expected:
if not fragment in disasm:
raise rdtest.TestFailureException(
f"AMDIL ISA doesn't contain '{fragment}' as expected: {disasm}")
if 'RDNA (gfx1010)' not in isas:
raise rdtest.TestFailureException(
"RDNA (gfx1010) is not an available disassembly target. Are you missing plugins?")
disasm = self.controller.DisassembleShader(pipe.GetGraphicsPipelineObject(), refl, 'RDNA (gfx1010)')
expected = [
'asic(GFX10)',
'vgpr_count',
'wave_size',
's_endpgm',
]
for fragment in expected:
if not fragment in disasm:
raise rdtest.TestFailureException(
f"RDNA ISA doesn't contain '{fragment}' as expected: {disasm}")
rdtest.log.success("AMD disassembly is as expected")
# There's no live driver disassembly on GL
rdtest.log.print("No Live driver disassembly to test on GL")