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:
authorOmar Emara <mail@OmarEmara.dev>2022-05-16 16:44:20 +0300
committerOmar Emara <mail@OmarEmara.dev>2022-05-16 16:44:20 +0300
commitc0c31994ab8690c435d5847641abf510b57bf41d (patch)
tree86f7254b83ebbd123edba4bc1246f00e7c1c9f58 /source/blender/gpu/shaders
parent1328d9a575d28a2756594f01a6ef162e1c5afb8e (diff)
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.
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_store_output.glsl27
1 files changed, 21 insertions, 6 deletions
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