From: Kenneth Graunke Date: Sat, 22 Feb 2014 03:15:10 +0000 (-0800) Subject: meta: Use a #define for the vector type to avoid %svec4 everywhere. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe8f3bef31b91fe9296711e0f9dbf511ac9737bf;p=mesa.git meta: Use a #define for the vector type to avoid %svec4 everywhere. By adding "#define gvec4 %svec4" to the top of our fragment shader, we can write generic code without needing to specialize it to vec4, ivec4, or uvec4 via asprintf. This also makes the INT and UNSIGNED_INT merge function code identical, so I combined those two cases. It's not a big savings, but a little bit tidier. v2: Rebase on Vinson's MSVC build fixes. Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner --- diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c index 1bc5d94726c..b8836f40097 100644 --- a/src/mesa/drivers/common/meta_blit.c +++ b/src/mesa/drivers/common/meta_blit.c @@ -240,12 +240,9 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, int i; int step; - if (src_datatype == GL_INT) { + if (src_datatype == GL_INT || src_datatype == GL_UNSIGNED_INT) { merge_function = - "ivec4 merge(ivec4 a, ivec4 b) { return (a >> ivec4(1)) + (b >> ivec4(1)) + (a & b & ivec4(1)); }\n"; - } else if (src_datatype == GL_UNSIGNED_INT) { - merge_function = - "uvec4 merge(uvec4 a, uvec4 b) { return (a >> uvec4(1)) + (b >> uvec4(1)) + (a & b & uvec4(1)); }\n"; + "gvec4 merge(gvec4 a, gvec4 b) { return (a >> gvec4(1)) + (b >> gvec4(1)) + (a & b & gvec4(1)); }\n"; } else { /* The divide will happen at the end for floats. */ merge_function = @@ -266,8 +263,8 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, sample_resolve = rzalloc_size(mem_ctx, 1); for (i = 0; i < samples; i++) { ralloc_asprintf_append(&sample_resolve, - " %svec4 sample_1_%d = texelFetch(texSampler, ivec2(texCoords), %d);\n", - vec4_prefix, i, i); + " gvec4 sample_1_%d = texelFetch(texSampler, ivec2(texCoords), %d);\n", + i, i); } /* Now, merge each pair of samples, then merge each pair of those, * etc. @@ -275,8 +272,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, for (step = 2; step <= samples; step *= 2) { for (i = 0; i < samples; i += step) { ralloc_asprintf_append(&sample_resolve, - " %svec4 sample_%d_%d = merge(sample_%d_%d, sample_%d_%d);\n", - vec4_prefix, + " gvec4 sample_%d_%d = merge(sample_%d_%d, sample_%d_%d);\n", step, i, step / 2, i, step / 2, i + step / 2); @@ -309,9 +305,10 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, "#version 130\n" "#extension GL_ARB_texture_multisample : enable\n" "%s\n" + "#define gvec4 %svec4\n" "uniform %ssampler2DMS texSampler;\n" "in vec2 texCoords;\n" - "out %svec4 out_color;\n" + "out gvec4 out_color;\n" "\n" "%s" /* merge_function */ "void main()\n"