Browse Source

Ported over compute shader fixes from the Unity Graphics repository:

[PPV2] PPB-6 Disabled compute effects on WebGL and Android OpenGL (#7936)

* Disabled compute based effects not supported on WebGL and Android OpenGL
* Improved editor warning messages.
* Fix editor warning messages.
hdrp
Nico de Poel 3 years ago
parent
commit
4fba5fcc60
  1. 10
      com.unity.postprocessing/PostProcessing/Editor/Effects/AmbientOcclusionEditor.cs
  2. 10
      com.unity.postprocessing/PostProcessing/Editor/Effects/AutoExposureEditor.cs
  3. 24
      com.unity.postprocessing/PostProcessing/Editor/Utils/EditorUtilities.cs
  4. 1
      com.unity.postprocessing/PostProcessing/Runtime/Effects/AmbientOcclusion.cs
  5. 1
      com.unity.postprocessing/PostProcessing/Runtime/Effects/AutoExposure.cs
  6. 1
      com.unity.postprocessing/PostProcessing/Runtime/Monitors/Monitor.cs
  7. 15
      com.unity.postprocessing/PostProcessing/Runtime/Utils/RuntimeUtilities.cs

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

@ -49,8 +49,14 @@ namespace UnityEditor.Rendering.PostProcessing
}
else if (aoMode == (int)AmbientOcclusionMode.MultiScaleVolumetricObscurance)
{
if (!SystemInfo.supportsComputeShaders)
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support.", MessageType.Warning);
if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL)
{
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support which is not available on this platform.", MessageType.Error);
}
else if(EditorUtilities.isTargetingAndroid)
{
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
}
PropertyField(m_ThicknessModifier);
PropertyField(m_ZBias);

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

@ -31,8 +31,14 @@ namespace UnityEditor.Rendering.PostProcessing
public override void OnInspectorGUI()
{
if (!SystemInfo.supportsComputeShaders)
EditorGUILayout.HelpBox("Auto exposure requires compute shader support.", MessageType.Warning);
if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL)
{
EditorGUILayout.HelpBox("Auto exposure requires compute shader support which is not available on this platform.", MessageType.Error);
}
else if (EditorUtilities.isTargetingAndroid)
{
EditorGUILayout.HelpBox("Auto exposure requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
}
EditorUtilities.DrawHeaderLabel("Exposure");

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

@ -64,6 +64,30 @@ namespace UnityEditor.Rendering.PostProcessing
}
}
/// <summary>
/// Returns <c>true</c> if the current target is Android, <c>false</c> otherwise.
/// </summary>
public static bool isTargetingAndroid
{
get
{
var t = EditorUserBuildSettings.activeBuildTarget;
return t == BuildTarget.Android;
}
}
/// <summary>
/// Returns <c>true</c> if the current target is WebGL, <c>false</c> otherwise.
/// </summary>
public static bool isTargetingWebGL
{
get
{
var t = EditorUserBuildSettings.activeBuildTarget;
return t == BuildTarget.WebGL;
}
}
/// <summary>
/// Returns <c>true</c> if the current target is a console or a mobile, <c>false</c>
/// otherwise.

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

@ -196,6 +196,7 @@ namespace UnityEngine.Rendering.PostProcessing
state &= SystemInfo.supportsComputeShaders
&& !RuntimeUtilities.isAndroidOpenGL
&& !RuntimeUtilities.isWebGL
#if UNITY_2023_2_OR_NEWER
&& SystemInfo.IsFormatSupported(GraphicsFormat.R32_SFloat, GraphicsFormatUsage.Render)
&& SystemInfo.IsFormatSupported(GraphicsFormat.R16_SFloat, GraphicsFormatUsage.Render)

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

@ -85,6 +85,7 @@ namespace UnityEngine.Rendering.PostProcessing
return enabled.value
&& SystemInfo.supportsComputeShaders
&& !RuntimeUtilities.isAndroidOpenGL
&& !RuntimeUtilities.isWebGL
&& RenderTextureFormat.RFloat.IsSupported()
&& context.resources.computeShaders.autoExposure
&& context.resources.computeShaders.exposureHistogram;

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

@ -48,6 +48,7 @@ namespace UnityEngine.Rendering.PostProcessing
return requested
&& SystemInfo.supportsComputeShaders
&& !RuntimeUtilities.isAndroidOpenGL
&& !RuntimeUtilities.isWebGL
&& ShaderResourcesAvailable(context);
}

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

@ -858,6 +858,21 @@ namespace UnityEngine.Rendering.PostProcessing
get { return Application.platform == RuntimePlatform.Android && SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan; }
}
/// <summary>
/// Returns <c>true</c> if the target platform is WebGL,
/// <c>false</c> otherwise.
/// </summary>
public static bool isWebGL
{
get {
#if UNITY_WEBGL
return true;
#else
return false;
#endif
}
}
/// <summary>
/// Gets the default HDR render texture format for the current target platform.
/// </summary>

Loading…
Cancel
Save