Handle baseVertex as signed, separately from vertexOffset. Refs #228

This commit is contained in:
baldurk
2016-03-24 18:50:04 +01:00
parent 6e4f9f44b3
commit 5869e9c1bf
14 changed files with 210 additions and 51 deletions
+1
View File
@@ -35,6 +35,7 @@ struct MeshFormat
ResourceId idxbuf;
uint64_t idxoffs;
uint32_t idxByteWidth;
int32_t baseVertex;
ResourceId buf;
uint64_t offset;
+2
View File
@@ -184,6 +184,7 @@ struct FetchDrawcall
numIndices = 0;
numInstances = 0;
indexOffset = 0;
baseVertex = 0;
vertexOffset = 0;
instanceOffset = 0;
@@ -214,6 +215,7 @@ struct FetchDrawcall
uint32_t numIndices;
uint32_t numInstances;
int32_t baseVertex;
uint32_t indexOffset;
uint32_t vertexOffset;
uint32_t instanceOffset;
+3 -1
View File
@@ -1020,6 +1020,7 @@ void Serialiser::Serialise(const char *name, FetchDrawcall &el)
Serialise("", el.numIndices);
Serialise("", el.numInstances);
Serialise("", el.baseVertex);
Serialise("", el.indexOffset);
Serialise("", el.vertexOffset);
Serialise("", el.instanceOffset);
@@ -1045,7 +1046,7 @@ void Serialiser::Serialise(const char *name, FetchDrawcall &el)
Serialise("", el.events);
Serialise("", el.children);
SIZE_CHECK(FetchDrawcall, 208);
SIZE_CHECK(FetchDrawcall, 216);
}
template<>
@@ -1076,6 +1077,7 @@ void Serialiser::Serialise(const char *name, MeshFormat &el)
Serialise("", el.idxbuf);
Serialise("", el.idxoffs);
Serialise("", el.idxByteWidth);
Serialise("", el.baseVertex);
Serialise("", el.buf);
Serialise("", el.offset);
Serialise("", el.stride);
+1 -1
View File
@@ -6136,7 +6136,7 @@ vector<PixelModification> D3D11DebugManager::PixelHistory(uint32_t frameID, vect
m_pImmediateContext->DrawIndexedInstanced(Topology_NumVerticesPerPrimitive(draw->topology),
RDCMAX(1U, draw->numInstances),
draw->indexOffset + Topology_VertexOffset(draw->topology, history[h].primitiveID),
draw->vertexOffset, draw->instanceOffset);
draw->baseVertex, draw->instanceOffset);
}
else
{
+22 -12
View File
@@ -3447,7 +3447,7 @@ bool WrappedID3D11DeviceContext::Serialise_DrawIndexedInstanced(UINT IndexCountP
draw.numIndices = IndexCountPerInstance;
draw.numInstances = InstanceCount;
draw.indexOffset = StartIndexLocation;
draw.vertexOffset = BaseVertexLocation;
draw.baseVertex = BaseVertexLocation;
draw.instanceOffset = StartInstanceLocation;
draw.flags |= eDraw_Drawcall|eDraw_Instanced|eDraw_UseIBuffer;
@@ -3567,7 +3567,7 @@ bool WrappedID3D11DeviceContext::Serialise_DrawIndexed(UINT IndexCount_, UINT St
FetchDrawcall draw;
draw.name = name;
draw.numIndices = IndexCount;
draw.vertexOffset = BaseVertexLocation;
draw.baseVertex = BaseVertexLocation;
draw.indexOffset = StartIndexLocation;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
@@ -3787,19 +3787,29 @@ bool WrappedID3D11DeviceContext::Serialise_DrawIndexedInstancedIndirect(ID3D11Bu
if(m_pDevice->GetResourceManager()->HasLiveResource(BufferForArgs))
{
ID3D11Buffer *argBuffer = (ID3D11Buffer *)m_pDevice->GetResourceManager()->GetLiveResource(BufferForArgs);
vector<byte> argarray;
m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 5*sizeof(uint32_t), argarray, true);
vector<byte> args;
m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 5*sizeof(uint32_t), args, true);
uint32_t *uargs = (uint32_t *)&args[0];
struct DrawArgs
{
uint32_t IndexCountPerInstance;
uint32_t InstanceCount;
uint32_t StartIndexLocation;
int32_t BaseVertexLocation;
uint32_t StartInstanceLocation;
};
name = "DrawIndexedInstancedIndirect(<" + ToStr::Get(uargs[0])
+ ", " + ToStr::Get(uargs[1]) + ">)";
DrawArgs *args = (DrawArgs *)&argarray[0];
draw.numIndices = uargs[0];
draw.numInstances = uargs[1];
draw.indexOffset = uargs[2];
draw.vertexOffset = uargs[3];
draw.instanceOffset = uargs[4];
draw.numIndices = args->IndexCountPerInstance;
draw.numInstances = args->InstanceCount;
draw.indexOffset = args->StartIndexLocation;
draw.baseVertex = args->BaseVertexLocation;
draw.instanceOffset = args->StartInstanceLocation;
name = "DrawIndexedInstancedIndirect(<" + ToStr::Get(draw.numIndices)
+ ", " + ToStr::Get(draw.numInstances) + ">)";
}
draw.name = name;
+50 -15
View File
@@ -3654,6 +3654,7 @@ MeshFormat D3D11DebugManager::GetPostVSBuffers(uint32_t frameID, uint32_t eventI
ret.idxbuf = ResourceId();
ret.idxoffs = 0;
ret.idxByteWidth = s.idxFmt == DXGI_FORMAT_R16_UINT ? 2 : 4;
ret.baseVertex = 0;
if(s.buf)
ret.buf = ((WrappedID3D11Buffer *)s.buf)->GetResourceID();
@@ -3868,11 +3869,23 @@ void D3D11DebugManager::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
// only read as many indices as were available in the buffer
uint32_t numIndices = RDCMIN(uint32_t(index16 ? idxdata.size()/2 : idxdata.size()/4), drawcall->numIndices);
uint32_t idxclamp = 0;
if(drawcall->baseVertex < 0)
idxclamp = uint32_t(-drawcall->baseVertex);
// grab all unique vertex indices referenced
for(uint32_t i=0; i < numIndices; i++)
{
uint32_t i32 = index16 ? uint32_t(idx16[i]) : idx32[i];
// apply baseVertex but clamp to 0 (don't allow index to become negative)
if(i32 < idxclamp)
i32 = 0;
else if(drawcall->baseVertex < 0)
i32 -= idxclamp;
else if(drawcall->baseVertex > 0)
i32 += drawcall->baseVertex;
auto it = std::lower_bound(indices.begin(), indices.end(), i32);
if(it != indices.end() && *it == i32)
@@ -3919,24 +3932,31 @@ void D3D11DebugManager::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
SAFE_RELEASE(idxBuf);
if(drawcall->flags & eDraw_Instanced)
m_pImmediateContext->DrawIndexedInstanced((UINT)indices.size(), drawcall->numInstances, 0, drawcall->vertexOffset, drawcall->instanceOffset);
m_pImmediateContext->DrawIndexedInstanced((UINT)indices.size(), drawcall->numInstances, 0, 0, drawcall->instanceOffset);
else
m_pImmediateContext->DrawIndexed((UINT)indices.size(), 0, drawcall->vertexOffset);
m_pImmediateContext->DrawIndexed((UINT)indices.size(), 0, 0);
m_pImmediateContext->IASetPrimitiveTopology(topo);
m_pImmediateContext->IASetIndexBuffer(UNWRAP(WrappedID3D11Buffer, origBuf), idxFmt, idxOffs);
// rebase existing index buffer to point to the right elements in our stream-out'd
// vertex buffer
if(index16)
for(uint32_t i=0; i < numIndices; i++)
{
for(uint32_t i=0; i < numIndices; i++)
idx16[i] = uint16_t(indexRemap[ idx16[i] ]);
}
else
{
for(uint32_t i=0; i < numIndices; i++)
idx32[i] = uint32_t(indexRemap[ idx32[i] ]);
uint32_t i32 = index16 ? uint32_t(idx16[i]) : idx32[i];
// apply baseVertex but clamp to 0 (don't allow index to become negative)
if(i32 < idxclamp)
i32 = 0;
else if(drawcall->baseVertex < 0)
i32 -= idxclamp;
else if(drawcall->baseVertex > 0)
i32 += drawcall->baseVertex;
if(index16)
idx16[i] = uint16_t(indexRemap[ i32 ]);
else
idx32[i] = uint32_t(indexRemap[ i32 ]);
}
desc.ByteWidth = (UINT)idxdata.size();
@@ -4210,11 +4230,11 @@ void D3D11DebugManager::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
if(drawcall->flags & eDraw_Instanced)
{
m_pImmediateContext->DrawIndexedInstanced(drawcall->numIndices, drawcall->numInstances, drawcall->indexOffset,
drawcall->vertexOffset, drawcall->instanceOffset);
drawcall->baseVertex, drawcall->instanceOffset);
}
else
{
m_pImmediateContext->DrawIndexed(drawcall->numIndices, drawcall->indexOffset, drawcall->vertexOffset);
m_pImmediateContext->DrawIndexed(drawcall->numIndices, drawcall->indexOffset, drawcall->baseVertex);
}
}
else
@@ -4692,7 +4712,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, uint32_t eventID, const vec
buf = UNWRAP(WrappedID3D11Buffer, it->second.m_Buffer);
m_pImmediateContext->IASetIndexBuffer(buf, fmt.idxByteWidth == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, (UINT)fmt.idxoffs);
m_pImmediateContext->DrawIndexed(fmt.numVerts, 0, 0);
m_pImmediateContext->DrawIndexed(fmt.numVerts, 0, fmt.baseVertex);
}
else
{
@@ -4772,7 +4792,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, uint32_t eventID, const vec
}
if(cfg.position.idxByteWidth)
m_pImmediateContext->DrawIndexed(cfg.position.numVerts, 0, 0);
m_pImmediateContext->DrawIndexed(cfg.position.numVerts, 0, cfg.position.baseVertex);
else
m_pImmediateContext->Draw(cfg.position.numVerts, 0);
@@ -4802,7 +4822,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, uint32_t eventID, const vec
m_pImmediateContext->IASetPrimitiveTopology(topo);
if(cfg.position.idxByteWidth)
m_pImmediateContext->DrawIndexed(cfg.position.numVerts, 0, 0);
m_pImmediateContext->DrawIndexed(cfg.position.numVerts, 0, cfg.position.baseVertex);
else
m_pImmediateContext->Draw(cfg.position.numVerts, 0);
}
@@ -4888,9 +4908,24 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, uint32_t eventID, const vec
uint32_t numIndices = RDCMIN(cfg.position.numVerts, uint32_t(idxdata.size()/bytesize));
m_HighlightCache.indices.resize(numIndices);
uint32_t sub = uint32_t(-cfg.position.baseVertex);
uint32_t add = uint32_t(cfg.position.baseVertex);
for(uint32_t i=0; i < numIndices; i++)
{
m_HighlightCache.indices[i] = index16 ? uint32_t(idx16[i]) : idx32[i];
if(cfg.position.baseVertex < 0)
{
if(m_HighlightCache.indices[i] < sub)
m_HighlightCache.indices[i] = 0;
else
m_HighlightCache.indices[i] -= sub;
}
else
m_HighlightCache.indices[i] += add;
}
}
}
+1 -1
View File
@@ -162,7 +162,7 @@ struct DrawElementsIndirectCommand
uint32_t count;
uint32_t instanceCount;
uint32_t firstIndex;
uint32_t baseVertex;
int32_t baseVertex;
uint32_t baseInstance;
};
+23 -6
View File
@@ -2698,7 +2698,7 @@ void GLReplay::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
}
else
{
gl.glDrawElementsBaseVertex(eGL_POINTS, (GLsizei)indices.size(), eGL_UNSIGNED_INT, NULL, drawcall->vertexOffset);
gl.glDrawElementsBaseVertex(eGL_POINTS, (GLsizei)indices.size(), eGL_UNSIGNED_INT, NULL, drawcall->baseVertex);
}
// delete the buffer, we don't need it anymore
@@ -3104,12 +3104,12 @@ void GLReplay::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
{
gl.glDrawElementsInstancedBaseVertexBaseInstance(drawtopo, drawcall->numIndices, idxType,
(const void *)uintptr_t(drawcall->indexOffset*drawcall->indexByteWidth), drawcall->numInstances,
drawcall->vertexOffset, drawcall->instanceOffset);
drawcall->baseVertex, drawcall->instanceOffset);
}
else
{
gl.glDrawElementsBaseVertex(drawtopo, drawcall->numIndices, idxType,
(const void *)uintptr_t(drawcall->indexOffset*drawcall->indexByteWidth), drawcall->vertexOffset);
(const void *)uintptr_t(drawcall->indexOffset*drawcall->indexByteWidth), drawcall->baseVertex);
}
}
gl.glEndTransformFeedback();
@@ -3334,6 +3334,7 @@ MeshFormat GLReplay::GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32
ret.idxbuf = ResourceId();
ret.idxoffs = 0;
ret.idxByteWidth = s.idxByteWidth;
ret.baseVertex = 0;
if(s.buf)
ret.buf = m_pDriver->GetResourceManager()->GetID(BufferRes(NULL, s.buf));
@@ -3532,7 +3533,7 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
else if(fmt.idxByteWidth == 4)
idxtype = eGL_UNSIGNED_INT;
gl.glDrawElements(secondarytopo, fmt.numVerts, idxtype, (const void *)uintptr_t(fmt.idxoffs));
gl.glDrawElementsBaseVertex(secondarytopo, fmt.numVerts, idxtype, (const void *)uintptr_t(fmt.idxoffs), fmt.baseVertex);
}
else
{
@@ -3685,7 +3686,7 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
GLuint ib = m_pDriver->GetResourceManager()->GetCurrentResource(cfg.position.idxbuf).name;
gl.glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, ib);
}
gl.glDrawElements(topo, cfg.position.numVerts, idxtype, (const void *)uintptr_t(cfg.position.idxoffs));
gl.glDrawElementsBaseVertex(topo, cfg.position.numVerts, idxtype, (const void *)uintptr_t(cfg.position.idxoffs), cfg.position.baseVertex);
}
else
{
@@ -3728,7 +3729,7 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
GLuint ib = m_pDriver->GetResourceManager()->GetCurrentResource(cfg.position.idxbuf).name;
gl.glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, ib);
}
gl.glDrawElements(topo != eGL_PATCHES ? topo : eGL_POINTS, cfg.position.numVerts, idxtype, (const void *)uintptr_t(cfg.position.idxoffs));
gl.glDrawElementsBaseVertex(topo != eGL_PATCHES ? topo : eGL_POINTS, cfg.position.numVerts, idxtype, (const void *)uintptr_t(cfg.position.idxoffs), cfg.position.baseVertex);
}
else
{
@@ -3876,6 +3877,22 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
for(uint32_t i=0; i < numIndices; i++)
m_HighlightCache.indices[i] = idx32[i];
}
uint32_t sub = uint32_t(-cfg.position.baseVertex);
uint32_t add = uint32_t(cfg.position.baseVertex);
for(uint32_t i=0; cfg.position.baseVertex != 0 && i < numIndices; i++)
{
if(cfg.position.baseVertex < 0)
{
if(m_HighlightCache.indices[i] < sub)
m_HighlightCache.indices[i] = 0;
else
m_HighlightCache.indices[i] -= sub;
}
else
m_HighlightCache.indices[i] += add;
}
}
}
@@ -1051,7 +1051,7 @@ bool WrappedOpenGL::Serialise_glDrawElementsIndirect(GLenum mode, GLenum type, c
draw.numIndices = params.count;
draw.numInstances = params.instanceCount;
draw.indexOffset = params.firstIndex;
draw.vertexOffset = params.baseVertex;
draw.baseVertex = params.baseVertex;
draw.instanceOffset = params.baseInstance;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer|eDraw_Instanced|eDraw_Indirect;
@@ -1206,7 +1206,7 @@ bool WrappedOpenGL::Serialise_glDrawRangeElementsBaseVertex(GLenum mode, GLuint
draw.numIndices = Count;
draw.numInstances = 1;
draw.indexOffset = uint32_t(IdxOffset)/IdxSize;
draw.vertexOffset = BaseVtx;
draw.baseVertex = BaseVtx;
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
@@ -1282,7 +1282,7 @@ bool WrappedOpenGL::Serialise_glDrawElementsBaseVertex(GLenum mode, GLsizei coun
draw.numIndices = Count;
draw.numInstances = 1;
draw.indexOffset = uint32_t(IdxOffset)/IdxSize;
draw.vertexOffset = BaseVtx;
draw.baseVertex = BaseVtx;
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
@@ -1513,7 +1513,7 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseVertex(GLenum mode, GLs
draw.numIndices = Count;
draw.numInstances = InstCount;
draw.indexOffset = uint32_t(IdxOffset)/IdxSize;
draw.vertexOffset = BaseVertex;
draw.baseVertex = BaseVertex;
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
@@ -1592,7 +1592,7 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseVertexBaseInstance(GLen
draw.numIndices = Count;
draw.numInstances = InstCount;
draw.indexOffset = uint32_t(IdxOffset)/IdxSize;
draw.vertexOffset = BaseVertex;
draw.baseVertex = BaseVertex;
draw.instanceOffset = BaseInstance;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
@@ -2027,7 +2027,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsBaseVertex(GLenum mode, const G
FetchDrawcall multidraw;
multidraw.numIndices = countArray[i];
multidraw.indexOffset = (uint32_t) uint64_t(idxOffsArray[i])&0xFFFFFFFF;
multidraw.vertexOffset = baseArray[i];
multidraw.baseVertex = baseArray[i];
multidraw.name = "glMultiDrawElementsBaseVertex[" + ToStr::Get(i) + "](" +
ToStr::Get(multidraw.numIndices) + ")";
@@ -2340,7 +2340,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirect(GLenum mode, GLenum ty
multidraw.numIndices = params.count;
multidraw.numInstances = params.instanceCount;
multidraw.indexOffset = params.firstIndex;
multidraw.vertexOffset = params.baseVertex;
multidraw.baseVertex = params.baseVertex;
multidraw.instanceOffset = params.baseInstance;
multidraw.name = "glMultiDrawElementsIndirect[" + ToStr::Get(i) + "](<" +
@@ -2672,7 +2672,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirectCountARB(GLenum mode, G
multidraw.numIndices = params.count;
multidraw.numInstances = params.instanceCount;
multidraw.indexOffset = params.firstIndex;
multidraw.vertexOffset = params.baseVertex;
multidraw.baseVertex = params.baseVertex;
multidraw.instanceOffset = params.baseInstance;
multidraw.name = "glMultiDrawElementsIndirect[" + ToStr::Get(i) + "](" +
+3 -2
View File
@@ -4939,7 +4939,7 @@ void VulkanDebugManager::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
minIndex = indices[0];
maxIndex = indices[ indices.size()-1 ];
vertexIndexOffset = minIndex + drawcall->vertexOffset;
vertexIndexOffset = minIndex + drawcall->baseVertex;
// set numVerts
numVerts = maxIndex - minIndex + 1;
@@ -5248,7 +5248,7 @@ void VulkanDebugManager::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
// do single draw
modifiedstate.BeginRenderPassAndApplyState(cmd);
ObjDisp(cmd)->CmdDrawIndexed(Unwrap(cmd), (uint32_t)indices.size(), drawcall->numInstances, 0, drawcall->vertexOffset, drawcall->instanceOffset);
ObjDisp(cmd)->CmdDrawIndexed(Unwrap(cmd), (uint32_t)indices.size(), drawcall->numInstances, 0, drawcall->baseVertex, drawcall->instanceOffset);
modifiedstate.EndRenderPass(cmd);
// rebase existing index buffer to point to the right elements in our stream-out'd
@@ -5463,6 +5463,7 @@ MeshFormat VulkanDebugManager::GetPostVSBuffers(uint32_t frameID, uint32_t event
ret.idxByteWidth = 0;
}
ret.idxoffs = 0;
ret.baseVertex = 0;
if(s.buf != VK_NULL_HANDLE)
ret.buf = GetResID(s.buf);
+19 -3
View File
@@ -1598,7 +1598,7 @@ void VulkanReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<M
vt->CmdBindIndexBuffer(Unwrap(cmd), Unwrap(ib), fmt.idxoffs, idxtype);
}
vt->CmdDrawIndexed(Unwrap(cmd), fmt.numVerts, 1, 0, 0, 0);
vt->CmdDrawIndexed(Unwrap(cmd), fmt.numVerts, 1, 0, fmt.baseVertex, 0);
}
else
{
@@ -1684,7 +1684,7 @@ void VulkanReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<M
vt->CmdBindIndexBuffer(Unwrap(cmd), Unwrap(ib), cfg.position.idxoffs, idxtype);
}
vt->CmdDrawIndexed(Unwrap(cmd), cfg.position.numVerts, 1, 0, 0, 0);
vt->CmdDrawIndexed(Unwrap(cmd), cfg.position.numVerts, 1, 0, cfg.position.baseVertex, 0);
}
else
{
@@ -1731,7 +1731,7 @@ void VulkanReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<M
vt->CmdBindIndexBuffer(Unwrap(cmd), Unwrap(ib), cfg.position.idxoffs, idxtype);
}
vt->CmdDrawIndexed(Unwrap(cmd), cfg.position.numVerts, 1, 0, 0, 0);
vt->CmdDrawIndexed(Unwrap(cmd), cfg.position.numVerts, 1, 0, cfg.position.baseVertex, 0);
}
else
{
@@ -1962,6 +1962,22 @@ void VulkanReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<M
maxIndex = RDCMAX(maxIndex, (uint64_t)m_HighlightCache.indices[i]);
}
}
uint32_t sub = uint32_t(-cfg.position.baseVertex);
uint32_t add = uint32_t(cfg.position.baseVertex);
for(uint32_t i=0; cfg.position.baseVertex != 0 && i < numIndices; i++)
{
if(cfg.position.baseVertex < 0)
{
if(m_HighlightCache.indices[i] < sub)
m_HighlightCache.indices[i] = 0;
else
m_HighlightCache.indices[i] -= sub;
}
else
m_HighlightCache.indices[i] += add;
}
}
GetBufferData(cfg.position.buf, cfg.position.offset, (maxIndex+1)*cfg.position.stride, m_HighlightCache.data);
@@ -1108,7 +1108,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndexed(
draw.numIndices = idxCount;
draw.numInstances = instCount;
draw.indexOffset = firstIdx;
draw.vertexOffset = vtxOffs;
draw.baseVertex = vtxOffs;
draw.instanceOffset = firstInst;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer|eDraw_Instanced;
@@ -1310,7 +1310,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndexedIndirect(
draw.numIndices = args->indexCount;
draw.numInstances = args->instanceCount;
draw.indexOffset = args->firstIndex;
draw.vertexOffset = args->vertexOffset;
draw.baseVertex = args->vertexOffset;
draw.instanceOffset = args->firstInstance;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer|eDraw_Instanced|eDraw_Indirect;
+2
View File
@@ -336,6 +336,7 @@ namespace renderdoc
public UInt32 numIndices;
public UInt32 numInstances;
public Int32 baseVertex;
public UInt32 indexOffset;
public UInt32 vertexOffset;
public UInt32 instanceOffset;
@@ -380,6 +381,7 @@ namespace renderdoc
public ResourceId idxbuf;
public UInt64 idxoffs;
public UInt32 idxByteWidth;
public Int32 baseVertex;
public ResourceId buf;
public UInt64 offset;
+73
View File
@@ -1177,6 +1177,9 @@ namespace renderdocui.Windows
{
maxIdx = Math.Max(maxIndex, maxIdx);
offset = input.Drawcall.vertexOffset;
if (input.Drawcall.baseVertex > 0)
maxIdx += (uint)input.Drawcall.baseVertex;
}
System.Diagnostics.Debug.Assert(pi != pv || (pi == false && pv == false));
@@ -1497,6 +1500,21 @@ namespace renderdocui.Windows
else
{
index = data.Indices[rownum];
// apply base vertex but clamp to 0 if subtracting
if (input.Drawcall.baseVertex < 0)
{
uint subtract = (uint)(-input.Drawcall.baseVertex);
if (index < subtract)
index = 0;
else
index -= subtract;
}
else if (input.Drawcall.baseVertex > 0)
{
index += (uint)input.Drawcall.baseVertex;
}
}
}
else if ((input.Drawcall.flags & DrawcallFlags.UseIBuffer) != 0 && state == m_VSIn)
@@ -1774,6 +1792,29 @@ namespace renderdocui.Windows
else
{
dataIndex = data.DataIndices[rowIdx];
if (state == m_VSIn)
{
// apply base vertex but clamp to 0 if subtracting
if (input.Drawcall.baseVertex < 0)
{
uint subtract = (uint)(-input.Drawcall.baseVertex);
if (dataIndex < subtract)
{
dataIndex = 0;
outOfBoundsIdx = true;
}
else
{
dataIndex -= subtract;
}
}
else if (input.Drawcall.baseVertex > 0)
{
dataIndex += (uint)input.Drawcall.baseVertex;
}
}
}
}
else if (input.Drawcall != null && (input.Drawcall.flags & DrawcallFlags.UseIBuffer) != 0 &&
@@ -1786,8 +1827,34 @@ namespace renderdocui.Windows
uint displayIndex = dataIndex;
if (data.Indices != null && rowIdx < data.Indices.Length)
{
displayIndex = data.Indices[rowIdx];
if (input.Drawcall != null && (input.Drawcall.flags & DrawcallFlags.UseIBuffer) != 0 &&
(state == m_VSIn || state == m_VSOut))
{
// apply base vertex but clamp to 0 if subtracting
if (input.Drawcall.baseVertex < 0)
{
uint subtract = (uint)(-input.Drawcall.baseVertex);
if (displayIndex < subtract)
{
displayIndex = 0;
outOfBoundsIdx = true;
}
else
{
displayIndex -= subtract;
}
}
else if (input.Drawcall.baseVertex > 0)
{
displayIndex += (uint)input.Drawcall.baseVertex;
}
}
}
object[] rowdata = null;
int x = 0;
@@ -2636,6 +2703,7 @@ namespace renderdocui.Windows
m_MeshDisplay.position.idxbuf = ResourceId.Null;
m_MeshDisplay.position.idxoffs = 0;
m_MeshDisplay.position.idxByteWidth = 0;
m_MeshDisplay.position.baseVertex = 0;
m_MeshDisplay.position.buf = ResourceId.Null;
m_MeshDisplay.position.offset = 0;
@@ -2661,6 +2729,7 @@ namespace renderdocui.Windows
m_MeshDisplay.position.idxbuf = ResourceId.Null;
m_MeshDisplay.position.idxoffs = 0;
m_MeshDisplay.position.idxByteWidth = 0;
m_MeshDisplay.position.baseVertex = 0;
m_MeshDisplay.position.buf = ResourceId.Null;
m_MeshDisplay.position.offset = 0;
@@ -2683,6 +2752,7 @@ namespace renderdocui.Windows
m_MeshDisplay.position.idxoffs = m_VSIn.m_Input.IndexOffset +
ui.m_Input.Drawcall.indexOffset * ui.m_Input.Drawcall.indexByteWidth;
m_MeshDisplay.position.idxByteWidth = ui.m_Input.Drawcall.indexByteWidth;
m_MeshDisplay.position.baseVertex = ui.m_Input.Drawcall.baseVertex;
m_MeshDisplay.position.buf = m_VSIn.m_Input.Buffers[pos.buffer];
m_MeshDisplay.position.offset = pos.offset + ui.m_Input.Offsets[pos.buffer] +
@@ -2697,6 +2767,7 @@ namespace renderdocui.Windows
m_MeshDisplay.position.idxbuf = ui.m_Data.PostVS.idxbuf;
m_MeshDisplay.position.idxoffs = 0;
m_MeshDisplay.position.idxByteWidth = ui.m_Input.Drawcall.indexByteWidth;
m_MeshDisplay.position.baseVertex = ui.m_Data.PostVS.baseVertex;
m_MeshDisplay.position.buf = ui.m_Data.PostVS.buf;
m_MeshDisplay.position.offset = ui.m_Data.PostVS.offset + pos.offset;
@@ -2711,6 +2782,7 @@ namespace renderdocui.Windows
m_MeshDisplay.position.idxbuf = ResourceId.Null;
m_MeshDisplay.position.idxoffs = 0;
m_MeshDisplay.position.idxByteWidth = 0;
m_MeshDisplay.position.baseVertex = 0;
}
else
{
@@ -2734,6 +2806,7 @@ namespace renderdocui.Windows
m_MeshDisplay.secondary.idxbuf = ResourceId.Null;
m_MeshDisplay.secondary.idxoffs = 0;
m_MeshDisplay.secondary.idxByteWidth = 0;
m_MeshDisplay.secondary.baseVertex = 0;
m_MeshDisplay.secondary.buf = ResourceId.Null;
m_MeshDisplay.secondary.offset = 0;