Commit: 2d6dfbf03892058e24491b0d82d0897134cc5f4a
Author: Jeroen Bakker
Date:   Fri Dec 2 09:31:04 2022 +0100
Branches: temp-vulkan-shader
https://developer.blender.org/rB2d6dfbf03892058e24491b0d82d0897134cc5f4a

Fix vulkan compilation of common_smaa_lib.glsl

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

M       source/blender/draw/intern/shaders/common_smaa_lib.glsl

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

diff --git a/source/blender/draw/intern/shaders/common_smaa_lib.glsl 
b/source/blender/draw/intern/shaders/common_smaa_lib.glsl
index 0c040c9acfe..1b8a8202166 100644
--- a/source/blender/draw/intern/shaders/common_smaa_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_smaa_lib.glsl
@@ -569,7 +569,7 @@ SamplerState PointSampler
 #    define SMAAGather(tex, coord) tex.Gather(LinearSampler, coord, 0)
 #  endif
 #endif
-#if defined(SMAA_GLSL_3) || defined(SMAA_GLSL_4) || defined(GPU_METAL)
+#if defined(SMAA_GLSL_3) || defined(SMAA_GLSL_4) || defined(GPU_METAL) || 
defined(GPU_VULKAN)
 #  define SMAATexture2D(tex) sampler2D tex
 #  define SMAATexturePass2D(tex) tex
 #  define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0)
@@ -583,8 +583,28 @@ SamplerState PointSampler
 #  define lerp(a, b, t) mix(a, b, t)
 #  define saturate(a) clamp(a, 0.0, 1.0)
 #  if defined(SMAA_GLSL_4)
-#    define mad(a, b, c) fma(a, b, c)
 #    define SMAAGather(tex, coord) textureGather(tex, coord)
+#  endif
+#  if defined(SMAA_GLSL_4)
+#    define mad(a, b, c) fma(a, b, c)
+#  elif defined(GPU_VULKAN)
+/* NOTE(Vulkan) mad macro doesn't work, define each override as work-around. */
+vec4 mad(vec4 a, vec4 b, vec4 c)
+{
+  return fma(a, b, c);
+}
+vec3 mad(vec3 a, vec3 b, vec3 c)
+{
+  return fma(a, b, c);
+}
+vec2 mad(vec2 a, vec2 b, vec2 c)
+{
+  return fma(a, b, c);
+}
+float mad(float a, float b, float c)
+{
+  return fma(a, b, c);
+}
 #  else
 #    define mad(a, b, c) (a * b + c)
 #  endif

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to