mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Generate inline shader IDs during capture on D3D12
This commit is contained in:
@@ -545,6 +545,10 @@ bool D3D12InitParams::IsSupportedVersion(uint64_t ver)
|
||||
if(ver == 0x14)
|
||||
return true;
|
||||
|
||||
// 0x15 -> 0x16 - added IDs generated at capture time for shaders in pipelines
|
||||
if(ver == 0x15)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ struct D3D12InitParams
|
||||
UINT SDKVersion = 0;
|
||||
|
||||
// check if a frame capture section version is supported
|
||||
static const uint64_t CurrentVersion = 0x15;
|
||||
static const uint64_t CurrentVersion = 0x16;
|
||||
|
||||
static bool IsSupportedVersion(uint64_t ver);
|
||||
};
|
||||
|
||||
@@ -513,6 +513,30 @@ bool WrappedID3D12Device::Serialise_CreateGraphicsPipelineState(
|
||||
((WrappedID3D12PipelineState *)*ppPipelineState)->GetResourceID())
|
||||
.TypedAs("ID3D12PipelineState *"_lit);
|
||||
|
||||
ResourceId InlineShaderIDs[5];
|
||||
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
const D3D12_SHADER_BYTECODE *shaders[] = {
|
||||
&Descriptor.VS, &Descriptor.HS, &Descriptor.DS, &Descriptor.GS, &Descriptor.PS,
|
||||
};
|
||||
RDCCOMPILE_ASSERT(ARRAY_COUNT(InlineShaderIDs) == ARRAY_COUNT(shaders),
|
||||
"shaders array is incorrectly sized");
|
||||
|
||||
for(uint32_t s = 0; s < ARRAY_COUNT(shaders); s++)
|
||||
{
|
||||
if(shaders[s]->BytecodeLength == 0 || shaders[s]->pShaderBytecode == NULL)
|
||||
continue;
|
||||
|
||||
InlineShaderIDs[s] = ResourceIDGen::GetNewUniqueID();
|
||||
}
|
||||
}
|
||||
|
||||
if(ser.VersionAtLeast(0x16))
|
||||
{
|
||||
SERIALISE_ELEMENT(InlineShaderIDs).Hidden();
|
||||
}
|
||||
|
||||
SERIALISE_CHECK_READ_ERRORS();
|
||||
|
||||
if(IsReplayingAndReading())
|
||||
@@ -557,6 +581,8 @@ bool WrappedID3D12Device::Serialise_CreateGraphicsPipelineState(
|
||||
if(OrigDescriptor.pRootSignature)
|
||||
DerivedResource(OrigDescriptor.pRootSignature, pPipelineState);
|
||||
|
||||
RDCCOMPILE_ASSERT(ARRAY_COUNT(InlineShaderIDs) == ARRAY_COUNT(shaders),
|
||||
"shaders array is incorrectly sized");
|
||||
for(size_t i = 0; i < ARRAY_COUNT(shaders); i++)
|
||||
{
|
||||
if(shaders[i]->BytecodeLength == 0 || shaders[i]->pShaderBytecode == NULL)
|
||||
@@ -566,7 +592,8 @@ bool WrappedID3D12Device::Serialise_CreateGraphicsPipelineState(
|
||||
}
|
||||
else
|
||||
{
|
||||
WrappedID3D12Shader *entry = WrappedID3D12Shader::AddShader(ResourceId(), *shaders[i], this);
|
||||
WrappedID3D12Shader *entry =
|
||||
WrappedID3D12Shader::AddShader(InlineShaderIDs[i], *shaders[i], this);
|
||||
entry->AddRef();
|
||||
|
||||
shaders[i]->pShaderBytecode = entry;
|
||||
@@ -832,6 +859,18 @@ bool WrappedID3D12Device::Serialise_CreateComputePipelineState(
|
||||
((WrappedID3D12PipelineState *)*ppPipelineState)->GetResourceID())
|
||||
.TypedAs("ID3D12PipelineState *"_lit);
|
||||
|
||||
ResourceId InlineShaderID;
|
||||
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
InlineShaderID = ResourceIDGen::GetNewUniqueID();
|
||||
}
|
||||
|
||||
if(ser.VersionAtLeast(0x18))
|
||||
{
|
||||
SERIALISE_ELEMENT(InlineShaderID).Hidden();
|
||||
}
|
||||
|
||||
SERIALISE_CHECK_READ_ERRORS();
|
||||
|
||||
if(IsReplayingAndReading())
|
||||
@@ -855,7 +894,7 @@ bool WrappedID3D12Device::Serialise_CreateComputePipelineState(
|
||||
wrapped->compute = new D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC(OrigDescriptor);
|
||||
|
||||
WrappedID3D12Shader *entry =
|
||||
WrappedID3D12Shader::AddShader(ResourceId(), wrapped->compute->CS, this);
|
||||
WrappedID3D12Shader::AddShader(InlineShaderID, wrapped->compute->CS, this);
|
||||
entry->AddRef();
|
||||
|
||||
if(m_GlobalEXTUAV != ~0U)
|
||||
|
||||
@@ -70,6 +70,31 @@ bool WrappedID3D12Device::Serialise_CreatePipelineState(SerialiserType &ser,
|
||||
((WrappedID3D12PipelineState *)*ppPipelineState)->GetResourceID())
|
||||
.TypedAs("ID3D12PipelineState *"_lit);
|
||||
|
||||
ResourceId InlineShaderIDs[8];
|
||||
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
const D3D12_SHADER_BYTECODE *shaders[] = {
|
||||
&Descriptor.VS, &Descriptor.HS, &Descriptor.DS, &Descriptor.GS,
|
||||
&Descriptor.PS, &Descriptor.CS, &Descriptor.AS, &Descriptor.MS,
|
||||
};
|
||||
RDCCOMPILE_ASSERT(ARRAY_COUNT(InlineShaderIDs) == ARRAY_COUNT(shaders),
|
||||
"shaders array is incorrectly sized");
|
||||
|
||||
for(uint32_t s = 0; s < ARRAY_COUNT(shaders); s++)
|
||||
{
|
||||
if(shaders[s]->BytecodeLength == 0 || shaders[s]->pShaderBytecode == NULL)
|
||||
continue;
|
||||
|
||||
InlineShaderIDs[s] = ResourceIDGen::GetNewUniqueID();
|
||||
}
|
||||
}
|
||||
|
||||
if(ser.VersionAtLeast(0x16))
|
||||
{
|
||||
SERIALISE_ELEMENT(InlineShaderIDs).Hidden();
|
||||
}
|
||||
|
||||
SERIALISE_CHECK_READ_ERRORS();
|
||||
|
||||
if(IsReplayingAndReading())
|
||||
@@ -124,6 +149,8 @@ bool WrappedID3D12Device::Serialise_CreatePipelineState(SerialiserType &ser,
|
||||
if(OrigDescriptor.GetRootSigIfPresent())
|
||||
DerivedResource(OrigDescriptor.GetRootSigIfPresent(), pPipelineState);
|
||||
|
||||
RDCCOMPILE_ASSERT(ARRAY_COUNT(InlineShaderIDs) == ARRAY_COUNT(shaders),
|
||||
"shaders array is incorrectly sized");
|
||||
for(size_t i = 0; i < ARRAY_COUNT(shaders); i++)
|
||||
{
|
||||
if(shaders[i]->BytecodeLength == 0 || shaders[i]->pShaderBytecode == NULL)
|
||||
@@ -133,7 +160,8 @@ bool WrappedID3D12Device::Serialise_CreatePipelineState(SerialiserType &ser,
|
||||
}
|
||||
else
|
||||
{
|
||||
WrappedID3D12Shader *entry = WrappedID3D12Shader::AddShader(ResourceId(), *shaders[i], this);
|
||||
WrappedID3D12Shader *entry =
|
||||
WrappedID3D12Shader::AddShader(InlineShaderIDs[i], *shaders[i], this);
|
||||
entry->AddRef();
|
||||
|
||||
shaders[i]->pShaderBytecode = entry;
|
||||
|
||||
Reference in New Issue
Block a user