From 6498809dfd76e3aa85aaf0b3d8d10375a19f1a90 Mon Sep 17 00:00:00 2001 From: Jason Fielder Date: Wed, 24 Jan 2024 14:42:14 +0100 Subject: [PATCH] Metal: Fix Z-fighting in EEVEE Next Small change to always opt-in to using invariant position in the vertex shader. This ensures precision between position calculations from different shaders which need to produce the exact same result, by disabling fastMath on only those instructions. After benchmarking, the impact of this change does not appear to affect performance bottlenecks but will reduce the need for additional bias calculations. Authored by Apple: Michael Parkin-White. Pull Request: https://projects.blender.org/blender/blender/pulls/117478 --- source/blender/gpu/metal/mtl_shader.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/gpu/metal/mtl_shader.mm b/source/blender/gpu/metal/mtl_shader.mm index 41a038b009d..91a950c88f8 100644 --- a/source/blender/gpu/metal/mtl_shader.mm +++ b/source/blender/gpu/metal/mtl_shader.mm @@ -314,6 +314,7 @@ bool MTLShader::finalize(const shader::ShaderCreateInfo *info) MTLCompileOptions *options = [[[MTLCompileOptions alloc] init] autorelease]; options.languageVersion = MTLLanguageVersion2_2; options.fastMathEnabled = YES; + options.preserveInvariance = YES; if (@available(macOS 11.00, *)) { /* Raster order groups for tile data in struct require Metal 2.3.