[Bf-blender-cvs] [c0c31994ab8] temp-viewport-compositor-merge: Viewport Compositor: Fix output storer on Nvidia

Omar Emara noreply at git.blender.org
Mon May 16 15:47:12 CEST 2022


Commit: c0c31994ab8690c435d5847641abf510b57bf41d
Author: Omar Emara
Date:   Mon May 16 15:44:20 2022 +0200
Branches: temp-viewport-compositor-merge
https://developer.blender.org/rBc0c31994ab8690c435d5847641abf510b57bf41d

Viewport Compositor: Fix output storer on Nvidia

The GLSL specification is not clear about passing images to functions and consequently functions
with image parameters are not portable across driver implementations or even non-functioning in
some drivers. See https://github.com/KhronosGroup/GLSL/issues/57.

To work around this, we use macros instead of functions. However, to make those macros usable in
the GPU material library, we also define function counterparts that are guarded with #if 0 such
that they are not used in the shader but are parsed by the GPU shader dependency parser.

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

M	source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_store_output.glsl

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

diff --git a/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_store_output.glsl b/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_store_output.glsl
index 78f660ca648..b8e797aa82c 100644
--- a/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_store_output.glsl
+++ b/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_store_output.glsl
@@ -1,17 +1,32 @@
+/* The GLSL specification is not clear about passing images to functions and consequently functions
+ * with image parameters are not portable across driver implementations or even non-functioning in
+ * some drivers. See https://github.com/KhronosGroup/GLSL/issues/57.
+ * To work around this, we use macros instead of functions. However, to make those macros usable in
+ * the GPU material library, we also define function counterparts that are guarded with #if 0 such
+ * that they are not used in the shader but are parsed by the GPU shader dependency parser. */
+
+#if 0
 void store_output_float(restrict writeonly image2D output_image, float value)
 {
-  ivec2 xy = ivec2(gl_GlobalInvocationID.xy);
-  imageStore(output_image, xy, vec4(value));
+  imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(value));
 }
 
 void store_output_vector(restrict writeonly image2D output_image, vec3 vector)
 {
-  ivec2 xy = ivec2(gl_GlobalInvocationID.xy);
-  imageStore(output_image, xy, vec4(vector, 0.0));
+  imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(vector, 0.0));
 }
 
 void store_output_color(restrict writeonly image2D output_image, vec4 color)
 {
-  ivec2 xy = ivec2(gl_GlobalInvocationID.xy);
-  imageStore(output_image, xy, color);
+  imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), color);
 }
+#else
+#  define store_output_float(output_image, value) \
+    imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(value));
+
+#  define store_output_vector(output_image, vector) \
+    imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(vector, 0.0));
+
+#  define store_output_color(output_image, color) \
+    imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), color);
+#endif



More information about the Bf-blender-cvs mailing list