Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 78c7b57

Browse files
committed
Add runtime checks if strippable shaders are available
1 parent f0e8156 commit 78c7b57

13 files changed

+48
-13
lines changed

PostProcessing/Editor/PostProcessResourceStripper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void Apply(BuildTarget target)
103103
resources.shaders.scalableAO = null;
104104
}
105105

106-
if (stripping.stripUnsupportedShaders && !RuntimeUtilities.supportsMotionVectors)
106+
if (stripping.stripUnsupportedShaders && !SystemInfo.supportsMotionVectors)
107107
{
108108
resources.shaders.motionBlur = null;
109109
resources.shaders.temporalAntialiasing = null;

PostProcessing/Runtime/Effects/AmbientOcclusion.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,20 @@ public override bool IsEnabledAndSupported(PostProcessRenderContext context)
7171

7272
if (mode.value == AmbientOcclusionMode.ScalableAmbientObscurance)
7373
{
74-
state &= !RuntimeUtilities.scriptableRenderPipelineActive;
74+
state &= !RuntimeUtilities.scriptableRenderPipelineActive
75+
&& context.resources.shaders.scalableAO
76+
&& context.resources.shaders.scalableAO.isSupported;
7577
}
7678
else if (mode.value == AmbientOcclusionMode.MultiScaleVolumetricObscurance)
7779
{
7880
#if UNITY_2017_1_OR_NEWER
7981
state &= SystemInfo.supportsComputeShaders
82+
&& context.resources.shaders.multiScaleAO
83+
&& context.resources.shaders.multiScaleAO.isSupported
84+
&& context.resources.computeShaders.multiScaleAODownsample1
85+
&& context.resources.computeShaders.multiScaleAODownsample2
86+
&& context.resources.computeShaders.multiScaleAORender
87+
&& context.resources.computeShaders.multiScaleAOUpsample
8088
&& SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat)
8189
&& SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RHalf)
8290
&& SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.R8);

PostProcessing/Runtime/Effects/AutoExposure.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public override bool IsEnabledAndSupported(PostProcessRenderContext context)
4040
{
4141
return enabled.value
4242
&& SystemInfo.supportsComputeShaders
43-
&& SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat);
43+
&& SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat)
44+
&& context.resources.shaders.autoExposure
45+
&& context.resources.shaders.autoExposure.isSupported
46+
&& context.resources.computeShaders.exposureHistogram;
4447
}
4548
}
4649

PostProcessing/Runtime/Effects/Fog.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ internal bool IsEnabledAndSupported(PostProcessRenderContext context)
2121
return enabled
2222
&& RenderSettings.fog
2323
&& !RuntimeUtilities.scriptableRenderPipelineActive
24+
&& context.resources.shaders.deferredFog
25+
&& context.resources.shaders.deferredFog.isSupported
2426
&& context.camera.actualRenderingPath == RenderingPath.DeferredShading; // In forward fog is already done at shader level
2527
}
2628

PostProcessing/Runtime/Effects/ScreenSpaceReflections.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public override bool IsEnabledAndSupported(PostProcessRenderContext context)
5252
&& context.camera.actualRenderingPath == RenderingPath.DeferredShading
5353
&& SystemInfo.supportsMotionVectors
5454
&& SystemInfo.supportsComputeShaders
55-
&& SystemInfo.copyTextureSupport > CopyTextureSupport.None;
55+
&& SystemInfo.copyTextureSupport > CopyTextureSupport.None
56+
&& context.resources.shaders.screenSpaceReflections
57+
&& context.resources.shaders.screenSpaceReflections.isSupported
58+
&& context.resources.computeShaders.gaussianDownsample;
5659
}
5760
}
5861

PostProcessing/Runtime/Monitors/HistogramMonitor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ internal override bool NeedsHalfRes()
5353
return true;
5454
}
5555

56+
internal override bool ShaderResourcesAvailable(PostProcessRenderContext context)
57+
{
58+
return context.resources.computeShaders.gammaHistogram;
59+
}
60+
5661
internal override void Render(PostProcessRenderContext context)
5762
{
5863
CheckOutput(width, height);

PostProcessing/Runtime/Monitors/LightMeterMonitor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public sealed class LightMeterMonitor : Monitor
1111
// Note: only works with HDR grading, as this monitor only makes sense when working in HDR
1212
public bool showCurves = true;
1313

14+
internal override bool ShaderResourcesAvailable(PostProcessRenderContext context)
15+
{
16+
return context.resources.shaders.lightMeter && context.resources.shaders.lightMeter.isSupported;
17+
}
18+
1419
internal override void Render(PostProcessRenderContext context)
1520
{
1621
CheckOutput(width, height);

PostProcessing/Runtime/Monitors/Monitor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ public abstract class Monitor
1414

1515
internal bool requested = false;
1616

17-
public bool IsRequestedAndSupported()
17+
public bool IsRequestedAndSupported(PostProcessRenderContext context)
1818
{
1919
return requested
20-
&& SystemInfo.supportsComputeShaders;
20+
&& SystemInfo.supportsComputeShaders
21+
&& ShaderResourcesAvailable(context);
2122
}
2223

24+
internal abstract bool ShaderResourcesAvailable(PostProcessRenderContext context);
25+
2326
internal virtual bool NeedsHalfRes()
2427
{
2528
return false;

PostProcessing/Runtime/Monitors/VectorscopeMonitor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ internal override bool NeedsHalfRes()
3333
return true;
3434
}
3535

36+
internal override bool ShaderResourcesAvailable(PostProcessRenderContext context)
37+
{
38+
return context.resources.computeShaders.vectorscope;
39+
}
40+
3641
internal override void Render(PostProcessRenderContext context)
3742
{
3843
CheckOutput(size, size);

PostProcessing/Runtime/Monitors/WaveformMonitor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ internal override bool NeedsHalfRes()
4545
return true;
4646
}
4747

48+
49+
internal override bool ShaderResourcesAvailable(PostProcessRenderContext context)
50+
{
51+
return context.resources.computeShaders.waveform;
52+
}
53+
4854
internal override void Render(PostProcessRenderContext context)
4955
{
5056
// Waveform show localized data, so width depends on the aspect ratio

0 commit comments

Comments
 (0)