| 154 | } |
| 155 | |
| 156 | void HnPostProcessTask::PostProcessingTechnique::PreparePSO(TEXTURE_FORMAT RTVFormat) |
| 157 | { |
| 158 | bool IsDirty = PSO && PSO->GetGraphicsPipelineDesc().RTVFormats[0] != RTVFormat; |
| 159 | |
| 160 | { |
| 161 | const bool _ConvertOutputToSRGB = !PPTask.m_UseTAA && PPTask.m_Params.ConvertOutputToSRGB; |
| 162 | if (ConvertOutputToSRGB != _ConvertOutputToSRGB) |
| 163 | { |
| 164 | ConvertOutputToSRGB = _ConvertOutputToSRGB; |
| 165 | IsDirty = true; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | { |
| 170 | const int _ToneMappingMode = !PPTask.m_UseTAA ? PPTask.m_Params.ToneMapping.iToneMappingMode : 0; |
| 171 | if (ToneMappingMode != _ToneMappingMode) |
| 172 | { |
| 173 | ToneMappingMode = _ToneMappingMode; |
| 174 | IsDirty = true; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | { |
| 179 | const CoordinateGridRenderer::FEATURE_FLAGS _GridFeatureFlags = !PPTask.m_UseTAA ? PPTask.m_Params.GridFeatureFlags : CoordinateGridRenderer::FEATURE_FLAG_NONE; |
| 180 | if (GridFeatureFlags != _GridFeatureFlags) |
| 181 | { |
| 182 | GridFeatureFlags = _GridFeatureFlags; |
| 183 | IsDirty = true; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (IsDirty) |
| 188 | PSO.Release(); |
| 189 | |
| 190 | if (PSO) |
| 191 | return; |
| 192 | |
| 193 | try |
| 194 | { |
| 195 | HnRenderDelegate* RenderDelegate = static_cast<HnRenderDelegate*>(PPTask.m_RenderIndex->GetRenderDelegate()); |
| 196 | |
| 197 | // RenderDeviceWithCache_E throws exceptions in case of errors |
| 198 | RenderDeviceWithCache_E Device{RenderDelegate->GetDevice(), RenderDelegate->GetRenderStateCache()}; |
| 199 | |
| 200 | ShaderMacroHelper Macros; |
| 201 | Macros.Add("CONVERT_OUTPUT_TO_SRGB", ConvertOutputToSRGB); |
| 202 | Macros.Add("TONE_MAPPING_MODE", ToneMappingMode); |
| 203 | if (GridFeatureFlags != CoordinateGridRenderer::FEATURE_FLAG_NONE) |
| 204 | { |
| 205 | Macros.Add("ENABLE_GRID", 1); |
| 206 | CoordinateGridRenderer::AddShaderMacros(GridFeatureFlags, Macros); |
| 207 | } |
| 208 | |
| 209 | GraphicsPipelineStateCreateInfoX PsoCI{"Post process"}; |
| 210 | CreateShaders(Device, "HnPostProcess.psh", "Post-process PS", Macros, PsoCI) |
| 211 | .AddRenderTarget(RTVFormat) |
| 212 | .SetDepthStencilDesc(DSS_DisableDepth) |
| 213 | .SetRasterizerDesc(RS_SolidFillNoCull) |
no test coverage detected