From: Ian Romanick <ian.d.roman...@intel.com> Explicitly write to each output. This also resolves the issue from commit a6022e54 for integer and uint targets too.
Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/mesa/drivers/common/meta.h | 7 ++++- src/mesa/drivers/common/meta_blit.c | 60 +++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index 7a120b6..06fb798 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -301,7 +301,12 @@ struct blit_state struct gl_buffer_object *buf_obj; struct blit_shader_table shaders_with_depth; struct blit_shader_table shaders_without_depth; - GLuint msaa_shaders[BLIT_MSAA_SHADER_COUNT]; + + /* A unique shader is generated for each kind of blit and for each possible + * number target color draw buffers. + */ + GLuint msaa_shaders[BLIT_MSAA_SHADER_COUNT * MAX_DRAW_BUFFERS]; + struct temp_texture depthTex; bool no_ctsi_fallback; }; diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c index 2e45231..551ed29 100644 --- a/src/mesa/drivers/common/meta_blit.c +++ b/src/mesa/drivers/common/meta_blit.c @@ -348,6 +348,57 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, vec4_prefix = ""; } + + /* All of the non-depth resolve blits need to factor in the number of color + * draw buffers so that the source values can be broadcast correctly. + * + * Eventually this needs to expand to all non-depth blits. See + * https://bugs.freedesktop.org/show_bug.cgi?id=94128. It seems like + * before that happens the blit_msaa_shader enum should be reorganized as a + * bitfield to describe the blit using values that can easily be extracted + * from the shader index. + * + * Scaled blits are handled elsewhere. + */ + switch (shader_index) { + case BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE: + case BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE: + case BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE: + case BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE: + case BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE: + case BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT: + case BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT: + case BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT: + case BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT: + case BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT: + case BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT: + case BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT: + case BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT: + case BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT: + case BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT: + case BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE: + case BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE: + case BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE: + case BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE: + case BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE: + case BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT: + case BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT: + case BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT: + case BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT: + case BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT: + case BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT: + case BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT: + case BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT: + case BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT: + case BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT: + assert(drawFb->_NumColorDrawBuffers > 0); + assert(!dst_is_msaa); + shader_index += (drawFb->_NumColorDrawBuffers - 1) * BLIT_MSAA_SHADER_COUNT; + break; + default: + break; + }; + if (blit->msaa_shaders[shader_index]) { _mesa_UseProgram(blit->msaa_shaders[shader_index]); return; @@ -512,11 +563,13 @@ 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, - " out_color = sample_%d_0;\n", + " for (int i = 0; i < out_color.length(); i++)\n" + " out_color[i] = sample_%d_0;\n", samples); } else { ralloc_asprintf_append(&sample_resolve, - " gl_FragColor = sample_%d_0 / %f;\n", + " for (int i = 0; i < out_color.length(); i++)\n" + " out_color[i] = sample_%d_0 / %f;\n", samples, (float)samples); } @@ -526,7 +579,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, "#define gvec4 %svec4\n" "uniform %ssampler2DMS%s texSampler;\n" "in %s texCoords;\n" - "out gvec4 out_color;\n" + "out gvec4 out_color[%u];\n" "\n" "%s" /* merge_function */ "void main()\n" @@ -537,6 +590,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, vec4_prefix, sampler_array_suffix, texcoord_type, + drawFb->_NumColorDrawBuffers, merge_function, sample_resolve); } -- 2.5.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev