Skip to content

Commit

Permalink
Serialise and replay calls to SetPipelineStackSize
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Jun 24, 2024
1 parent 01384c4 commit 4648ef2
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions renderdoc/driver/d3d12/d3d12_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ bool WrappedID3D12CommandQueue::ProcessChunk(ReadSerialiser &ser, D3D12Chunk chu
case D3D12Chunk::Device_CreateStateObject:
case D3D12Chunk::Device_AddToStateObject:
case D3D12Chunk::CreateAS:
case D3D12Chunk::StateObject_SetPipelineStackSize:
RDCERR("Unexpected chunk while processing frame: %s", ToStr(chunk).c_str());
return false;

Expand Down
1 change: 1 addition & 0 deletions renderdoc/driver/d3d12/d3d12_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1223,5 +1223,6 @@ enum class D3D12Chunk : uint32_t
List_DispatchRays,
List_SetPipelineState1,
CreateAS,
StateObject_SetPipelineStackSize,
Max,
};
43 changes: 43 additions & 0 deletions renderdoc/driver/d3d12/d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,47 @@ void WrappedID3D12Device::SetShaderExtUAV(GPUVendor vendor, uint32_t reg, uint32
INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12Device, SetShaderExtUAV, GPUVendor vendor,
uint32_t reg, uint32_t space, bool global);

template <typename SerialiserType>
bool WrappedID3D12Device::Serialise_SetPipelineStackSize(SerialiserType &ser,
ID3D12StateObject *pStateObject,
UINT64 StackSize)
{
SERIALISE_ELEMENT(pStateObject);
SERIALISE_ELEMENT(StackSize);

SERIALISE_CHECK_READ_ERRORS();

if(IsReplayingAndReading() && pStateObject)
{
ID3D12StateObjectProperties *properties = NULL;
pStateObject->QueryInterface(__uuidof(ID3D12StateObjectProperties), (void **)&properties);

properties->SetPipelineStackSize(StackSize);

SAFE_RELEASE(properties);
}

return true;
}

void WrappedID3D12Device::SetPipelineStackSize(ID3D12StateObject *pStateObject, UINT64 StackSize)
{
if(IsCaptureMode(m_State))
{
D3D12ResourceRecord *record = GetRecord(pStateObject);

{
WriteSerialiser &ser = GetThreadSerialiser();
SCOPED_SERIALISE_CHUNK(D3D12Chunk::StateObject_SetPipelineStackSize);
Serialise_SetPipelineStackSize(ser, pStateObject, StackSize);
record->AddChunk(scope.Get());
}
}
}

INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12Device, SetPipelineStackSize,
ID3D12StateObject *pStateObject, UINT64 StackSize);

void WrappedID3D12Device::SetShaderExt(GPUVendor vendor)
{
// just overwrite, we don't expect to switch back and forth on a given device.
Expand Down Expand Up @@ -4455,6 +4496,8 @@ bool WrappedID3D12Device::ProcessChunk(ReadSerialiser &ser, D3D12Chunk context)
case D3D12Chunk::Device_AddToStateObject:
return Serialise_AddToStateObject(ser, NULL, NULL, IID(), NULL);
case D3D12Chunk::CreateAS: return Serialise_CreateAS(ser, NULL, 0, {}, NULL);
case D3D12Chunk::StateObject_SetPipelineStackSize:
return Serialise_SetPipelineStackSize(ser, NULL, 0);

// in order to get a warning if we miss a case, we explicitly handle the list/queue chunks here.
// If we actually encounter one it's an error (we should hit CaptureBegin first and switch to
Expand Down
2 changes: 2 additions & 0 deletions renderdoc/driver/d3d12/d3d12_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,8 @@ class WrappedID3D12Device : public IFrameCapturer, public ID3DDevice, public ID3
ID3D12PipelineState **state);

// Resource
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, SetPipelineStackSize, ID3D12StateObject *pStateObject,
UINT64 StackSize);
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, SetName, ID3D12DeviceChild *pResource, const char *Name);
IMPLEMENT_FUNCTION_THREAD_SERIALISED(HRESULT, SetShaderDebugPath, ID3D12DeviceChild *pResource,
const char *Path);
Expand Down
1 change: 1 addition & 0 deletions renderdoc/driver/d3d12/d3d12_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ class WrappedID3D12StateObject : public WrappedDeviceChild12<ID3D12StateObject>,
}
virtual void STDMETHODCALLTYPE SetPipelineStackSize(UINT64 PipelineStackSizeInBytes)
{
m_pDevice->SetPipelineStackSize(this, PipelineStackSizeInBytes);
properties->SetPipelineStackSize(PipelineStackSizeInBytes);
}
};
Expand Down
4 changes: 3 additions & 1 deletion renderdoc/driver/d3d12/d3d12_stringise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
template <>
rdcstr DoStringise(const D3D12Chunk &el)
{
RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1132, "Chunks changed without updating names");
RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1133, "Chunks changed without updating names");

BEGIN_ENUM_STRINGISE(D3D12Chunk)
{
Expand Down Expand Up @@ -234,6 +234,8 @@ rdcstr DoStringise(const D3D12Chunk &el)
STRINGISE_ENUM_CLASS_NAMED(List_SetPipelineState1,
"ID3D12GraphicsCommandList4::SetPipelineState1");
STRINGISE_ENUM_CLASS_NAMED(CreateAS, "Internal::Acceleration Structure Create");
STRINGISE_ENUM_CLASS_NAMED(StateObject_SetPipelineStackSize,
"ID3D12StateObjectProperties::SetPipelineStackSize");
STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk");
}
END_ENUM_STRINGISE()
Expand Down

0 comments on commit 4648ef2

Please sign in to comment.