MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / GetPSO

Method GetPSO

Components/src/BoundBoxRenderer.cpp:94–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92)";
93
94IPipelineState* BoundBoxRenderer::GetPSO(const PSOKey& Key)
95{
96 auto it = m_PSOs.find(Key);
97 if (it != m_PSOs.end())
98 return it->second;
99
100 RenderDeviceWithCache_N Device{m_pDevice, m_pStateCache};
101
102 RefCntAutoPtr<IShaderSourceInputStreamFactory> pMemorySourceFactory =
103 CreateMemoryShaderSourceFactory({MemoryShaderSourceFileInfo{"PSMainGenerated.generated", !m_PSMainSource.empty() ? m_PSMainSource.c_str() : DefaultPSMain}});
104 RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory =
105 CreateCompoundShaderSourceFactory({&DiligentFXShaderSourceStreamFactory::GetInstance(), pMemorySourceFactory});
106
107 ShaderCreateInfo ShaderCI;
108 ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
109 ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory;
110 if (m_PackMatrixRowMajor)
111 ShaderCI.CompileFlags |= SHADER_COMPILE_FLAG_PACK_MATRIX_ROW_MAJOR;
112 if (m_AsyncShaders)
113 ShaderCI.CompileFlags |= SHADER_COMPILE_FLAG_ASYNCHRONOUS;
114
115 ShaderMacroHelper Macros;
116 Macros
117 .Add("CONVERT_OUTPUT_TO_SRGB", Key.ConvertOutputToSRGB)
118 .Add("COMPUTE_MOTION_VECTORS", Key.ComputeMotionVectors);
119 ShaderCI.Macros = Macros;
120
121 RefCntAutoPtr<IShader> pVS;
122 {
123 ShaderCI.Desc = {"Bound Box VS", SHADER_TYPE_VERTEX, true};
124 ShaderCI.EntryPoint = "BoundBoxVS";
125 ShaderCI.FilePath = "BoundBox.vsh";
126
127 pVS = Device.CreateShader(ShaderCI);
128 if (!pVS)
129 {
130 UNEXPECTED("Failed to create bound box vertex shader");
131 return nullptr;
132 }
133 }
134
135 RefCntAutoPtr<IShader> pPS;
136 {
137 ShaderCI.Desc = {"Bound Box PS", SHADER_TYPE_PIXEL, true};
138 ShaderCI.EntryPoint = "main";
139 ShaderCI.FilePath = "BoundBox.psh";
140
141 pPS = Device.CreateShader(ShaderCI);
142 if (!pPS)
143 {
144 UNEXPECTED("Failed to create bound box pixel shader");
145 return nullptr;
146 }
147 }
148
149 GraphicsPipelineStateCreateInfoX PsoCI{"Bound Box PSO"};
150 PsoCI
151 .AddShader(pVS)

Callers

nothing calls this directly

Calls 1

CreateShaderMethod · 0.80

Tested by

no test coverage detected