Make code more robust if indexed draw has unbound ibuffer. Closes #1085

This commit is contained in:
baldurk committed 2018-08-28 18:23:57 +01:00
1 parent d24c53c7e0
commit 5024f80ee9
3 files changed
+10 -7

No files matched your search

+1 -1
View File
@@ -2349,7 +2349,7 @@ void BufferViewer::configureMeshColumns()
// drawing more than this many indices will read off the end of the index buffer - which while
// technically not invalid is certainly not intended, so serves as a good 'upper bound'
numRowsUpperBound = bytesAvailable / draw->indexByteWidth;
numRowsUpperBound = bytesAvailable / qMax(1U, draw->indexByteWidth);
}
else
{
+4 -3
View File
@@ -371,8 +371,9 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId)
else // drawcall is indexed
{
bytebuf idxdata;
GetBufferData(rs.ibuffer.buf, rs.ibuffer.offs + drawcall->indexOffset * rs.ibuffer.bytewidth,
RDCMIN(drawcall->numIndices * rs.ibuffer.bytewidth, rs.ibuffer.size), idxdata);
if(rs.ibuffer.buf != ResourceId())
GetBufferData(rs.ibuffer.buf, rs.ibuffer.offs + drawcall->indexOffset * rs.ibuffer.bytewidth,
RDCMIN(drawcall->numIndices * rs.ibuffer.bytewidth, rs.ibuffer.size), idxdata);
vector<uint32_t> indices;
@@ -381,7 +382,7 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId)
// only read as many indices as were available in the buffer
uint32_t numIndices =
RDCMIN(uint32_t(idxdata.size() / rs.ibuffer.bytewidth), drawcall->numIndices);
RDCMIN(uint32_t(idxdata.size() / RDCMAX(1, rs.ibuffer.bytewidth)), drawcall->numIndices);
uint32_t idxclamp = 0;
if(drawcall->baseVertex < 0)
+5 -3
View File
@@ -1197,8 +1197,9 @@ void VulkanReplay::InitPostVSBuffers(uint32_t eventId)
uint32_t *idx32 = NULL;
// fetch ibuffer
GetBufferData(state.ibuffer.buf, state.ibuffer.offs + drawcall->indexOffset * idxsize,
uint64_t(drawcall->numIndices) * idxsize, idxdata);
if(state.ibuffer.buf != ResourceId())
GetBufferData(state.ibuffer.buf, state.ibuffer.offs + drawcall->indexOffset * idxsize,
uint64_t(drawcall->numIndices) * idxsize, idxdata);
// figure out what the maximum index could be, so we can clamp our index buffer to something
// sane
@@ -1463,7 +1464,8 @@ void VulkanReplay::InitPostVSBuffers(uint32_t eventId)
offs += drawcall->vertexOffset * vi->pVertexBindingDescriptions[vb].stride;
}
GetBufferData(state.vbuffers[vb].buf, offs, len, origVBs[vb]);
if(state.vbuffers[vb].buf != ResourceId())
GetBufferData(state.vbuffers[vb].buf, offs, len, origVBs[vb]);
}
for(uint32_t i = 0; i < vi->vertexAttributeDescriptionCount; i++)