mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-26 14:01:02 +00:00
fixed CRP PSO caches running out of memory
This commit is contained in:
parent
0e692f6fed
commit
68c28996e1
6 changed files with 22 additions and 17 deletions
|
@ -157,9 +157,10 @@ int PSOCache::AddPipeline(const GraphicsPipelineDesc& desc, const char* name)
|
|||
GraphicsPipelineDesc namedDesc = desc;
|
||||
namedDesc.name = name;
|
||||
|
||||
// @NOTE: we keep the original desc and its padding bytes for proper comparison results
|
||||
const uint32_t index = entryCount++;
|
||||
Entry& entry = entries[index];
|
||||
entry.desc = desc; // keep the original desc for proper comparison results
|
||||
memcpy(&entry.desc, &desc, sizeof(entry.desc));
|
||||
entry.handle = CreateGraphicsPipeline(namedDesc);
|
||||
|
||||
return (int)index;
|
||||
|
|
|
@ -168,14 +168,13 @@ void WorldOpaque::ProcessShader(shader_t& shader)
|
|||
const unsigned int stateBits = stage.stateBits & (~GLS_POLYMODE_LINE);
|
||||
int a = 0;
|
||||
|
||||
// @NOTE: we are not using any CTOR because we deliberately want to 0-init the struct
|
||||
// this is necessary for padding bytes not to mess up comparisons in the PSO cache
|
||||
// @NOTE: we 0-init the struct so that padding bytes don't mess up comparisons in the PSO cache
|
||||
GraphicsPipelineDesc desc = {};
|
||||
desc.name = "opaque";
|
||||
desc.rootSignature = RHI_MAKE_NULL_HANDLE();
|
||||
desc.shortLifeTime = true; // the PSO cache is only valid for this map!
|
||||
desc.vertexShader = g_opaque_vs;
|
||||
desc.pixelShader = g_opaque_ps;
|
||||
desc.vertexShader.Set(g_opaque_vs);
|
||||
desc.pixelShader.Set(g_opaque_ps);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::Position, DataType::Float32, 3, 0);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::Normal, DataType::Float32, 3, 0);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::TexCoord, DataType::Float32, 2, 0);
|
||||
|
|
|
@ -169,14 +169,13 @@ void Prepass::ProcessShader(shader_t& shader)
|
|||
Q_assert((stateBits & GLS_DEPTHFUNC_EQUAL) == 0); // depth comparison GE
|
||||
#endif
|
||||
|
||||
// @NOTE: we are not using any CTOR because we deliberately want to 0-init the struct
|
||||
// this is necessary for padding bytes not to mess up comparisons in the PSO cache
|
||||
// @NOTE: we 0-init the struct so that padding bytes don't mess up comparisons in the PSO cache
|
||||
GraphicsPipelineDesc desc = {};
|
||||
desc.name = "pre-pass";
|
||||
desc.rootSignature = RHI_MAKE_NULL_HANDLE();
|
||||
desc.shortLifeTime = true; // the PSO cache is only valid for this map!
|
||||
desc.vertexShader = g_prepass_vs;
|
||||
desc.pixelShader = g_prepass_ps;
|
||||
desc.vertexShader.Set(g_prepass_vs);
|
||||
desc.pixelShader.Set(g_prepass_ps);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::Position, DataType::Float32, 3, 0);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::Normal, DataType::Float32, 3, 0);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::TexCoord, DataType::Float32, 2, 0);
|
||||
|
|
|
@ -185,14 +185,13 @@ void WorldTransp::ProcessShader(shader_t& shader)
|
|||
{
|
||||
int a = 0;
|
||||
|
||||
// @NOTE: we are not using any CTOR because we deliberately want to 0-init the struct
|
||||
// this is necessary for padding bytes not to mess up comparisons in the PSO cache
|
||||
// @NOTE: we 0-init the struct so that padding bytes don't mess up comparisons in the PSO cache
|
||||
GraphicsPipelineDesc desc = {};
|
||||
desc.name = "transp";
|
||||
desc.rootSignature = RHI_MAKE_NULL_HANDLE();
|
||||
desc.shortLifeTime = true; // the PSO cache is only valid for this map!
|
||||
desc.vertexShader = g_transp_draw_vs;
|
||||
desc.pixelShader = g_transp_draw_ps;
|
||||
desc.vertexShader.Set(g_transp_draw_vs);
|
||||
desc.pixelShader.Set(g_transp_draw_ps);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::Position, DataType::Float32, 3, 0);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::Normal, DataType::Float32, 3, 0);
|
||||
desc.vertexLayout.AddAttribute(a++, ShaderSemantic::TexCoord, DataType::Float32, 2, 0);
|
||||
|
|
|
@ -4139,13 +4139,13 @@ namespace RHI
|
|||
{
|
||||
ASSERT_DR_DISABLED();
|
||||
|
||||
RootSignature rhiSignature = { 0 };
|
||||
RootSignature rhiSignature = {};
|
||||
rhiSignature.genericTableIndex = UINT32_MAX;
|
||||
rhiSignature.samplerTableIndex = UINT32_MAX;
|
||||
rhiSignature.genericDescCount = 0;
|
||||
rhiSignature.samplerDescCount = rhiDesc.samplerCount;
|
||||
|
||||
bool shaderVis[ShaderStage::Count] = { 0 };
|
||||
bool shaderVis[ShaderStage::Count] = {};
|
||||
|
||||
//
|
||||
// root constants
|
||||
|
|
|
@ -262,7 +262,7 @@ namespace RHI
|
|||
struct RootSignatureDesc
|
||||
{
|
||||
RootSignatureDesc() = default;
|
||||
RootSignatureDesc(const char* name_)
|
||||
explicit RootSignatureDesc(const char* name_)
|
||||
{
|
||||
name = name_;
|
||||
}
|
||||
|
@ -308,7 +308,14 @@ namespace RHI
|
|||
}
|
||||
|
||||
template<uint32_t N>
|
||||
ShaderByteCode(const uint8_t (&byteCode)[N])
|
||||
explicit ShaderByteCode(const uint8_t (&byteCode)[N])
|
||||
{
|
||||
data = byteCode;
|
||||
byteCount = N;
|
||||
}
|
||||
|
||||
template<uint32_t N>
|
||||
void Set(const uint8_t (&byteCode)[N])
|
||||
{
|
||||
data = byteCode;
|
||||
byteCount = N;
|
||||
|
|
Loading…
Reference in a new issue