[Bf-blender-cvs] [fb7132386ce] temp-viewport-compositor-compiler: Viewport Compositor: Ensure bounded loads in shaders

Omar Emara noreply at git.blender.org
Wed Mar 30 16:55:16 CEST 2022


Commit: fb7132386ceca6ad258beb6787aca4b7a010a897
Author: Omar Emara
Date:   Wed Mar 30 16:04:32 2022 +0200
Branches: temp-viewport-compositor-compiler
https://developer.blender.org/rBfb7132386ceca6ad258beb6787aca4b7a010a897

Viewport Compositor: Ensure bounded loads in shaders

Bound texture loads by their size to support single results and
non-robust GL implementations.

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

M	source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_load_input.glsl

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

diff --git a/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_load_input.glsl b/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_load_input.glsl
index 68568236145..109279ed47d 100644
--- a/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_load_input.glsl
+++ b/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_load_input.glsl
@@ -1,17 +1,20 @@
 void load_input_float(sampler2D input_sampler, out float value)
 {
   ivec2 xy = ivec2(gl_GlobalInvocationID.xy);
-  value = texelFetch(input_sampler, xy, 0).x;
+  ivec2 texture_bounds = textureSize(input_sampler, 0) - ivec2(1);
+  value = texelFetch(input_sampler, min(xy, texture_bounds), 0).x;
 }
 
 void load_input_vector(sampler2D input_sampler, out vec3 vector)
 {
   ivec2 xy = ivec2(gl_GlobalInvocationID.xy);
-  vector = texelFetch(input_sampler, xy, 0).xyz;
+  ivec2 texture_bounds = textureSize(input_sampler, 0) - ivec2(1);
+  vector = texelFetch(input_sampler, min(xy, texture_bounds), 0).xyz;
 }
 
 void load_input_color(sampler2D input_sampler, out vec4 color)
 {
   ivec2 xy = ivec2(gl_GlobalInvocationID.xy);
-  color = texelFetch(input_sampler, xy, 0);
+  ivec2 texture_bounds = textureSize(input_sampler, 0) - ivec2(1);
+  color = texelFetch(input_sampler, min(xy, texture_bounds), 0);
 }



More information about the Bf-blender-cvs mailing list