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
This commit is contained in:
Jason Fielder
2024-01-24 14:42:14 +01:00
committed by Clément Foucault
parent b6e5b02ede
commit 6498809dfd

View File

@@ -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.