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

Method GetPSO

Components/src/EnvMapRenderer.cpp:99–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97)";
98
99IPipelineState* EnvMapRenderer::GetPSO(const PSOKey& Key)
100{
101 auto it = m_PSOs.find(Key);
102 if (it != m_PSOs.end())
103 return it->second;
104
105 RenderDeviceWithCache_N Device{m_pDevice, m_pStateCache};
106
107 std::string PSMainSource = m_PSMainSource;
108 if (PSMainSource.empty())
109 PSMainSource = DefaultPSMain;
110
111 RefCntAutoPtr<IShaderSourceInputStreamFactory> pMemorySourceFactory =
112 CreateMemoryShaderSourceFactory({MemoryShaderSourceFileInfo{"PSMainGenerated.generated", PSMainSource}});
113 RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory =
114 CreateCompoundShaderSourceFactory({&DiligentFXShaderSourceStreamFactory::GetInstance(), pMemorySourceFactory});
115
116 ShaderCreateInfo ShaderCI;
117 ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
118 ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory;
119 ShaderCI.CompileFlags = m_PackMatrixRowMajor ? SHADER_COMPILE_FLAG_PACK_MATRIX_ROW_MAJOR : SHADER_COMPILE_FLAG_NONE;
120
121 ShaderMacroHelper Macros;
122 Macros
123 .Add("CONVERT_OUTPUT_TO_SRGB", Key.ConvertOutputToSRGB)
124 .Add("TONE_MAPPING_MODE", Key.ToneMappingMode)
125 .Add("COMPUTE_MOTION_VECTORS", Key.ComputeMotionVectors)
126 .Add("ENV_MAP_TYPE_CUBE", static_cast<int>(PSOKey::ENV_MAP_TYPE_CUBE))
127 .Add("ENV_MAP_TYPE_SPHERE", static_cast<int>(PSOKey::ENV_MAP_TYPE_SPHERE))
128 .Add("ENV_MAP_TYPE", static_cast<int>(Key.EnvMapType));
129 ShaderCI.Macros = Macros;
130
131 RefCntAutoPtr<IShader> pVS;
132 {
133 ShaderCI.Desc = {"Environment Map VS", SHADER_TYPE_VERTEX, true};
134 ShaderCI.EntryPoint = "main";
135 ShaderCI.FilePath = "EnvMap.vsh";
136
137 pVS = Device.CreateShader(ShaderCI);
138 if (!pVS)
139 {
140 UNEXPECTED("Failed to create environment map vertex shader");
141 return nullptr;
142 }
143 }
144
145 // Create pixel shader
146 RefCntAutoPtr<IShader> pPS;
147 {
148 ShaderCI.Desc = {"Environment Map PS", SHADER_TYPE_PIXEL, true};
149 ShaderCI.EntryPoint = "main";
150 ShaderCI.FilePath = "EnvMap.psh";
151
152 pPS = Device.CreateShader(ShaderCI);
153 if (!pPS)
154 {
155 UNEXPECTED("Failed to create environment map pixel shader");
156 return nullptr;

Callers

nothing calls this directly

Calls 1

CreateShaderMethod · 0.80

Tested by

no test coverage detected