D3D12: Support returning pipeline cache data
This commit is contained in:
parent
61a656570e
commit
5cef09e383
|
@ -156,7 +156,8 @@ static void GetD3DBlendDesc(D3D12_BLEND_DESC* desc, const BlendingState& state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DXPipeline> DXPipeline::Create(const AbstractPipelineConfig& config)
|
std::unique_ptr<DXPipeline> DXPipeline::Create(const AbstractPipelineConfig& config,
|
||||||
|
const void* cache_data, size_t cache_data_size)
|
||||||
{
|
{
|
||||||
DEBUG_ASSERT(config.vertex_shader && config.pixel_shader);
|
DEBUG_ASSERT(config.vertex_shader && config.pixel_shader);
|
||||||
|
|
||||||
|
@ -202,16 +203,36 @@ std::unique_ptr<DXPipeline> DXPipeline::Create(const AbstractPipelineConfig& con
|
||||||
D3DCommon::GetDSVFormatForAbstractFormat(config.framebuffer_state.depth_texture_format);
|
D3DCommon::GetDSVFormatForAbstractFormat(config.framebuffer_state.depth_texture_format);
|
||||||
desc.SampleDesc.Count = config.framebuffer_state.samples;
|
desc.SampleDesc.Count = config.framebuffer_state.samples;
|
||||||
desc.NodeMask = 1;
|
desc.NodeMask = 1;
|
||||||
|
desc.CachedPSO.pCachedBlob = cache_data;
|
||||||
|
desc.CachedPSO.CachedBlobSizeInBytes = cache_data_size;
|
||||||
|
|
||||||
ID3D12PipelineState* pso;
|
ID3D12PipelineState* pso;
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso));
|
HRESULT hr = g_dx_context->GetDevice()->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso));
|
||||||
CHECK(SUCCEEDED(hr), "Create PSO");
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
WARN_LOG(VIDEO, "CreateGraphicsPipelineState() %sfailed with HRESULT %08X",
|
||||||
|
cache_data ? "with cache data " : "", hr);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const bool use_integer_rtv =
|
const bool use_integer_rtv =
|
||||||
!config.blending_state.blendenable && config.blending_state.logicopenable;
|
!config.blending_state.blendenable && config.blending_state.logicopenable;
|
||||||
return std::make_unique<DXPipeline>(pso, desc.pRootSignature, config.usage,
|
return std::make_unique<DXPipeline>(pso, desc.pRootSignature, config.usage,
|
||||||
GetD3DTopology(config.rasterization_state), use_integer_rtv);
|
GetD3DTopology(config.rasterization_state), use_integer_rtv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractPipeline::CacheData DXPipeline::GetCacheData() const
|
||||||
|
{
|
||||||
|
ComPtr<ID3DBlob> blob;
|
||||||
|
HRESULT hr = m_pipeline->GetCachedBlob(&blob);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
WARN_LOG(VIDEO, "ID3D12Pipeline::GetCachedBlob() failed with HRESULT %08X", hr);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheData data(blob->GetBufferSize());
|
||||||
|
std::memcpy(data.data(), blob->GetBufferPointer(), blob->GetBufferSize());
|
||||||
|
return data;
|
||||||
|
}
|
||||||
} // namespace DX12
|
} // namespace DX12
|
||||||
|
|
|
@ -19,7 +19,8 @@ public:
|
||||||
bool use_integer_rtv);
|
bool use_integer_rtv);
|
||||||
~DXPipeline() override;
|
~DXPipeline() override;
|
||||||
|
|
||||||
static std::unique_ptr<DXPipeline> Create(const AbstractPipelineConfig& config);
|
static std::unique_ptr<DXPipeline> Create(const AbstractPipelineConfig& config,
|
||||||
|
const void* cache_data, size_t cache_data_size);
|
||||||
|
|
||||||
ID3D12PipelineState* GetPipeline() const { return m_pipeline; }
|
ID3D12PipelineState* GetPipeline() const { return m_pipeline; }
|
||||||
ID3D12RootSignature* GetRootSignature() const { return m_root_signature; }
|
ID3D12RootSignature* GetRootSignature() const { return m_root_signature; }
|
||||||
|
@ -27,6 +28,8 @@ public:
|
||||||
D3D12_PRIMITIVE_TOPOLOGY GetPrimitiveTopology() const { return m_primitive_topology; }
|
D3D12_PRIMITIVE_TOPOLOGY GetPrimitiveTopology() const { return m_primitive_topology; }
|
||||||
bool UseIntegerRTV() const { return m_use_integer_rtv; }
|
bool UseIntegerRTV() const { return m_use_integer_rtv; }
|
||||||
|
|
||||||
|
CacheData GetCacheData() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ID3D12PipelineState* m_pipeline;
|
ID3D12PipelineState* m_pipeline;
|
||||||
ID3D12RootSignature* m_root_signature;
|
ID3D12RootSignature* m_root_signature;
|
||||||
|
|
|
@ -103,7 +103,7 @@ std::unique_ptr<AbstractPipeline> Renderer::CreatePipeline(const AbstractPipelin
|
||||||
const void* cache_data,
|
const void* cache_data,
|
||||||
size_t cache_data_length)
|
size_t cache_data_length)
|
||||||
{
|
{
|
||||||
return DXPipeline::Create(config);
|
return DXPipeline::Create(config, cache_data, cache_data_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 Renderer::BBoxRead(int index)
|
u16 Renderer::BBoxRead(int index)
|
||||||
|
|
Loading…
Reference in New Issue