mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-24 15:36:33 +00:00
Handle degenerate case on D3D12 of indexed draw with no index buffer
This commit is contained in:
@@ -1495,6 +1495,11 @@ MeshFormat D3D12Replay::GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint
|
||||
ret.indexByteStride = s.idxFmt == DXGI_FORMAT_R16_UINT ? 2 : 4;
|
||||
ret.indexByteSize = ~0ULL;
|
||||
}
|
||||
else if(s.useIndices)
|
||||
{
|
||||
// indicate that an index buffer is still needed
|
||||
ret.indexByteStride = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.indexResourceId = ResourceId();
|
||||
|
||||
@@ -358,19 +358,23 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
|
||||
|
||||
if(fmt.indexByteStride)
|
||||
{
|
||||
if(fmt.indexResourceId != ResourceId())
|
||||
{
|
||||
ID3D12Resource *ib =
|
||||
m_pDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(fmt.indexResourceId);
|
||||
ID3D12Resource *ib =
|
||||
m_pDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(fmt.indexResourceId);
|
||||
|
||||
if(ib)
|
||||
{
|
||||
D3D12_INDEX_BUFFER_VIEW iview;
|
||||
iview.BufferLocation = ib->GetGPUVirtualAddress() + fmt.indexByteOffset;
|
||||
iview.SizeInBytes = (UINT)fmt.indexByteSize;
|
||||
iview.Format = fmt.indexByteStride == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
||||
list->IASetIndexBuffer(&iview);
|
||||
|
||||
list->DrawIndexedInstanced(fmt.numIndices, 1, 0, fmt.baseVertex, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
list->IASetIndexBuffer(NULL);
|
||||
}
|
||||
|
||||
list->DrawIndexedInstanced(fmt.numIndices, 1, 0, fmt.baseVertex, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -486,19 +490,23 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
|
||||
|
||||
if(cfg.position.indexByteStride)
|
||||
{
|
||||
if(cfg.position.indexResourceId != ResourceId())
|
||||
{
|
||||
ID3D12Resource *ib = m_pDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(
|
||||
cfg.position.indexResourceId);
|
||||
ID3D12Resource *ib =
|
||||
m_pDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(cfg.position.indexResourceId);
|
||||
|
||||
if(ib)
|
||||
{
|
||||
D3D12_INDEX_BUFFER_VIEW view;
|
||||
view.BufferLocation = ib->GetGPUVirtualAddress() + cfg.position.indexByteOffset;
|
||||
view.SizeInBytes = (UINT)cfg.position.indexByteSize;
|
||||
view.Format = cfg.position.indexByteStride == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
||||
list->IASetIndexBuffer(&view);
|
||||
|
||||
list->DrawIndexedInstanced(cfg.position.numIndices, 1, 0, cfg.position.baseVertex, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
list->IASetIndexBuffer(NULL);
|
||||
}
|
||||
|
||||
list->DrawIndexedInstanced(cfg.position.numIndices, 1, 0, cfg.position.baseVertex, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -529,16 +537,23 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
|
||||
|
||||
list->SetGraphicsRoot32BitConstants(2, 4, &pixelData, 0);
|
||||
|
||||
if(cfg.position.indexByteStride && cfg.position.indexResourceId != ResourceId())
|
||||
if(cfg.position.indexByteStride)
|
||||
{
|
||||
ID3D12Resource *ib =
|
||||
m_pDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(cfg.position.indexResourceId);
|
||||
|
||||
D3D12_INDEX_BUFFER_VIEW view;
|
||||
view.BufferLocation = ib->GetGPUVirtualAddress() + cfg.position.indexByteOffset;
|
||||
view.SizeInBytes = (UINT)cfg.position.indexByteSize;
|
||||
view.Format = cfg.position.indexByteStride == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
||||
list->IASetIndexBuffer(&view);
|
||||
if(ib)
|
||||
{
|
||||
D3D12_INDEX_BUFFER_VIEW view;
|
||||
view.BufferLocation = ib->GetGPUVirtualAddress() + cfg.position.indexByteOffset;
|
||||
view.SizeInBytes = (UINT)cfg.position.indexByteSize;
|
||||
view.Format = cfg.position.indexByteStride == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
||||
list->IASetIndexBuffer(&view);
|
||||
}
|
||||
else
|
||||
{
|
||||
list->IASetIndexBuffer(NULL);
|
||||
}
|
||||
|
||||
list->DrawIndexedInstanced(cfg.position.numIndices, 1, 0, cfg.position.baseVertex, 0);
|
||||
}
|
||||
|
||||
@@ -2138,7 +2138,7 @@ uint32_t D3D12Replay::PickVertex(uint32_t eventId, int32_t width, int32_t height
|
||||
|
||||
cbuf.PickCoords = Vec2f((float)x, (float)y);
|
||||
cbuf.PickViewport = Vec2f((float)width, (float)height);
|
||||
cbuf.PickIdx = cfg.position.indexByteStride ? 1 : 0;
|
||||
cbuf.PickIdx = cfg.position.indexByteStride && cfg.position.indexResourceId != ResourceId() ? 1 : 0;
|
||||
cbuf.PickNumVerts = cfg.position.numIndices;
|
||||
cbuf.PickUnproject = cfg.position.unproject ? 1 : 0;
|
||||
cbuf.PickFlipY = cfg.position.flipY;
|
||||
@@ -2489,6 +2489,13 @@ uint32_t D3D12Replay::PickVertex(uint32_t eventId, int32_t width, int32_t height
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cfg.position.indexByteStride)
|
||||
{
|
||||
maxIndex = 0;
|
||||
if(cfg.position.baseVertex > 0)
|
||||
minIndex = maxIndex = (uint32_t)cfg.position.baseVertex;
|
||||
}
|
||||
|
||||
sdesc.Buffer.NumElements = 4;
|
||||
m_pDevice->CreateShaderResourceView(NULL, &sdesc, GetDebugManager()->GetCPUHandle(PICK_IB_SRV));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user