Skip to content

Commit 9ba9158

Browse files
Fixed compute based effects not supported on OpenGLES
1 parent 30f11be commit 9ba9158

7 files changed

Lines changed: 35 additions & 30 deletions

File tree

com.unity.postprocessing/PostProcessing/Editor/Effects/AmbientOcclusionEditor.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,13 @@ public override void OnInspectorGUI()
5353
{
5454
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support which is not available on this platform.", MessageType.Error);
5555
}
56-
else if (EditorUtilities.isTargetingWebGL)
57-
{
58-
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (WebGPU) when running on Web.", MessageType.Warning);
59-
}
60-
else if(EditorUtilities.isTargetingAndroid)
56+
if (EditorUtilities.isTargetingOpenGLES)
6157
{
62-
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
58+
EditorGUILayout.HelpBox("\"Multi-scale volumetric obscurance requires compute shader support which is not available for OpenGLES.", MessageType.Warning);
6359
}
64-
else if(EditorUtilities.isTargetingQNX)
60+
else if (EditorUtilities.isTargetingWebGL)
6561
{
66-
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support when running on QNX.", MessageType.Warning);
62+
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (WebGPU) when running on Web.", MessageType.Warning);
6763
}
6864

6965
PropertyField(m_ThicknessModifier);

com.unity.postprocessing/PostProcessing/Editor/Effects/AutoExposureEditor.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,13 @@ public override void OnInspectorGUI()
3535
{
3636
EditorGUILayout.HelpBox("Auto exposure requires compute shader support which is not available on this platform.", MessageType.Error);
3737
}
38-
else if (EditorUtilities.isTargetingWebGL)
39-
{
40-
EditorGUILayout.HelpBox("Auto exposure requires compute shader support (WebGPU) when running on Web.", MessageType.Warning);
41-
}
42-
else if (EditorUtilities.isTargetingAndroid)
38+
if (EditorUtilities.isTargetingOpenGLES)
4339
{
44-
EditorGUILayout.HelpBox("Auto exposure requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
40+
EditorGUILayout.HelpBox("Auto exposure requires compute shader support which is not available for OpenGLES.", MessageType.Warning);
4541
}
46-
else if (EditorUtilities.isTargetingQNX)
42+
else if (EditorUtilities.isTargetingWebGL)
4743
{
48-
EditorGUILayout.HelpBox("Auto exposure requires compute shader support when running on QNX.", MessageType.Warning);
44+
EditorGUILayout.HelpBox("Auto exposure requires compute shader support (WebGPU) when running on Web.", MessageType.Warning);
4945
}
5046

5147
EditorUtilities.DrawHeaderLabel("Exposure");

com.unity.postprocessing/PostProcessing/Editor/Utils/EditorUtilities.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using UnityEngine;
55
using UnityEngine.Assertions;
6+
using UnityEngine.Rendering;
67
using UnityEngine.Rendering.PostProcessing;
78

89
#if XR_MANAGEMENT_4_0_1_OR_NEWER
@@ -80,14 +81,27 @@ public static bool isTargetingAndroid
8081
}
8182

8283
/// <summary>
83-
/// Returns <c>true</c> if the current target is QNX, <c>false</c> otherwise.
84+
/// Returns <c>true</c> if the current build targets OpenGLES, <c>false</c> otherwise.
8485
/// </summary>
85-
public static bool isTargetingQNX
86+
public static bool isTargetingOpenGLES
8687
{
8788
get
8889
{
89-
var t = EditorUserBuildSettings.activeBuildTarget;
90-
return t == BuildTarget.QNX;
90+
var buildTargetAPIs = PlayerSettings.GetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget);
91+
92+
foreach (var api in buildTargetAPIs)
93+
{
94+
if (api == GraphicsDeviceType.OpenGLES3
95+
#if !UNITY_2023_1_OR_NEWER
96+
|| api == GraphicsDeviceType.OpenGLES2
97+
#endif
98+
)
99+
{
100+
return true;
101+
}
102+
}
103+
104+
return false;
91105
}
92106
}
93107

com.unity.postprocessing/PostProcessing/Runtime/Effects/AmbientOcclusion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public override bool IsEnabledAndSupported(PostProcessRenderContext context)
195195
}
196196

197197
state &= SystemInfo.supportsComputeShaders
198-
&& !RuntimeUtilities.isOpenGLNoCompute
198+
&& !RuntimeUtilities.isOpenGLES
199199
&& !RuntimeUtilities.isWebNonWebGPU
200200
#if UNITY_2023_2_OR_NEWER
201201
&& SystemInfo.IsFormatSupported(GraphicsFormat.R32_SFloat, GraphicsFormatUsage.Render)

com.unity.postprocessing/PostProcessing/Runtime/Effects/AutoExposure.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public override bool IsEnabledAndSupported(PostProcessRenderContext context)
8484
{
8585
return enabled.value
8686
&& SystemInfo.supportsComputeShaders
87-
&& !RuntimeUtilities.isOpenGLNoCompute
87+
&& !RuntimeUtilities.isOpenGLES
8888
&& !RuntimeUtilities.isWebNonWebGPU
8989
&& RenderTextureFormat.RFloat.IsSupported()
9090
&& context.resources.computeShaders.autoExposure

com.unity.postprocessing/PostProcessing/Runtime/Monitors/Monitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public bool IsRequestedAndSupported(PostProcessRenderContext context)
4747
{
4848
return requested
4949
&& SystemInfo.supportsComputeShaders
50-
&& !RuntimeUtilities.isOpenGLNoCompute
50+
&& !RuntimeUtilities.isOpenGLES
5151
&& !RuntimeUtilities.isWebNonWebGPU
5252
&& ShaderResourcesAvailable(context);
5353
}

com.unity.postprocessing/PostProcessing/Runtime/Utils/RuntimeUtilities.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -853,14 +853,13 @@ public static bool isVREnabled
853853
/// Returns <c>true</c> if the target platform is does not support compute and the selected API is OpenGL,
854854
/// <c>false</c> otherwise.
855855
/// </summary>
856-
public static bool isOpenGLNoCompute
856+
public static bool isOpenGLES
857857
{
858-
get { return (Application.platform == RuntimePlatform.Android ||
859-
Application.platform == RuntimePlatform.QNXArm32 ||
860-
Application.platform == RuntimePlatform.QNXArm64 ||
861-
Application.platform == RuntimePlatform.QNXX86 ||
862-
Application.platform == RuntimePlatform.QNXX64) &&
863-
SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan; }
858+
get { return (SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3
859+
#if !UNITY_2023_1_OR_NEWER
860+
|| SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES2
861+
#endif
862+
); }
864863
}
865864

866865
/// <summary>

0 commit comments

Comments
 (0)