Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Fielder <jason_apple>2022-04-14 12:47:52 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-04-14 12:49:18 +0300
commitb0dc3aff2c73f2a1b65406dcb7fe73c95b9485ed (patch)
tree29642f7e85e2f5189549c1710854c421463a2e0d /source/blender/gpu/shaders/material
parentd62f443f2d0b464131f77f770f9aa19d81164f0c (diff)
Metal: GLSL shader compatibility 3rd pass
Undefined behaviour for divergent control-flow fixes, replacement for partial vector references, and resolution of a number of calculation precision issues occuring on macOS. Authored by Apple: Michael Parkin-White Ref: T96261 Reviewed By: fclem Differential Revision: https://developer.blender.org/D14437
Diffstat (limited to 'source/blender/gpu/shaders/material')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl
index cb798047791..32d61f06a65 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl
@@ -209,10 +209,12 @@ vec3 hash_vec4_to_vec3(vec4 k)
float integer_noise(int n)
{
- int nn;
- n = (n + 1013) & 0x7fffffff;
- n = (n >> 13) ^ n;
- nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
+ /* Integer bit-shifts for these calculations can cause precision problems on macOS.
+ * Using uint resolves these issues. */
+ uint nn;
+ nn = (uint(n) + 1013u) & 0x7fffffffu;
+ nn = (nn >> 13u) ^ nn;
+ nn = (uint(nn * (nn * nn * 60493u + 19990303u)) + 1376312589u) & 0x7fffffffu;
return 0.5 * (float(nn) / 1073741824.0);
}