Don't apply restart index if primitive restart is disabled

This commit is contained in:
baldurk
2020-05-20 11:20:13 +01:00
parent c93d92467d
commit 47f2fa8b93
3 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -55,7 +55,7 @@ def open_capture(filename="", cap: rd.CaptureFile=None, opts: rd.ReplayOptions=N
return controller
def fetch_indices(controller: rd.ReplayController, mesh: rd.MeshFormat, index_offset: int, first_index: int, num_indices: int):
def fetch_indices(controller: rd.ReplayController, draw: rd.DrawcallDescription, mesh: rd.MeshFormat, index_offset: int, first_index: int, num_indices: int):
# Get the character for the width of index
index_fmt = 'B'
if mesh.indexByteStride == 2:
@@ -65,6 +65,7 @@ def fetch_indices(controller: rd.ReplayController, mesh: rd.MeshFormat, index_of
pipe = controller.GetPipelineState()
restart_idx = pipe.GetStripRestartIndex() & ((1 << (mesh.indexByteStride*8)) - 1)
restart_enabled = pipe.IsStripRestartEnabled() and rd.IsStrip(draw.topology)
# Duplicate the format by the number of indices
index_fmt = '=' + str(num_indices) + index_fmt
@@ -80,7 +81,7 @@ def fetch_indices(controller: rd.ReplayController, mesh: rd.MeshFormat, index_of
indices = struct.unpack_from(index_fmt, ibdata)
# Apply the baseVertex offset
return [i if i == restart_idx else i + mesh.baseVertex for i in indices]
return [i if restart_enabled and i == restart_idx else i + mesh.baseVertex for i in indices]
else:
# With no index buffer, just generate a range
return tuple(range(first_index, first_index + num_indices))
+3 -3
View File
@@ -275,7 +275,7 @@ class TestCase:
first_index = min(first_index, draw.numIndices-1)
indices = analyse.fetch_indices(self.controller, mesh, 0, first_index, num_indices)
indices = analyse.fetch_indices(self.controller, draw, mesh, 0, first_index, num_indices)
return analyse.decode_mesh_data(self.controller, indices, indices, attrs, 0, 0)
@@ -307,8 +307,8 @@ class TestCase:
in_mesh.indexByteStride = 0
in_mesh.indexResourceId = rd.ResourceId.Null()
indices = analyse.fetch_indices(self.controller, mesh, 0, first_index, num_indices)
in_indices = analyse.fetch_indices(self.controller, in_mesh, 0, first_index, num_indices)
indices = analyse.fetch_indices(self.controller, draw, mesh, 0, first_index, num_indices)
in_indices = analyse.fetch_indices(self.controller, draw, in_mesh, 0, first_index, num_indices)
attrs = analyse.get_postvs_attrs(self.controller, mesh, data_stage)
+1 -1
View File
@@ -86,7 +86,7 @@ class Iter_Test(rdtest.TestCase):
mesh.indexByteOffset = ib.byteOffset + draw.indexOffset * draw.indexByteWidth
mesh.baseVertex = draw.baseVertex
indices = rdtest.fetch_indices(self.controller, mesh, 0, vtx, 1)
indices = rdtest.fetch_indices(self.controller, draw, mesh, 0, vtx, 1)
if len(indices) < 1:
rdtest.log.print("No index buffer, skipping")