Optimize various rendering stages to skip loading shader when effect is disables
This commit is contained in:
@@ -202,16 +202,14 @@ GPUTexture* DepthOfFieldPass::getDofBokehShape(DepthOfFieldSettings& dofSettings
|
||||
|
||||
void DepthOfFieldPass::Render(RenderContext& renderContext, GPUTexture*& frame, GPUTexture*& tmp)
|
||||
{
|
||||
if (!_platformSupportsDoF || checkIfSkipPass())
|
||||
DepthOfFieldSettings& dofSettings = renderContext.List->Settings.DepthOfField;
|
||||
const bool useDoF = EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::DepthOfField) && dofSettings.Enabled;
|
||||
if (!useDoF || _platformSupportsDoF || checkIfSkipPass())
|
||||
return;
|
||||
auto device = GPUDevice::Instance;
|
||||
auto context = device->GetMainContext();
|
||||
const auto depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
const auto shader = _shader->GetShader();
|
||||
DepthOfFieldSettings& dofSettings = renderContext.List->Settings.DepthOfField;
|
||||
const bool useDoF = _platformSupportsDoF && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::DepthOfField) && dofSettings.Enabled;
|
||||
if (!useDoF)
|
||||
return;
|
||||
PROFILE_GPU_CPU("Depth Of Field");
|
||||
|
||||
context->ResetSR();
|
||||
|
||||
@@ -35,7 +35,6 @@ PACK_STRUCT(struct EyeAdaptationData {
|
||||
|
||||
void EyeAdaptationPass::Render(RenderContext& renderContext, GPUTexture* colorBuffer)
|
||||
{
|
||||
// Cache data
|
||||
auto device = GPUDevice::Instance;
|
||||
auto context = device->GetMainContext();
|
||||
auto& view = renderContext.View;
|
||||
@@ -45,12 +44,8 @@ void EyeAdaptationPass::Render(RenderContext& renderContext, GPUTexture* colorBu
|
||||
//const float frameDelta = Time::ElapsedGameTime.GetTotalSeconds();
|
||||
const float frameDelta = time - renderContext.Buffers->LastEyeAdaptationTime;
|
||||
renderContext.Buffers->LastEyeAdaptationTime = 0.0f;
|
||||
|
||||
// Optionally skip the rendering
|
||||
if (checkIfSkipPass() || (view.Flags & ViewFlags::EyeAdaptation) == ViewFlags::None || settings.Mode == EyeAdaptationMode::None)
|
||||
{
|
||||
if ((view.Flags & ViewFlags::EyeAdaptation) == ViewFlags::None || settings.Mode == EyeAdaptationMode::None || checkIfSkipPass())
|
||||
return;
|
||||
}
|
||||
|
||||
PROFILE_GPU_CPU("Eye Adaptation");
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ void MotionBlurPass::RenderDebug(RenderContext& renderContext, GPUTextureView* f
|
||||
{
|
||||
auto context = GPUDevice::Instance->GetMainContext();
|
||||
const auto motionVectors = renderContext.Buffers->MotionVectors;
|
||||
if (!motionVectors->IsAllocated() || checkIfSkipPass())
|
||||
if (!motionVectors || !motionVectors->IsAllocated() || checkIfSkipPass())
|
||||
{
|
||||
context->Draw(frame);
|
||||
return;
|
||||
|
||||
@@ -195,7 +195,7 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input,
|
||||
bool useLensFlares = EnumHasAnyFlags(view.Flags, ViewFlags::LensFlares) && settings.LensFlares.Intensity > 0.0f && useBloom;
|
||||
|
||||
// Ensure to have valid data and if at least one effect should be applied
|
||||
if (checkIfSkipPass() || !(useBloom || useToneMapping || useCameraArtifacts))
|
||||
if (!(useBloom || useToneMapping || useCameraArtifacts) || checkIfSkipPass())
|
||||
{
|
||||
// Resources are missing. Do not perform rendering. Just copy raw frame
|
||||
context->SetViewportAndScissors((float)output->Width(), (float)output->Height());
|
||||
|
||||
Reference in New Issue
Block a user