mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 21:10:42 +00:00
Add functions to check vertex input data as well as vertex output data
This commit is contained in:
@@ -84,6 +84,34 @@ class MeshAttribute:
|
||||
name: str
|
||||
|
||||
|
||||
def get_vsin_attrs(controller: rd.ReplayController, index_mesh: rd.MeshFormat):
|
||||
pipe: rd.PipeState = controller.GetPipelineState()
|
||||
inputs: List[rd.VertexInputAttribute] = pipe.GetVertexInputs()
|
||||
|
||||
attrs: List[MeshAttribute] = []
|
||||
vbs: List[rd.BoundVBuffer] = pipe.GetVBuffers()
|
||||
|
||||
for a in inputs:
|
||||
if not a.used:
|
||||
continue
|
||||
|
||||
attr = MeshAttribute()
|
||||
attr.name = a.name
|
||||
attr.mesh = rd.MeshFormat(index_mesh)
|
||||
|
||||
attr.mesh.vertexByteStride = vbs[a.vertexBuffer].byteStride
|
||||
attr.mesh.instStepRate = a.instanceRate
|
||||
attr.mesh.instanced = a.perInstance
|
||||
attr.mesh.vertexResourceId = vbs[a.vertexBuffer].resourceId
|
||||
attr.mesh.vertexByteOffset = vbs[a.vertexBuffer].byteOffset + a.byteOffset
|
||||
|
||||
attr.mesh.format = a.format
|
||||
|
||||
attrs.append(attr)
|
||||
|
||||
return attrs
|
||||
|
||||
|
||||
def get_postvs_attrs(controller: rd.ReplayController, mesh: rd.MeshFormat, data_stage: rd.MeshDataStage):
|
||||
pipe: rd.PipeState = controller.GetPipelineState()
|
||||
|
||||
|
||||
@@ -221,6 +221,29 @@ class TestCase:
|
||||
|
||||
return self._find_draw(name, start_event, self.controller.GetDrawcalls())
|
||||
|
||||
def get_vsin(self, draw: rd.DrawcallDescription, first_index: int=0, num_indices: int=0, instance: int=0, view: int=0):
|
||||
ib: rd.BoundVBuffer = self.controller.GetPipelineState().GetIBuffer()
|
||||
|
||||
if num_indices == 0:
|
||||
num_indices = draw.numIndices
|
||||
else:
|
||||
num_indices = min(num_indices, draw.numIndices)
|
||||
|
||||
mesh = rd.MeshFormat()
|
||||
mesh.numIndices = num_indices
|
||||
mesh.indexByteOffset = ib.byteOffset + draw.indexOffset * draw.indexByteWidth
|
||||
mesh.indexByteStride = draw.indexByteWidth
|
||||
mesh.indexResourceId = ib.resourceId
|
||||
mesh.baseVertex = draw.baseVertex
|
||||
|
||||
attrs = analyse.get_vsin_attrs(self.controller, mesh)
|
||||
|
||||
first_index = min(first_index, draw.numIndices-1)
|
||||
|
||||
indices = analyse.fetch_indices(self.controller, mesh, 0, first_index, num_indices)
|
||||
|
||||
return analyse.decode_mesh_data(self.controller, indices, attrs, 0)
|
||||
|
||||
def get_postvs(self, data_stage: rd.MeshDataStage, first_index: int=0, num_indices: int=0, instance: int=0, view: int=0):
|
||||
mesh: rd.MeshFormat = self.controller.GetPostVSData(instance, view, data_stage)
|
||||
|
||||
@@ -244,16 +267,16 @@ class TestCase:
|
||||
for idx in mesh_ref:
|
||||
ref = mesh_ref[idx]
|
||||
if idx >= len(mesh_data):
|
||||
raise TestFailureException('PostVS data doesn\'t have expected element {}'.format(idx))
|
||||
raise TestFailureException('Mesh data doesn\'t have expected element {}'.format(idx))
|
||||
|
||||
data = mesh_data[idx]
|
||||
|
||||
for key in ref:
|
||||
if key not in data:
|
||||
raise TestFailureException('PostVS data[{}] doesn\'t contain data {} as expected. Data is: {}'.format(idx, key, list(data.keys())))
|
||||
raise TestFailureException('Mesh data[{}] doesn\'t contain data {} as expected. Data is: {}'.format(idx, key, list(data.keys())))
|
||||
|
||||
if not util.value_compare(ref[key], data[key]):
|
||||
raise TestFailureException('PostVS data[{}] \'{}\': {} is not as expected: {}'.format(idx, key, data[key], ref[key]))
|
||||
raise TestFailureException('Mesh data[{}] \'{}\': {} is not as expected: {}'.format(idx, key, data[key], ref[key]))
|
||||
|
||||
log.success("Mesh data is identical to reference")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user