mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Metal: Enable fast math based on runtime OS version checks.
Chrome compiled with a recent SDK but a low minimum required OS version so fast math was always disabled at compile time. Turn this into a two- part check: Use macros to make sure preserveInvariance can be compiled and @available to do the runtime OS check. Fix the UseFastMathForShaderCompilation check. It was incorrectly inverting two negative conditions. Mark some dEQP precision tests as failing due to fast math. We would prefer to have the performance improvement over some precision loss. Bug: chromium:1468346 Bug: angleproject:8287 Change-Id: I31d9c732a12841cb4d0bc1a555ea1f1ea8a434fc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4750199 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
dbae1804db
commit
1b94197ab0
@@ -365,7 +365,7 @@ constexpr size_t PipelineParametersToFragmentShaderVariantIndex(bool multisample
|
||||
bool UseFastMathForShaderCompilation(ContextMtl *context,
|
||||
const mtl::TranslatedShaderInfo *translatedMslInfo)
|
||||
{
|
||||
return !context->getDisplay()->getFeatures().intelDisableFastMath.enabled ||
|
||||
return !context->getDisplay()->getFeatures().intelDisableFastMath.enabled &&
|
||||
!translatedMslInfo->hasInvariantOrAtan;
|
||||
}
|
||||
|
||||
|
||||
@@ -856,16 +856,19 @@ AutoObjCPtr<id<MTLLibrary>> CreateShaderLibrary(
|
||||
encoding:NSUTF8StringEncoding
|
||||
freeWhenDone:NO];
|
||||
auto options = [[[MTLCompileOptions alloc] init] ANGLE_MTL_AUTORELEASE];
|
||||
|
||||
// Mark all positions in VS with attribute invariant as non-optimizable
|
||||
#if (defined(__MAC_11_0) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0) || \
|
||||
(defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_14_0) || \
|
||||
(defined(__TVOS_14_0) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_14_0)
|
||||
options.preserveInvariance = true;
|
||||
#else
|
||||
// No preserveInvariance available compiling from source, so just disable fastmath.
|
||||
options.fastMathEnabled = false;
|
||||
bool canPerserveInvariance = false;
|
||||
#if defined(__MAC_11_0) || defined(__IPHONE_14_0) || defined(__TVOS_14_0)
|
||||
if (ANGLE_APPLE_AVAILABLE_XCI(11.0, 14.0, 14.0))
|
||||
{
|
||||
canPerserveInvariance = true;
|
||||
options.preserveInvariance = true;
|
||||
}
|
||||
#endif
|
||||
options.fastMathEnabled &= enableFastMath;
|
||||
|
||||
// If preserveInvariance is not available when compiling from source, disable fastmath.
|
||||
options.fastMathEnabled = enableFastMath && canPerserveInvariance;
|
||||
options.languageVersion = GetUserSetOrHighestMSLVersion(options.languageVersion);
|
||||
|
||||
if (!substitutionMacros.empty())
|
||||
|
||||
@@ -702,6 +702,19 @@
|
||||
6297 MAC METAL : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond* = FAIL
|
||||
6297 MAC METAL : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond* = FAIL
|
||||
|
||||
// Some trig functions have precision issues when fast math is enabled in Metal shader compilation
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.mix.mediump_fragment.scalar = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.mix.mediump_vertex.scalar = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.refract.lowp_vertex.scalar = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_fragment.scalar = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_fragment.vec2 = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_fragment.vec3 = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_fragment.vec4 = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_vertex.scalar = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_vertex.vec2 = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_vertex.vec3 = FAIL
|
||||
8287 MAC METAL : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_vertex.vec4 = FAIL
|
||||
|
||||
|
||||
// Metal/Intel
|
||||
|
||||
|
||||
Reference in New Issue
Block a user