diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index 63ac9d5c0ee..3cbf15927b8 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -627,12 +627,26 @@ dri2_allocate_textures(struct dri_context *ctx, continue; if (drawable->textures[statt]) { + struct pipe_screen *screen = ctx->st->pipe->screen; + templ.format = drawable->textures[statt]->format; templ.bind = drawable->textures[statt]->bind & ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED); templ.nr_samples = drawable->stvis.samples; templ.nr_storage_samples = drawable->stvis.samples; + /* The MSAA component order doesn't have to match the single-sample + * one. Allow the DRI frontend to swap channels for MSAA. + */ + if (!screen->is_format_supported(screen, templ.format, + PIPE_TEXTURE_2D, + templ.nr_samples, + templ.nr_storage_samples, + templ.bind)) { + templ.format = util_format_rgb_to_bgr(templ.format); + assert(templ.format); + } + /* Try to reuse the resource. * (the other resource parameters should be constant) */ @@ -643,8 +657,7 @@ dri2_allocate_textures(struct dri_context *ctx, pipe_resource_reference(&drawable->msaa_textures[statt], NULL); drawable->msaa_textures[statt] = - screen->base.screen->resource_create(screen->base.screen, - &templ); + screen->resource_create(screen, &templ); assert(drawable->msaa_textures[statt]); /* If there are any MSAA resources, we should initialize them diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c index e68a8c19eec..b7e5e0f51fa 100644 --- a/src/gallium/frontends/dri/dri_screen.c +++ b/src/gallium/frontends/dri/dri_screen.c @@ -257,13 +257,21 @@ dri_fill_in_modes(struct dri_screen *screen) continue; for (i = 1; i <= msaa_samples_max; i++) { + /* The MSAA component order doesn't have to match the single-sample + * one. Allow the DRI frontend to swap channels for MSAA. + */ + enum pipe_format swapped_format = + util_format_rgb_to_bgr(pipe_formats[format]); int samples = i > 1 ? i : 0; if (p_screen->is_format_supported(p_screen, pipe_formats[format], PIPE_TEXTURE_2D, samples, samples, - PIPE_BIND_RENDER_TARGET)) { + PIPE_BIND_RENDER_TARGET) || + (swapped_format != PIPE_FORMAT_NONE && + p_screen->is_format_supported(p_screen, swapped_format, + PIPE_TEXTURE_2D, samples, samples, + PIPE_BIND_RENDER_TARGET))) msaa_modes[num_msaa_modes++] = samples; - } } if (num_msaa_modes) {