Don't set stale table root signature entries for non-current heaps

* The problem is we need to keep current state for both graphics and
  compute because while setting a root signature invalidates bindings,
  setting compute doesn't invalidate graphics and vice-versa.
* However it can be invalid to try and re-apply in one go if we're only
  drawing and not dispatching and some of the compute elements are
  invalid.
* Rather than try to figure out which one *should* be valid, instead we
  just skip invalid binds that don't have matching heaps.
This commit is contained in:
baldurk
2016-10-26 23:14:10 +02:00
parent 447b64fd14
commit e8e7ad711a
+28 -2
View File
@@ -205,7 +205,20 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd)
GetResourceManager()->GetCurrentAs<ID3D12RootSignature>(graphics.rootsig));
for(size_t i = 0; i < graphics.sigelems.size(); i++)
graphics.sigelems[i].SetToGraphics(GetResourceManager(), cmd, (UINT)i);
{
// just don't set tables that aren't in the descriptor heaps, since it's invalid and can crash
// and is probably just from stale bindings that aren't going to be used
if(graphics.sigelems[i].type == eRootTable ||
std::find(heaps.begin(), heaps.end(), graphics.sigelems[i].id) != heaps.end())
{
graphics.sigelems[i].SetToGraphics(GetResourceManager(), cmd, (UINT)i);
}
else
{
RDCDEBUG("Skipping setting possibly stale graphics root table referring to heap %llu",
graphics.sigelems[i].id);
}
}
}
if(compute.rootsig != ResourceId())
@@ -214,6 +227,19 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd)
GetResourceManager()->GetCurrentAs<ID3D12RootSignature>(compute.rootsig));
for(size_t i = 0; i < compute.sigelems.size(); i++)
compute.sigelems[i].SetToCompute(GetResourceManager(), cmd, (UINT)i);
{
// just don't set tables that aren't in the descriptor heaps, since it's invalid and can crash
// and is probably just from stale bindings that aren't going to be used
if(compute.sigelems[i].type != eRootTable ||
std::find(heaps.begin(), heaps.end(), compute.sigelems[i].id) != heaps.end())
{
compute.sigelems[i].SetToCompute(GetResourceManager(), cmd, (UINT)i);
}
else
{
RDCDEBUG("Skipping setting possibly stale compute root table referring to heap %llu",
compute.sigelems[i].id);
}
}
}
}