mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-10 17:47:16 +00:00
Detect and drop calls setting a GPU virtual address of 0
This commit is contained in:
@@ -133,6 +133,8 @@ public:
|
||||
m_Init.type = type;
|
||||
}
|
||||
|
||||
bool ValidateRootGPUVA(ResourceId buffer);
|
||||
|
||||
//////////////////////////////
|
||||
// implement IUnknown
|
||||
|
||||
|
||||
@@ -1517,8 +1517,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootConstantBufferVie
|
||||
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
m_Cmd->m_LastCmdListID = CommandList;
|
||||
|
||||
if(ValidateRootGPUVA(buffer))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_State == EXECUTING)
|
||||
{
|
||||
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
|
||||
@@ -1589,8 +1594,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootShaderResourceVie
|
||||
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
m_Cmd->m_LastCmdListID = CommandList;
|
||||
|
||||
if(ValidateRootGPUVA(buffer))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_State == EXECUTING)
|
||||
{
|
||||
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
|
||||
@@ -1661,8 +1671,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootUnorderedAccessVi
|
||||
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
m_Cmd->m_LastCmdListID = CommandList;
|
||||
|
||||
if(ValidateRootGPUVA(buffer))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_State == EXECUTING)
|
||||
{
|
||||
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
|
||||
@@ -2017,8 +2032,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootConstantBufferVi
|
||||
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
m_Cmd->m_LastCmdListID = CommandList;
|
||||
|
||||
if(ValidateRootGPUVA(buffer))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_State == EXECUTING)
|
||||
{
|
||||
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
|
||||
@@ -2090,8 +2110,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootShaderResourceVi
|
||||
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
m_Cmd->m_LastCmdListID = CommandList;
|
||||
|
||||
if(ValidateRootGPUVA(buffer))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_State == EXECUTING)
|
||||
{
|
||||
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
|
||||
@@ -2163,8 +2188,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootUnorderedAccessV
|
||||
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
m_Cmd->m_LastCmdListID = CommandList;
|
||||
|
||||
if(ValidateRootGPUVA(buffer))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_State == EXECUTING)
|
||||
{
|
||||
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
|
||||
|
||||
@@ -666,6 +666,32 @@ WrappedID3D12GraphicsCommandList::~WrappedID3D12GraphicsCommandList()
|
||||
SAFE_RELEASE(m_pReal);
|
||||
}
|
||||
|
||||
bool WrappedID3D12GraphicsCommandList::ValidateRootGPUVA(ResourceId buffer)
|
||||
{
|
||||
if(!GetResourceManager()->HasLiveResource(buffer))
|
||||
{
|
||||
// abort, we don't have this buffer. Print errors while reading
|
||||
if(m_State == READING)
|
||||
{
|
||||
if(buffer != ResourceId())
|
||||
{
|
||||
RDCERR("Don't have live buffer for %llu", buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pDevice->AddDebugMessage(eDbgCategory_Resource_Manipulation, eDbgSeverity_Medium,
|
||||
eDbgSource_IncorrectAPIUse,
|
||||
"Binding 0 as a GPU Virtual Address in a root constant is "
|
||||
"invalid. This call will be dropped during replay.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE WrappedID3D12GraphicsCommandList::QueryInterface(REFIID riid,
|
||||
void **ppvObject)
|
||||
{
|
||||
|
||||
@@ -1593,6 +1593,35 @@ void WrappedID3D12Device::ReleaseResource(ID3D12DeviceChild *res)
|
||||
}
|
||||
}
|
||||
|
||||
void WrappedID3D12Device::AddDebugMessage(DebugMessageCategory c, DebugMessageSeverity sv,
|
||||
DebugMessageSource src, std::string d)
|
||||
{
|
||||
D3D12CommandData &cmd = *m_Queue->GetCommandData();
|
||||
|
||||
DebugMessage msg;
|
||||
msg.eventID = 0;
|
||||
msg.messageID = 0;
|
||||
msg.source = src;
|
||||
msg.category = c;
|
||||
msg.severity = sv;
|
||||
msg.description = d;
|
||||
|
||||
if(m_State == EXECUTING)
|
||||
{
|
||||
// look up the EID this drawcall came from
|
||||
D3D12CommandData::DrawcallUse use(cmd.m_CurChunkOffset, 0);
|
||||
auto it = std::lower_bound(cmd.m_DrawcallUses.begin(), cmd.m_DrawcallUses.end(), use);
|
||||
RDCASSERT(it != cmd.m_DrawcallUses.end());
|
||||
|
||||
msg.eventID = it->eventID;
|
||||
AddDebugMessage(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.m_EventMessages.push_back(msg);
|
||||
}
|
||||
}
|
||||
|
||||
vector<DebugMessage> WrappedID3D12Device::GetDebugMessages()
|
||||
{
|
||||
vector<DebugMessage> ret;
|
||||
|
||||
@@ -362,6 +362,8 @@ public:
|
||||
FetchFrameRecord &GetFrameRecord() { return m_FrameRecord; }
|
||||
const FetchDrawcall *GetDrawcall(uint32_t eventID);
|
||||
|
||||
void AddDebugMessage(DebugMessageCategory c, DebugMessageSeverity sv, DebugMessageSource src,
|
||||
std::string d);
|
||||
void AddDebugMessage(const DebugMessage &msg) { m_DebugMessages.push_back(msg); }
|
||||
vector<DebugMessage> GetDebugMessages();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user