From 99bd2c429b1bc14f5493cbf7cc3da327d4702a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 24 Dec 2017 13:16:07 +0100 Subject: [PATCH] Adjustments to test compute shader --- test/demo.srd | 9 +++++---- test/shaders/combine.c.glsl | 14 ++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/test/demo.srd b/test/demo.srd index e9cd351..2a01c74 100644 --- a/test/demo.srd +++ b/test/demo.srd @@ -414,7 +414,8 @@ (if $use-compute ( (program prg-combine "combine.c.glsl") (pipeline pl-combine prg-combine) - (set combine-compute-size 16) + (set combine-compute-size-x 8) + (set combine-compute-size-y 32) )( (framebuffer rt-combined tx-combined) (program prg-combine "combine.f.glsl") @@ -476,10 +477,10 @@ (profiling "Combine" (uniforms-i prg-combine 0 0) (uniforms-i prg-combine 1 1) - (uniforms prg-combine 2 $vp-width $vp-height) (use-pipeline pl-combine) (if (not $use-compute) ( + (uniforms prg-combine 2 $vp-width $vp-height) (use-framebuffer rt-combined) )) (use-texture 0 in-main smp-combine-input) @@ -511,8 +512,8 @@ (if $use-compute ( (image 0 tx-combined 0) (compute - (add 1 (div $vp-width $combine-compute-size)) - (add 1 (div $vp-height $combine-compute-size)) + (add 1 (div $vp-width $combine-compute-size-x)) + (add 1 (div $vp-height $combine-compute-size-y)) 1) )( (viewport 0 0 $vp-width $vp-height) diff --git a/test/shaders/combine.c.glsl b/test/shaders/combine.c.glsl index 9e05863..8776efd 100644 --- a/test/shaders/combine.c.glsl +++ b/test/shaders/combine.c.glsl @@ -1,6 +1,9 @@ #version 450 core -layout( local_size_x = 16 , local_size_y = 16 ) in; +layout( + local_size_x = 8 , + local_size_y = 32 +) in; //! type compute //! include lib/utils.glsl @@ -15,7 +18,7 @@ layout( location = 6 ) uniform vec3 u_ColorLift; layout( location = 7 ) uniform vec3 u_ColorGain; layout( location = 8 ) uniform vec3 u_ColorGamma; -layout( binding = 0 , rgba8 ) writeonly uniform image2D ub_Output; +layout( binding = 0 , rgba8 ) writeonly uniform image2D u_Output; #define uVigShapeMul (u_Vignette1.x) #define uVigShapePow (u_Vignette1.y) @@ -27,7 +30,10 @@ layout( binding = 0 , rgba8 ) writeonly uniform image2D ub_Output; void main( void ) { ivec2 coords = ivec2( gl_GlobalInvocationID.xy ); - vec2 pos = vec2( coords ) / u_OutputSize; + vec2 pos = vec2( coords ) / vec2( imageSize( u_Output ) ); + if ( pos.x > 1. || pos.y > 1. ) { + return; + } float f = u_Bloom.x; vec3 color = textureLod( u_MainInput , pos , 0 ).rgb; @@ -58,6 +64,6 @@ void main( void ) color = pow( color , vec3( 1 ) / ( u_ColorGamma + 2.2 ) ); // Write it - imageStore( ub_Output , coords , + imageStore( u_Output , coords , vec4( color , M_Luminosity( color ) ) ); }