Handle ExecuteIndirect setting a GPU_VA of 0

* I don't know if this is valid or not, but it seems to work without triggering
  any validation layer warnings or errors which is the best guess.
This commit is contained in:
baldurk
2019-01-28 19:55:39 +00:00
parent 317e89f7cb
commit 3e843351e7
3 changed files with 40 additions and 17 deletions
@@ -3658,7 +3658,6 @@ void WrappedID3D12GraphicsCommandList2::PatchExecuteIndirect(BakedCmdListInfo &i
m_pDevice->GetResIDFromAddr(*addr, id, offs);
ID3D12Resource *res = GetResourceManager()->GetLiveAs<ID3D12Resource>(id);
RDCASSERT(res);
if(res)
*addr = res->GetGPUVirtualAddress() + offs;
@@ -4023,7 +4022,7 @@ void WrappedID3D12GraphicsCommandList2::ReplayExecuteIndirect(ID3D12GraphicsComm
ResourceId id;
uint64_t offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(*srcAddr, id, offs);
RDCASSERT(id != ResourceId());
RDCASSERT(*srcAddr == 0 || id != ResourceId());
const uint32_t rootIdx = arg.Constant.RootParameterIndex;
@@ -4035,22 +4034,37 @@ void WrappedID3D12GraphicsCommandList2::ReplayExecuteIndirect(ID3D12GraphicsComm
{
elemType = eRootCBV;
if(executing && id != ResourceId())
list->SetGraphicsRootConstantBufferView(rootIdx, *srcAddr);
if(executing)
{
if(id != ResourceId())
list->SetGraphicsRootConstantBufferView(rootIdx, *srcAddr);
else
list->SetGraphicsRootConstantBufferView(rootIdx, 0);
}
}
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW)
{
elemType = eRootSRV;
if(executing && id != ResourceId())
list->SetGraphicsRootShaderResourceView(rootIdx, *srcAddr);
if(executing)
{
if(id != ResourceId())
list->SetGraphicsRootShaderResourceView(rootIdx, *srcAddr);
else
list->SetGraphicsRootShaderResourceView(rootIdx, 0);
}
}
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW)
{
elemType = eRootUAV;
if(executing && id != ResourceId())
list->SetGraphicsRootUnorderedAccessView(rootIdx, *srcAddr);
if(executing)
{
if(id != ResourceId())
list->SetGraphicsRootUnorderedAccessView(rootIdx, *srcAddr);
else
list->SetGraphicsRootUnorderedAccessView(rootIdx, 0);
}
}
else
{
+12 -3
View File
@@ -913,7 +913,10 @@ void D3D12Replay::FillRegisterSpaces(const D3D12RenderState::RootSignature &root
cb.resourceId = rm->GetOriginalID(e.id);
cb.byteOffset = e.offset;
cb.byteSize = uint32_t(res->GetDesc().Width - cb.byteOffset);
if(res)
cb.byteSize = uint32_t(res->GetDesc().Width - cb.byteOffset);
else
cb.byteSize = 0;
}
}
}
@@ -938,7 +941,10 @@ void D3D12Replay::FillRegisterSpaces(const D3D12RenderState::RootSignature &root
view.elementByteSize = sizeof(uint32_t);
view.firstElement = e.offset / sizeof(uint32_t);
view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t));
if(res)
view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t));
else
view.numElements = 0;
}
}
}
@@ -963,7 +969,10 @@ void D3D12Replay::FillRegisterSpaces(const D3D12RenderState::RootSignature &root
view.elementByteSize = sizeof(uint32_t);
view.firstElement = e.offset / sizeof(uint32_t);
view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t));
if(res)
view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t));
else
view.numElements = 0;
}
}
}
+6 -6
View File
@@ -92,17 +92,17 @@ struct D3D12RenderState
else if(type == eRootCBV)
{
ID3D12Resource *res = rm->GetCurrentAs<ID3D12Resource>(id);
cmd->SetGraphicsRootConstantBufferView(slot, res->GetGPUVirtualAddress() + offset);
cmd->SetGraphicsRootConstantBufferView(slot, res ? res->GetGPUVirtualAddress() + offset : 0);
}
else if(type == eRootSRV)
{
ID3D12Resource *res = rm->GetCurrentAs<ID3D12Resource>(id);
cmd->SetGraphicsRootShaderResourceView(slot, res->GetGPUVirtualAddress() + offset);
cmd->SetGraphicsRootShaderResourceView(slot, res ? res->GetGPUVirtualAddress() + offset : 0);
}
else if(type == eRootUAV)
{
ID3D12Resource *res = rm->GetCurrentAs<ID3D12Resource>(id);
cmd->SetGraphicsRootUnorderedAccessView(slot, res->GetGPUVirtualAddress() + offset);
cmd->SetGraphicsRootUnorderedAccessView(slot, res ? res->GetGPUVirtualAddress() + offset : 0);
}
}
@@ -122,17 +122,17 @@ struct D3D12RenderState
else if(type == eRootCBV)
{
ID3D12Resource *res = rm->GetCurrentAs<ID3D12Resource>(id);
cmd->SetComputeRootConstantBufferView(slot, res->GetGPUVirtualAddress() + offset);
cmd->SetComputeRootConstantBufferView(slot, res ? res->GetGPUVirtualAddress() + offset : 0);
}
else if(type == eRootSRV)
{
ID3D12Resource *res = rm->GetCurrentAs<ID3D12Resource>(id);
cmd->SetComputeRootShaderResourceView(slot, res->GetGPUVirtualAddress() + offset);
cmd->SetComputeRootShaderResourceView(slot, res ? res->GetGPUVirtualAddress() + offset : 0);
}
else if(type == eRootUAV)
{
ID3D12Resource *res = rm->GetCurrentAs<ID3D12Resource>(id);
cmd->SetComputeRootUnorderedAccessView(slot, res->GetGPUVirtualAddress() + offset);
cmd->SetComputeRootUnorderedAccessView(slot, res ? res->GetGPUVirtualAddress() + offset : 0);
}
}