From a709d99bfd7982bcb15d2c98bea5bc8de91ea0a7 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 14 Dec 2020 23:35:55 -0500 Subject: [PATCH] st/mesa: set drawpixels swizzle before creating sampler view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (some) drivers need to have the swizzle set prior to create_sampler_view being called in order to actually apply it Fixes: d11fefa9616 ("st/mesa: optimize 4-component ubyte glDrawPixels") Acked-by: Adam Jackson Reviewed-by: Eric Anholt Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_cb_drawpixels.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 4cc6ebb2686..48f9a05a8ad 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1231,7 +1231,7 @@ setup_sampler_swizzle(struct pipe_sampler_view *sv, GLenum format, GLenum type) { if ((format == GL_RGBA || format == GL_BGRA) && type == GL_UNSIGNED_BYTE) { const struct util_format_description *desc = - util_format_description(sv->texture->format); + util_format_description(sv->format); unsigned c0, c1, c2, c3; /* Every gallium driver supports at least one 32-bit packed RGBA format. @@ -1377,17 +1377,22 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y, st_upload_constants(st, &st->fp->Base); } - /* create sampler view for the image */ - sv[0] = st_create_texture_sampler_view(st->pipe, pt); + { + /* create sampler view for the image */ + struct pipe_sampler_view templ; + + u_sampler_view_default_template(&templ, pt, pt->format); + /* Set up the sampler view's swizzle */ + setup_sampler_swizzle(&templ, format, type); + + sv[0] = st->pipe->create_sampler_view(st->pipe, pt, &templ); + } if (!sv[0]) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); pipe_resource_reference(&pt, NULL); return; } - /* Set up the sampler view's swizzle */ - setup_sampler_swizzle(sv[0], format, type); - /* Create a second sampler view to read stencil. The stencil is * written using the shader stencil export functionality. */