svga: don't call svga_texture_device_format_has_alpha() for PIPE_BUFFER
authorBrian Paul <brianp@vmware.com>
Fri, 30 Jun 2017 21:11:01 +0000 (14:11 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 3 Jul 2017 16:10:14 +0000 (10:10 -0600)
svga_texture_device_format_has_alpha() is only intended to work for
texture resources, not buffer resources.  This fixes a failed assertion
in the svga_texture() cast function when running texture buffer tests.

Also, add an assertion in svga_texture_device_format_has_alpha() to
catch the issue sooner.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_shader.c

index 84441d116ddf1f654552877ce380d3301f88f3af..5a684b7933b426c0c009b68ec46ebd86d916c4d4 100644 (file)
@@ -1539,6 +1539,9 @@ svga_texture_transfer_unmap_upload(struct svga_context *svga,
 boolean
 svga_texture_device_format_has_alpha(struct pipe_resource *texture)
 {
+   /* the svga_texture() call below is invalid for PIPE_BUFFER resources */
+   assert(texture->target != PIPE_BUFFER);
+
    enum svga3d_block_desc block_desc =
       svga3dsurface_get_desc(svga_texture(texture)->key.format)->block_desc;
 
index ef3b021d404c9b14ac1797e20870be65da9cc613..5ff6f034cf8a134844dfd02f4ef4eb8711054138 100644 (file)
@@ -224,7 +224,8 @@ svga_init_shader_key_common(const struct svga_context *svga,
             }
          }
 
-         swizzle_tab = (!util_format_has_alpha(view->format) &&
+         swizzle_tab = (view->texture->target != PIPE_BUFFER &&
+                        !util_format_has_alpha(view->format) &&
                         svga_texture_device_format_has_alpha(view->texture)) ?
             set_alpha : copy_alpha;