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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
import renderdoc as rd
import struct
import rdtest
class VK_Misaligned_Dirty(rdtest.TestCase):
demos_test_name = 'VK_Misaligned_Dirty'
def get_capture_options(self):
opts = rdtest.TestCase.get_capture_options(self)
opts.apiValidation = True
return opts
def get_replay_options(self):
opts = rdtest.TestCase.get_replay_options(self)
# Set a balanced optimisation level to ensure that written ranges are cleared instead of being either restored
# or ignored
opts.optimisation = rd.ReplayOptimisationLevel.Balanced
return opts
def check_capture(self):
action = self.find_action("Draw")
self.check(action is not None)
self.controller.SetFrameEvent(action.eventId, False)
self.check(len(self.controller.GetFrameInfo().debugMessages) == 0)
self.check(len(self.controller.GetDebugMessages()) == 0)
rdtest.log.success("No debug messages found")
pipe: rd.PipeState = self.controller.GetPipelineState()
postvs_data = self.get_postvs(action, rd.MeshDataStage.VSOut, 0, action.numIndices)
val = 2.0 / 3.0
postvs_ref = {
0: {
'vtx': 0,
'idx': 0,
'gl_PerVertex_var.gl_Position': [-val, val, val, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
},
1: {
'vtx': 1,
'idx': 1,
'gl_PerVertex_var.gl_Position': [0.0, -val, val, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
},
2: {
'vtx': 2,
'idx': 2,
'gl_PerVertex_var.gl_Position': [val, val, val, 1.0],
'vertOut.col': [0.0, 1.0, 0.0, 1.0],
},
}
self.check_mesh_data(postvs_ref, postvs_data)
rdtest.log.success("vertex output is as expected")
tex = pipe.GetOutputTargets()[0].resourceId
texdetails = self.get_texture(tex)
coords = [
[int(texdetails.width * 1 / 3) + 5, int(texdetails.height * 2 / 3) - 5],
[int(texdetails.width * 1 / 2) + 0, int(texdetails.height * 1 / 3) + 5],
[int(texdetails.width * 2 / 3) + 5, int(texdetails.height * 2 / 3) - 5],
]
for coord in coords:
self.check_pixel_value(tex, coord[0], coord[1], [0.0, 1.0, 0.0, 1.0])
rdtest.log.success("picked values are as expected")
checkpoint1 = self.find_action("First Submit")
checkpoint2 = self.find_action("Second Submit")
checkpoint3 = self.find_action("Third Submit")
self.check(checkpoint1 is not None)
self.check(checkpoint2 is not None)
self.check(checkpoint3 is not None)
resources = self.controller.GetResources()
copy_src = None
vb = None
for r in resources:
if r.name == 'copy_src':
copy_src = r.resourceId
elif r.name == 'vb':
vb = r.resourceId
self.check(copy_src is not None)
self.check(vb is not None)
self.controller.SetFrameEvent(checkpoint1.eventId, False)
val = struct.unpack('f', self.controller.GetBufferData(copy_src, 116, 4))
self.check(val[0] == 11.0)
self.controller.SetFrameEvent(checkpoint2.eventId, False)
val = struct.unpack('f', self.controller.GetBufferData(copy_src, 116, 4))
self.check(val[0] == 12.0)
val = struct.unpack('f', self.controller.GetBufferData(vb, 116, 4))
self.check(val[0] == 12.0)
self.controller.SetFrameEvent(checkpoint3.eventId, False)
val = struct.unpack('f', self.controller.GetBufferData(copy_src, 116, 4))
self.check(val[0] == 11.0)
rdtest.log.success("buffers have correct values in both submits")
|