File: GL_Resource_Lifetimes.py

package info (click to toggle)
renderdoc 1.27%2Bdfsg-1
  • links: PTS, VCS
  • area: non-free
  • in suites: sid
  • size: 107,796 kB
  • sloc: cpp: 763,519; ansic: 326,847; python: 26,946; xml: 23,189; java: 11,382; cs: 7,181; makefile: 6,707; yacc: 5,682; ruby: 4,648; perl: 3,461; sh: 2,381; php: 2,119; lisp: 1,835; javascript: 1,525; tcl: 1,068; ml: 747
file content (79 lines) | stat: -rw-r--r-- 3,703 bytes parent folder | download | duplicates (2)
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
import renderdoc as rd
import rdtest


class GL_Resource_Lifetimes(rdtest.TestCase):
    demos_test_name = 'GL_Resource_Lifetimes'
    demos_frame_cap = 200

    def check_capture(self):
        action: rd.ActionDescription = self.find_action("glDraw")

        self.controller.SetFrameEvent(action.eventId, True)

        mapping: rd.ShaderBindpointMapping = self.controller.GetPipelineState().GetBindpointMapping(rd.ShaderStage.Vertex)
        self.check(mapping.readWriteResources[0].bind == 3)

        mapping: rd.ShaderBindpointMapping = self.controller.GetPipelineState().GetBindpointMapping(rd.ShaderStage.Pixel)
        self.check(mapping.readWriteResources[0].bind == 3)

        action: rd.ActionDescription = self.find_action("glDraw", action.eventId+1)

        self.controller.SetFrameEvent(action.eventId, True)

        mapping: rd.ShaderBindpointMapping = self.controller.GetPipelineState().GetBindpointMapping(rd.ShaderStage.Vertex)
        self.check(mapping.readWriteResources[0].bind == 3)

        mapping: rd.ShaderBindpointMapping = self.controller.GetPipelineState().GetBindpointMapping(rd.ShaderStage.Pixel)
        self.check(mapping.readWriteResources[0].bind == 3)

        last_action: rd.ActionDescription = self.get_last_action()

        self.controller.SetFrameEvent(last_action.eventId, True)

        tex = last_action.copyDestination

        # green background around first triangle, blue around second
        self.check_pixel_value(tex, 10, 10, [0.0, 1.0, 0.0, 1.0])
        self.check_pixel_value(tex, 118, 10, [0.0, 1.0, 0.0, 1.0])
        self.check_pixel_value(tex, 118, 118, [0.0, 1.0, 0.0, 1.0])
        self.check_pixel_value(tex, 10, 118, [0.0, 1.0, 0.0, 1.0])

        self.check_pixel_value(tex, 138, 10, [0.0, 0.0, 1.0, 1.0])
        self.check_pixel_value(tex, 246, 10, [0.0, 0.0, 1.0, 1.0])
        self.check_pixel_value(tex, 246, 118, [0.0, 0.0, 1.0, 1.0])
        self.check_pixel_value(tex, 138, 118, [0.0, 0.0, 1.0, 1.0])

        # Sample across each triangle, we expect things to be identical
        for xoffs in [0, 128]:
            # Check black checkerboard squares
            self.check_pixel_value(tex, xoffs+42, 92, [0.0, 0.0, 0.0, 1.0])
            self.check_pixel_value(tex, xoffs+40, 85, [0.0, 0.0, 0.0, 1.0])
            self.check_pixel_value(tex, xoffs+68, 66, [0.0, 0.0, 0.0, 1.0])
            self.check_pixel_value(tex, xoffs+59, 47, [0.0, 0.0, 0.0, 1.0])
            self.check_pixel_value(tex, xoffs+81, 92, [0.0, 0.0, 0.0, 1.0])

            # Check the red and green eyes of the smiley
            self.check_pixel_value(tex, xoffs+49, 83, [1.0, 0.0, 0.09, 1.0])
            self.check_pixel_value(tex, xoffs+60, 83, [0.0, 1.0, 0.09, 1.0])

            # Check the blue smile
            self.check_pixel_value(tex, xoffs+64, 72, [0.09, 0.0, 1.0, 1.0])

            # Check the orange face
            self.check_pixel_value(tex, xoffs+46, 86, [1.0, 0.545, 0.36, 1.0])

            # Check the empty space where we clamped and didn't repeat
            self.check_pixel_value(tex, xoffs+82, 79, [0.72, 1.0, 1.0, 1.0])
            self.check_pixel_value(tex, xoffs+84, 86, [0.72, 1.0, 1.0, 1.0])
            self.check_pixel_value(tex, xoffs+88, 92, [0.72, 1.0, 1.0, 1.0])

            # Check that the repeated smiley above is there
            self.check_pixel_value(tex, xoffs+67, 53, [0.905, 0.635, 0.36, 1.0])
            self.check_pixel_value(tex, xoffs+65, 50, [1.0, 0.0, 0.09, 1.0])

        # Check for resource leaks
        if len(self.controller.GetResources()) > 75:
            raise rdtest.TestFailureException(
                "Too many resources found: {}".format(len(self.controller.GetResources())))