skip SSAO texture read if SSAO is disabled

This commit is contained in:
Mathias Agopian
2022-07-29 16:07:43 -07:00
committed by Mathias Agopian
parent b9b4b7c64d
commit e0eaaf4fb9
3 changed files with 8 additions and 2 deletions

View File

@@ -168,7 +168,7 @@ void PerViewUniforms::prepareSSAO(Handle<HwTexture> ssao,
const float edgeDistance = 1.0f / options.bilateralThreshold;
auto& s = mUniforms.edit();
s.aoSamplingQualityAndEdgeDistance =
options.enabled && highQualitySampling ? edgeDistance : 0.0f;
options.enabled ? (highQualitySampling ? edgeDistance : 0.0f) : -1.0f;
s.aoBentNormals = options.enabled && options.bentNormals ? 1.0f : 0.0f;
}

View File

@@ -83,7 +83,7 @@ struct PerViewUib { // NOLINT(cppcoreguidelines-pro-type-member-init)
float needsAlphaChannel;
// AO
float aoSamplingQualityAndEdgeDistance; // 0: bilinear, !0: bilateral edge distance
float aoSamplingQualityAndEdgeDistance; // <0: no AO, 0: bilinear, !0: bilateral edge distance
float aoBentNormals; // 0: no AO bent normal, >0.0 AO bent normals
float aoReserved0;
float aoReserved1;

View File

@@ -25,6 +25,12 @@ struct SSAOInterpolationCache {
float evaluateSSAO(inout SSAOInterpolationCache cache) {
#if defined(BLEND_MODE_OPAQUE) || defined(BLEND_MODE_MASKED)
if (frameUniforms.aoSamplingQualityAndEdgeDistance < 0.0) {
// SSAO is disabled
return 1.0;
}
// Upscale the SSAO buffer in real-time, in high quality mode we use a custom bilinear
// filter. This adds about 2.0ms @ 250MHz on Pixel 4.