File: GL_Shader_ISA.py

package info (click to toggle)
renderdoc 1.11%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 93,988 kB
  • sloc: cpp: 662,188; ansic: 350,046; python: 22,871; xml: 14,473; java: 11,365; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; sh: 2,277; php: 2,119; lisp: 1,835; javascript: 1,524; tcl: 1,068; ml: 747
file content (85 lines) | stat: -rw-r--r-- 3,428 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import renderdoc as rd
from typing import List
import rdtest


class GL_Shader_ISA(rdtest.TestCase):
    demos_test_name = 'GL_Shader_ISA'

    def check_capture(self):
        draw = self.find_draw("GPU=")

        self.check(draw is not None)

        is_amd = 'AMD' in draw.name

        self.controller.SetFrameEvent(draw.next.eventId, False)

        pipe: rd.PipeState = self.controller.GetPipelineState()

        refl: rd.ShaderReflection = pipe.GetShaderReflection(rd.ShaderStage.Vertex)

        isas: List[str] = 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 isa == 'AMDIL'):
                rdtest.log.print("Skipping {} as we know it will fail".format(isa))
                continue

            disasm: str = self.controller.DisassembleShader(pipe.GetGraphicsPipelineObject(), refl, isa)

            if len(disasm) < 32:
                raise rdtest.TestFailureException("Disassembly for target '{}' is degenerate: {}".format(isa, 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: str = 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(
                        "AMDIL ISA doesn't contain '{}' as expected: {}".format(fragment, disasm))

            if 'RDNA (Navi 10)' not in isas:
                raise rdtest.TestFailureException(
                    "RDNA (Navi 10) is not an available disassembly target. Are you missing plugins?")

            disasm: str = self.controller.DisassembleShader(pipe.GetGraphicsPipelineObject(), refl, 'RDNA (Navi 10)')

            expected = [
                'asic(GFX10)',
                'vgpr_count',
                'wave_size',
                's_endpgm',
            ]

            for fragment in expected:
                if not fragment in disasm:
                    raise rdtest.TestFailureException(
                        "RDNA ISA doesn't contain '{}' as expected: {}".format(fragment, 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")