[Mesa-dev] [PATCH 20/22] meta/blit: Don't dynamically select the MSAA "emit" function

Iago Toral itoral at igalia.com
Fri Feb 19 09:55:22 UTC 2016


On Wed, 2016-02-17 at 17:58 -0800, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> Just include all 3 versions in the shader.  The GLSL type system will
> pick the correct one.  This simplifies the code a bit, and it helps pave
> the way for additional simplifications.
> 
> For vec4 outputs, we have to make out_color not be a shader output.
> Otherwise the shader will fail to compile due to static writes to both a
> user-defined output and gl_FragColor.  This is pretty ugly, and I think
> it should be fixed by not writing to gl_FragColor... but that has its
> own challenges.

I am a bit confused by this last paragraph, isn't this issue fixed in
patch 18?

> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/mesa/drivers/common/meta_blit.c | 23 +++++++++--------------
>  1 file changed, 9 insertions(+), 14 deletions(-)
> 
> diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
> index 72428f9..355c937 100644
> --- a/src/mesa/drivers/common/meta_blit.c
> +++ b/src/mesa/drivers/common/meta_blit.c
> @@ -550,19 +550,6 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
>              }
>           }
>  
> -         /* Scale the final result. */
> -         if (src_datatype == GL_UNSIGNED_INT || src_datatype == GL_INT) {
> -            ralloc_asprintf_append(&sample_resolve,
> -                                   "   for (int i = 0; i < out_color.length(); i++)\n"
> -                                   "      out_color[i] = sample_%d_0;\n",
> -                                   samples);
> -         } else {
> -            ralloc_asprintf_append(&sample_resolve,
> -                                   "   for (int i = 0; i < out_color.length(); i++)\n"
> -                                   "      out_color[i] = sample_%d_0 / %f;\n",
> -                                   samples, (float)samples);
> -         }
> -
>           fs_source = ralloc_asprintf(mem_ctx,
>                                       "#version 130\n"
>                                       "#extension GL_ARB_texture_multisample: require\n"
> @@ -575,17 +562,25 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
>                                       "ivec4 merge(ivec4 a, ivec4 b) { return (a >> 1) + (b >> 1) + (a & b & 1); }\n"
>                                       /* The divide will happen at the end for floats. */
>                                       "vec4 merge(vec4 a, vec4 b) { return a + b; }\n"
> +                                     "void emit2(gvec4 s) { for (int i = 0; i < out_color.length(); i++) out_color[i] = s; }\n"
> +                                     "void emit(ivec4 s) { emit2(gvec4(s)); }\n"
> +                                     "void emit(uvec4 s) { emit2(gvec4(s)); }\n"
> +                                     /* Scale the final result. */
> +                                     "void emit(vec4 s) { emit2(gvec4(s / %f)); }\n"
>                                       "\n"
>                                       "void main()\n"
>                                       "{\n"
>                                       "%s\n" /* sample_resolve */
> +                                     "    emit(sample_%d_0);\n"
>                                       "}\n",
>                                       vec4_prefix,
>                                       vec4_prefix,
>                                       sampler_array_suffix,
>                                       texcoord_type,
>                                       drawFb->_NumColorDrawBuffers,
> -                                     sample_resolve);
> +                                     (float) samples,
> +                                     sample_resolve,
> +                                     samples);
>        }
>  
>        vs_source = ralloc_asprintf(mem_ctx,




More information about the mesa-dev mailing list