[Bf-blender-cvs] [b4f8e3f01bc] blender-v2.82-release: Fix T69776: Error with complex Eevee noise texture in some drivers

Patrick Bender noreply at git.blender.org
Thu Feb 6 02:58:43 CET 2020


Commit: b4f8e3f01bc91c98cc8b37f9a6f4ab8378e807eb
Author: Patrick Bender
Date:   Wed Feb 5 22:53:53 2020 -0300
Branches: blender-v2.82-release
https://developer.blender.org/rBb4f8e3f01bc91c98cc8b37f9a6f4ab8378e807eb

Fix T69776: Error with complex Eevee noise texture in some drivers

Apparently the compiled shader bump into some register limit and
the compiler instead of giving an error, does something incorrectly.

Differential Revision: https://developer.blender.org/D6759

===================================================================

M	source/blender/gpu/intern/gpu_material_library.h
M	source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl

===================================================================

diff --git a/source/blender/gpu/intern/gpu_material_library.h b/source/blender/gpu/intern/gpu_material_library.h
index 08c36e24920..0d697a31c35 100644
--- a/source/blender/gpu/intern/gpu_material_library.h
+++ b/source/blender/gpu/intern/gpu_material_library.h
@@ -139,9 +139,7 @@ static GPUMaterialLibrary gpu_shader_material_hash_library = {
 
 static GPUMaterialLibrary gpu_shader_material_noise_library = {
     .code = datatoc_gpu_shader_material_noise_glsl,
-    .dependencies = {&gpu_shader_material_math_util_library,
-                     &gpu_shader_material_hash_library,
-                     NULL},
+    .dependencies = {&gpu_shader_material_hash_library, NULL},
 };
 
 static GPUMaterialLibrary gpu_shader_material_fractal_noise_library = {
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl
index e8487fb5d42..5c1ee05f094 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl
@@ -48,13 +48,6 @@ int quick_floor(float x)
   return int(x) - ((x < 0) ? 1 : 0);
 }
 
-float floorfrac(float x, out int i)
-{
-  float x_floor = floor(x);
-  i = int(x_floor);
-  return x - x_floor;
-}
-
 /* Vector Math */
 
 vec2 safe_divide(vec2 a, vec2 b)
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl
index c184c61c269..cc65b1eb57c 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl
@@ -1,3 +1,7 @@
+/* clang-format off */
+#define FLOORFRAC(x, x_int, x_fract) { float x_floor = floor(x); x_int = int(x_floor); x_fract = x - x_floor; }
+/* clang-format on */
+
 /* Bilinear Interpolation:
  *
  * v2          v3
@@ -124,7 +128,10 @@ float noise_grad(uint hash, float x, float y, float z, float w)
 float noise_perlin(float x)
 {
   int X;
-  float fx = floorfrac(x, X);
+  float fx;
+
+  FLOORFRAC(x, X, fx);
+
   float u = fade(fx);
 
   float r = mix(noise_grad(hash_int(X), fx), noise_grad(hash_int(X + 1), fx - 1.0), u);
@@ -134,11 +141,11 @@ float noise_perlin(float x)
 
 float noise_perlin(vec2 vec)
 {
-  int X;
-  int Y;
+  int X, Y;
+  float fx, fy;
 
-  float fx = floorfrac(vec.x, X);
-  float fy = floorfrac(vec.y, Y);
+  FLOORFRAC(vec.x, X, fx);
+  FLOORFRAC(vec.y, Y, fy);
 
   float u = fade(fx);
   float v = fade(fy);
@@ -155,13 +162,12 @@ float noise_perlin(vec2 vec)
 
 float noise_perlin(vec3 vec)
 {
-  int X;
-  int Y;
-  int Z;
+  int X, Y, Z;
+  float fx, fy, fz;
 
-  float fx = floorfrac(vec.x, X);
-  float fy = floorfrac(vec.y, Y);
-  float fz = floorfrac(vec.z, Z);
+  FLOORFRAC(vec.x, X, fx);
+  FLOORFRAC(vec.y, Y, fy);
+  FLOORFRAC(vec.z, Z, fz);
 
   float u = fade(fx);
   float v = fade(fy);
@@ -184,15 +190,13 @@ float noise_perlin(vec3 vec)
 
 float noise_perlin(vec4 vec)
 {
-  int X;
-  int Y;
-  int Z;
-  int W;
-
-  float fx = floorfrac(vec.x, X);
-  float fy = floorfrac(vec.y, Y);
-  float fz = floorfrac(vec.z, Z);
-  float fw = floorfrac(vec.w, W);
+  int X, Y, Z, W;
+  float fx, fy, fz, fw;
+
+  FLOORFRAC(vec.x, X, fx);
+  FLOORFRAC(vec.y, Y, fy);
+  FLOORFRAC(vec.z, Z, fz);
+  FLOORFRAC(vec.w, W, fw);
 
   float u = fade(fx);
   float v = fade(fy);



More information about the Bf-blender-cvs mailing list