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

Method Prepare

Components/src/EnvMapRenderer.cpp:198–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void EnvMapRenderer::Prepare(IDeviceContext* pContext,
199 const RenderAttribs& Attribs,
200 const HLSL::ToneMappingAttribs& ToneMapping)
201{
202 if (Attribs.pEnvMap == nullptr)
203 {
204 UNEXPECTED("Environment map must not be null");
205 return;
206 }
207
208 const PSOKey::ENV_MAP_TYPE EnvMapType = Attribs.pEnvMap->GetTexture()->GetDesc().IsCube() ?
209 PSOKey::ENV_MAP_TYPE_CUBE :
210 PSOKey::ENV_MAP_TYPE_SPHERE;
211
212 m_pCurrentPSO = GetPSO({ToneMapping.iToneMappingMode, Attribs.ConvertOutputToSRGB, Attribs.ComputeMotionVectors, EnvMapType});
213 if (m_pCurrentPSO == nullptr)
214 {
215 UNEXPECTED("Failed to get PSO");
216 return;
217 }
218
219 m_pEnvMapVar->Set(Attribs.pEnvMap);
220
221 if (m_ShaderAttribs)
222 {
223 if (std::memcmp(&m_ShaderAttribs->ToneMapping, &ToneMapping, sizeof(ToneMapping)) != 0 ||
224 m_ShaderAttribs->AverageLogLum != Attribs.AverageLogLum ||
225 m_ShaderAttribs->MipLevel != Attribs.MipLevel ||
226 m_ShaderAttribs->Alpha != Attribs.Alpha)
227 {
228 m_ShaderAttribs->ToneMapping = ToneMapping;
229 m_ShaderAttribs->AverageLogLum = Attribs.AverageLogLum;
230 m_ShaderAttribs->MipLevel = Attribs.MipLevel;
231 m_ShaderAttribs->Alpha = Attribs.Alpha;
232
233 pContext->UpdateBuffer(m_RenderAttribsCB, 0, sizeof(EnvMapShaderAttribs), m_ShaderAttribs.get(), RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
234 StateTransitionDesc Barrier{m_RenderAttribsCB, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_CONSTANT_BUFFER, STATE_TRANSITION_FLAG_UPDATE_STATE};
235 pContext->TransitionResourceStates(1, &Barrier);
236 }
237 }
238 else
239 {
240 MapHelper<EnvMapShaderAttribs> EnvMapAttribs{pContext, m_RenderAttribsCB, MAP_WRITE, MAP_FLAG_DISCARD};
241 EnvMapAttribs->ToneMapping = ToneMapping;
242 EnvMapAttribs->AverageLogLum = Attribs.AverageLogLum;
243 EnvMapAttribs->MipLevel = Attribs.MipLevel;
244 EnvMapAttribs->Alpha = Attribs.Alpha;
245 }
246}
247
248void EnvMapRenderer::Render(IDeviceContext* pContext)
249{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected