From 5e771df1523ea3f7926c0b5a115c29d134c53f11 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 22 Nov 2017 20:11:06 +0100 Subject: [PATCH] Move compute shader functions from the header to the footer; easier to unify with how the fragment shaders work. --- effect_chain.cpp | 2 +- footer.comp | 19 +++++++++++++++++++ footer.compute | 7 ------- header.comp | 18 ++++-------------- 4 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 footer.comp delete mode 100644 footer.compute diff --git a/effect_chain.cpp b/effect_chain.cpp index d56a248..a83a952 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -500,7 +500,7 @@ void EffectChain::compile_glsl_program(Phase *phase) } if (phase->is_compute_shader) { - frag_shader.append(read_file("footer.compute")); + frag_shader.append(read_file("footer.comp")); phase->output_node->effect->register_uniform_vec2("inv_output_size", (float *)&phase->inv_output_size); phase->output_node->effect->register_uniform_vec2("output_texcoord_adjust", (float *)&phase->output_texcoord_adjust); } else { diff --git a/footer.comp b/footer.comp new file mode 100644 index 0000000..3ece901 --- /dev/null +++ b/footer.comp @@ -0,0 +1,19 @@ +void main() +{ + INPUT(); +} + +vec4 tex2D(sampler2D s, vec2 coord) +{ + return texture(s, coord); +} + +void cs_output(uvec2 coord, vec4 val) +{ + imageStore(outbuf, ivec2(coord), val); +} + +void cs_output(ivec2 coord, vec4 val) +{ + imageStore(outbuf, coord, val); +} diff --git a/footer.compute b/footer.compute deleted file mode 100644 index 1baa856..0000000 --- a/footer.compute +++ /dev/null @@ -1,7 +0,0 @@ -// GLSL is pickier than the C++ preprocessor in if-testing for undefined -// tokens; do some fixups here to keep it happy. - -void main() -{ - INPUT(); -} diff --git a/header.comp b/header.comp index 266e24f..d922e33 100644 --- a/header.comp +++ b/header.comp @@ -5,19 +5,9 @@ // FIXME this needs to be auto-output or something uniform restrict writeonly image2D outbuf; -vec4 tex2D(sampler2D s, vec2 coord) -{ - return texture(s, coord); -} - -void cs_output(uvec2 coord, vec4 val) -{ - imageStore(outbuf, ivec2(coord), val); -} - -void cs_output(ivec2 coord, vec4 val) -{ - imageStore(outbuf, coord, val); -} +// Defined in footer.comp. +vec4 tex2D(sampler2D s, vec2 coord); +void cs_output(uvec2 coord, vec4 val); +void cs_output(ivec2 coord, vec4 val); #define OUTPUT(tc, val) cs_output(tc, val) -- 2.39.2