mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 17:30:12 +01:00
frontend/dri: allow swapped BGR->RGB channel order for MSAA color buffers
This only applies to MSAA visuals. The MSAA channel order doesn't have to match the visual, but some drivers don't support MSAA with BGR. Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16327>
This commit is contained in:
parent
89c94502b6
commit
cfec9a55ea
2 changed files with 25 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue