Skip to content

Commit 7313cc6

Browse files
ProxyPipelineState: keep a copy of PSO desc
1 parent 41e6218 commit 7313cc6

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

Graphics/GraphicsTools/include/AsyncPipelineState.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diligent Graphics LLC
2+
* Copyright 2024-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,6 @@ class AsyncPipelineState final : public ProxyPipelineState<ObjectBase<IPipelineS
8282

8383
RefCntAutoPtr<RenderStateCacheImpl> m_pStateCache;
8484
std::unique_ptr<CreateInfoWrapperBase> m_pCreateInfo;
85-
const PIPELINE_TYPE m_Type;
8685
UniqueIdHelper<AsyncPipelineState> m_UniqueID;
8786
};
8887

Graphics/GraphicsTools/include/ProxyPipelineState.hpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diligent Graphics LLC
2+
* Copyright 2024-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131

3232
#include "PipelineState.h"
3333
#include "RefCntAutoPtr.hpp"
34+
#include "PipelineStateBase.hpp"
3435

3536
namespace Diligent
3637
{
@@ -42,15 +43,15 @@ class ProxyPipelineState : public Base
4243
{
4344
public:
4445
template <typename... Args>
45-
ProxyPipelineState(Args&&... args) :
46-
Base{std::forward<Args>(args)...}
46+
ProxyPipelineState(const PipelineStateDesc& PSODesc, Args&&... args) :
47+
Base{std::forward<Args>(args)...},
48+
m_Name{PSODesc.Name != nullptr ? PSODesc.Name : ""},
49+
m_Desc{m_Name.c_str(), PSODesc.PipelineType}
4750
{}
4851

4952
virtual const PipelineStateDesc& DILIGENT_CALL_TYPE GetDesc() const override
5053
{
51-
DEV_CHECK_ERR(m_pPipeline, "Internal pipeline is null");
52-
static constexpr PipelineStateDesc NullDesc;
53-
return m_pPipeline ? m_pPipeline->GetDesc() : NullDesc;
54+
return m_pPipeline ? m_pPipeline->GetDesc() : m_Desc;
5455
}
5556

5657
virtual Int32 DILIGENT_CALL_TYPE GetUniqueID() const override
@@ -62,7 +63,10 @@ class ProxyPipelineState : public Base
6263
virtual void DILIGENT_CALL_TYPE SetUserData(IObject* pUserData) override
6364
{
6465
DEV_CHECK_ERR(m_pPipeline, "Internal pipeline is null");
65-
m_pPipeline->SetUserData(pUserData);
66+
if (m_pPipeline)
67+
{
68+
m_pPipeline->SetUserData(pUserData);
69+
}
6670
}
6771

6872
virtual IObject* DILIGENT_CALL_TYPE GetUserData() const override
@@ -104,7 +108,7 @@ class ProxyPipelineState : public Base
104108
virtual Uint32 DILIGENT_CALL_TYPE GetStaticVariableCount(SHADER_TYPE ShaderType) const override
105109
{
106110
DEV_CHECK_ERR(m_pPipeline, "Internal pipeline is null");
107-
return m_pPipeline->GetStaticVariableCount(ShaderType);
111+
return m_pPipeline ? m_pPipeline->GetStaticVariableCount(ShaderType) : 0;
108112
}
109113

110114
virtual IShaderResourceVariable* DILIGENT_CALL_TYPE GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name) override
@@ -122,7 +126,10 @@ class ProxyPipelineState : public Base
122126
virtual void DILIGENT_CALL_TYPE CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources) override
123127
{
124128
DEV_CHECK_ERR(m_pPipeline, "Internal pipeline is null");
125-
m_pPipeline->CreateShaderResourceBinding(ppShaderResourceBinding, InitStaticResources);
129+
if (m_pPipeline)
130+
{
131+
m_pPipeline->CreateShaderResourceBinding(ppShaderResourceBinding, InitStaticResources);
132+
}
126133
}
127134

128135
virtual void DILIGENT_CALL_TYPE InitializeStaticSRBResources(IShaderResourceBinding* pShaderResourceBinding) const override
@@ -168,6 +175,9 @@ class ProxyPipelineState : public Base
168175
}
169176

170177
protected:
178+
const std::string m_Name;
179+
const PipelineStateDesc m_Desc;
180+
171181
RefCntAutoPtr<IPipelineState> m_pPipeline;
172182
};
173183

Graphics/GraphicsTools/include/ReloadablePipelineState.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diligent Graphics LLC
2+
* Copyright 2024-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,6 @@ class ReloadablePipelineState final : public ProxyPipelineState<ObjectBase<IPipe
8484

8585
RefCntAutoPtr<RenderStateCacheImpl> m_pStateCache;
8686
std::unique_ptr<CreateInfoWrapperBase> m_pCreateInfo;
87-
const PIPELINE_TYPE m_Type;
8887

8988
// Old pipeline state kept around to copy static resources from
9089
RefCntAutoPtr<IPipelineState> m_pOldPipeline;

Graphics/GraphicsTools/src/AsyncPipelineState.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diligent Graphics LLC
2+
* Copyright 2024-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,9 +73,8 @@ struct AsyncPipelineState::CreateInfoWrapper : CreateInfoWrapperBase
7373
AsyncPipelineState::AsyncPipelineState(IReferenceCounters* pRefCounters,
7474
RenderStateCacheImpl* pStateCache,
7575
const PipelineStateCreateInfo& CreateInfo) :
76-
TBase{pRefCounters},
76+
TBase{CreateInfo.PSODesc, pRefCounters},
7777
m_pStateCache{pStateCache},
78-
m_Type{CreateInfo.PSODesc.PipelineType},
7978
m_UniqueID{}
8079
{
8180
static_assert(PIPELINE_TYPE_COUNT == 5, "Did you add a new pipeline type? You may need to handle it here.");
@@ -132,7 +131,7 @@ void AsyncPipelineState::QueryInterface(const INTERFACE_ID& IID, IObject** ppInt
132131
void AsyncPipelineState::InitInternalPipeline()
133132
{
134133
static_assert(PIPELINE_TYPE_COUNT == 5, "Did you add a new pipeline type? You may need to handle it here.");
135-
switch (m_Type)
134+
switch (m_Desc.PipelineType)
136135
{
137136
case PIPELINE_TYPE_GRAPHICS:
138137
case PIPELINE_TYPE_MESH:

Graphics/GraphicsTools/src/ReloadablePipelineState.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diligent Graphics LLC
2+
* Copyright 2024-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,9 +82,8 @@ ReloadablePipelineState::ReloadablePipelineState(IReferenceCounters*
8282
RenderStateCacheImpl* pStateCache,
8383
IPipelineState* pPipeline,
8484
const PipelineStateCreateInfo& CreateInfo) :
85-
TBase{pRefCounters},
86-
m_pStateCache{pStateCache},
87-
m_Type{CreateInfo.PSODesc.PipelineType}
85+
TBase{CreateInfo.PSODesc, pRefCounters},
86+
m_pStateCache{pStateCache}
8887
{
8988
m_pPipeline = pPipeline;
9089

@@ -249,7 +248,7 @@ bool ReloadablePipelineState::Reload(ReloadGraphicsPipelineCallbackType ReloadGr
249248
static_assert(PIPELINE_TYPE_COUNT == 5, "Did you add a new pipeline type? You may need to handle it here.");
250249
// Note that all shaders in Create Info are reloadable shaders, so they will automatically redirect all calls
251250
// to the updated internal shader
252-
switch (m_Type)
251+
switch (m_Desc.PipelineType)
253252
{
254253
case PIPELINE_TYPE_GRAPHICS:
255254
case PIPELINE_TYPE_MESH:

0 commit comments

Comments
 (0)