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

Commit 77da772

Browse files
committed
Workaround to disable all compute shaders for OpenGL ES 3 in Unity 2017.3 and older
1 parent afe4b85 commit 77da772

10 files changed

+85
-0
lines changed

PostProcessing/Shaders/API/OpenGL.hlsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@
4848

4949
#define FXAA_HLSL_3 1
5050
#define SMAA_HLSL_3 1
51+
52+
// pragma exclude_renderers is only supported since Unity 2018.1 for compute shaders
53+
#if UNITY_VERSION < 201810 && !defined(SHADER_API_GLCORE)
54+
# define DISABLE_COMPUTE_SHADERS 1
55+
# define TRIVIAL_COMPUTE_KERNEL(name) [numthreads(1, 1, 1)] void name() {}
56+
#endif

PostProcessing/Shaders/Builtins/AutoExposure.compute

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ float InterpolateExposure(float newExposure, float oldExposure)
3636
return exposure;
3737
}
3838

39+
#ifdef DISABLE_COMPUTE_SHADERS
40+
41+
TRIVIAL_COMPUTE_KERNEL(MAIN)
42+
43+
#else
44+
3945
[numthreads(HISTOGRAM_THREAD_X, HISTOGRAM_BINS / HISTOGRAM_THREAD_X, 1)]
4046
void MAIN(uint2 groupThreadId : SV_GroupThreadID)
4147
{
@@ -83,3 +89,5 @@ void MAIN(uint2 groupThreadId : SV_GroupThreadID)
8389
#endif
8490
}
8591
}
92+
93+
#endif // DISABLE_COMPUTE_SHADERS

PostProcessing/Shaders/Builtins/ExposureHistogram.compute

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ CBUFFER_END
1919
groupshared uint gs_histogram[HISTOGRAM_BINS];
2020

2121
#pragma kernel KEyeHistogram
22+
23+
#ifdef DISABLE_COMPUTE_SHADERS
24+
25+
TRIVIAL_COMPUTE_KERNEL(KEyeHistogram)
26+
TRIVIAL_COMPUTE_KERNEL(KEyeHistogramClear)
27+
28+
#else
29+
2230
[numthreads(HISTOGRAM_THREAD_X, HISTOGRAM_THREAD_Y, 1)]
2331
void KEyeHistogram(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupThreadId : SV_GroupThreadID)
2432
{
@@ -74,3 +82,5 @@ void KEyeHistogramClear(uint dispatchThreadId : SV_DispatchThreadID)
7482
if (dispatchThreadId < HISTOGRAM_BINS)
7583
_HistogramBuffer[dispatchThreadId] = 0u;
7684
}
85+
86+
#endif // DISABLE_COMPUTE_SHADERS

PostProcessing/Shaders/Builtins/GaussianDownsample.compute

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ void BlurVertically(uint2 pixelCoord, uint topMostIndex)
116116
}
117117

118118
#pragma kernel KMain
119+
120+
#ifdef DISABLE_COMPUTE_SHADERS
121+
122+
TRIVIAL_COMPUTE_KERNEL(KMain)
123+
124+
#else
125+
119126
[numthreads(8, 8, 1)]
120127
void KMain(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, uint2 dispatchThreadId : SV_DispatchThreadID)
121128
{
@@ -145,3 +152,5 @@ void KMain(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, u
145152
// Vertically blur the pixels in LDS and write the result to memory
146153
BlurVertically(dispatchThreadId, (groupThreadId.y << 3u) + groupThreadId.x);
147154
}
155+
156+
#endif // DISABLE_COMPUTE_SHADERS

PostProcessing/Shaders/Builtins/Lut3DBaker.compute

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ void Eval(uint3 id)
159159
#define GROUP_SIZE_Z 8
160160
#endif
161161

162+
163+
#ifdef DISABLE_COMPUTE_SHADERS
164+
165+
TRIVIAL_COMPUTE_KERNEL(KGenLut3D_NoTonemap)
166+
TRIVIAL_COMPUTE_KERNEL(KGenLut3D_AcesTonemap)
167+
TRIVIAL_COMPUTE_KERNEL(KGenLut3D_NeutralTonemap)
168+
TRIVIAL_COMPUTE_KERNEL(KGenLut3D_CustomTonemap)
169+
170+
#else
171+
162172
[numthreads(GROUP_SIZE_XY, GROUP_SIZE_XY, GROUP_SIZE_Z)]
163173
void KGenLut3D_NoTonemap(uint3 id : SV_DispatchThreadID) { Eval(id); }
164174

@@ -170,3 +180,5 @@ void KGenLut3D_NeutralTonemap(uint3 id : SV_DispatchThreadID) { Eval(id); }
170180

171181
[numthreads(GROUP_SIZE_XY, GROUP_SIZE_XY, GROUP_SIZE_Z)]
172182
void KGenLut3D_CustomTonemap(uint3 id : SV_DispatchThreadID) { Eval(id); }
183+
184+
#endif // DISABLE_COMPUTE_SHADERS

PostProcessing/Shaders/Builtins/MultiScaleVODownsample1.compute

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ float Linearize(uint2 st)
5353

5454
groupshared float g_CacheW[256];
5555

56+
#ifdef DISABLE_COMPUTE_SHADERS
57+
58+
TRIVIAL_COMPUTE_KERNEL(main)
59+
60+
#else
61+
5662
[numthreads(8, 8, 1)]
5763
void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID)
5864
{
@@ -83,3 +89,5 @@ void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_Group
8389
}
8490

