File: D3D11_Pixel_History_Zoo.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 (74 lines) | stat: -rw-r--r-- 3,370 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
import renderdoc as rd
import rdtest
from typing import List


class D3D11_Pixel_History_Zoo(rdtest.TestCase):
    slow_test = True
    demos_test_name = 'D3D11_Pixel_History_Zoo'

    def check_capture(self):
        draws = self.controller.GetDrawcalls()

        for d in self.controller.GetDrawcalls():
            # Only process test draws
            if not d.name.startswith('Test'):
                continue

            # Go to the last child draw
            self.controller.SetFrameEvent(d.children[-1].eventId, True)

            if any(['UInt tex' in d.name for d in d.children]):
                value_selector = lambda x: x.uintValue
                shader_out = (0, 1, 1234, 5)
            elif any(['SInt tex' in d.name for d in d.children]):
                value_selector = lambda x: x.intValue
                shader_out = (0, 1, -1234, 5)
            else:
                value_selector = lambda x: x.floatValue
                shader_out = (0.0, 1.0, 0.1234, 0.5)

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

            rt: rd.BoundResource = pipe.GetOutputTargets()[0]

            vp: rd.Viewport = pipe.GetViewport(0)

            tex = rt.resourceId
            x, y = (int(vp.width / 2), int(vp.height / 2))

            tex_details = self.get_texture(tex)

            sub = rd.Subresource()
            if tex_details.arraysize > 1:
                sub.slice = rt.firstSlice
            if tex_details.mips > 1:
                sub.mip = rt.firstMip

            modifs: List[rd.PixelModification] = self.controller.PixelHistory(tex, x, y, sub, rt.typeCast)

            # Should be at least two modifications in every test - clear and draw
            self.check(len(modifs) >= 2)

            # Check that the modifications are self consistent - postmod of each should match premod of the next
            for i in range(len(modifs) - 1):
                if value_selector(modifs[i].postMod.col) != value_selector(modifs[i + 1].preMod.col):
                    raise rdtest.TestFailureException(
                        "postmod at {}: {} doesn't match premod at {}: {}".format(modifs[i].eventId,
                                                                                  value_selector(modifs[i].postMod.col),
                                                                                  modifs[i + 1].eventId,
                                                                                  value_selector(modifs[i].preMod.col)))

                if self.get_draw(modifs[i].eventId).flags & rd.DrawFlags.Drawcall:
                    if not rdtest.value_compare(value_selector(modifs[i].shaderOut.col), shader_out):
                        raise rdtest.TestFailureException(
                            "Shader output {} isn't as expected {}".format(value_selector(modifs[i].shaderOut.col),
                                                                           shader_out))

            rdtest.log.success("shader output and premod/postmod is consistent")

            # The current pixel value should match the last postMod
            self.check_pixel_value(tex, x, y, value_selector(modifs[-1].postMod.col), sub=sub, cast=rt.typeCast)

            # Also the red channel should be zero, as it indicates errors
            self.check(float(value_selector(modifs[-1].postMod.col)[0]) == 0.0)