8591
}
92+
93+
#endif

PostProcessing/Shaders/Builtins/MultiScaleVODownsample2.compute

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ RWTexture2DArray<float> DS8xAtlas;
3030
RWTexture2D<float> DS16x;
3131
RWTexture2DArray<float> DS16xAtlas;
3232

33+
#ifdef DISABLE_COMPUTE_SHADERS
34+
35+
TRIVIAL_COMPUTE_KERNEL(main)
36+
37+
#else
38+
3339
[numthreads(8, 8, 1)]
3440
void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID)
3541
{
@@ -50,3 +56,5 @@ void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_Group
5056
DS16xAtlas[uint3(stAtlas, stSlice)] = m1;
5157
}
5258
}
59+
60+
#endif // DISABLE_COMPUTE_SHADERS

PostProcessing/Shaders/Builtins/MultiScaleVORender.compute

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ float TestSamples(uint centerIdx, uint x, uint y, float invDepth, float invThick
118118
}
119119
}
120120

121+
#ifdef DISABLE_COMPUTE_SHADERS
122+
123+
TRIVIAL_COMPUTE_KERNEL(MAIN)
124+
125+
#else
126+
121127
[numthreads(THREAD_COUNT_X, THREAD_COUNT_Y, 1)]
122128
void MAIN(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID)
123129
{
@@ -184,3 +190,5 @@ void MAIN(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_Group
184190
#endif
185191
Occlusion[OutPixel] = lerp(1, ao, gIntensity);
186192
}
193+
194+
#endif // DISABLE_COMPUTE_SHADERS

PostProcessing/Shaders/Builtins/MultiScaleVOUpsample.compute

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ float BilateralUpsample(float HiDepth, float HiAO, float4 LowDepths, float4 LowA
188188
return HiAO * WeightedSum / TotalWeight;
189189
}
190190

191+
#ifdef DISABLE_COMPUTE_SHADERS
192+
193+
TRIVIAL_COMPUTE_KERNEL(MAIN)
194+
195+
#else
196+
191197
[numthreads(8, 8, 1)]
192198
void MAIN(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID)
193199
{
@@ -245,3 +251,5 @@ void MAIN(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_Group
245251
AoResult[OutST + int2(-1, -1)] = BilateralUpsample(HiDepths.w, HiSSAOs.w, LoDepths.wxyz, LoSSAOs.wxyz);
246252
#endif
247253
}
254+
255+
#endif // DISABLE_COMPUTE_SHADERS

PostProcessing/Shaders/Builtins/Texture3DLerp.compute

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Texture3D _To;
1616

1717
#define GROUP_SIZE 8
1818

19+
#ifdef DISABLE_COMPUTE_SHADERS
20+
21+
TRIVIAL_COMPUTE_KERNEL(KTexture3DLerp)
22+
23+
#else
24+
1925
[numthreads(GROUP_SIZE, GROUP_SIZE, GROUP_SIZE)]
2026
void KTexture3DLerp(uint3 id : SV_DispatchThreadID)
2127
{
@@ -26,3 +32,5 @@ void KTexture3DLerp(uint3 id : SV_DispatchThreadID)
2632
_Output[id] = float4(lerp(from, to, _Params.xxx), 1.0);
2733
}
2834
}
35+
36+
#endif // DISABLE_COMPUTE_SHADERS

0 commit comments

Comments
 (0)