svga: try to flag surfaces for sampling, in addition to rendering
authorBrian Paul <brianp@vmware.com>
Mon, 2 May 2016 16:29:52 +0000 (10:29 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 3 May 2016 21:40:48 +0000 (15:40 -0600)
This silences some warnings when we try to sample from surfaces that were
created for drawing, such as when blitting from one of the framebuffer
surfaces.  We were already doing the opposite situation (adding a bind
flag for rendering to surfaces declared as texture sources).

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

index f176647..b7e8549 100644 (file)
@@ -839,6 +839,17 @@ svga_texture_create(struct pipe_screen *screen,
 
    tex->key.cachable = 1;
 
+   if ((bindings & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL)) &&
+       !(bindings & PIPE_BIND_SAMPLER_VIEW)) {
+      /* Also check if the format can be sampled from */
+      if (screen->is_format_supported(screen, template->format,
+                                      template->target,
+                                      template->nr_samples,
+                                      PIPE_BIND_SAMPLER_VIEW)) {
+         bindings |= PIPE_BIND_SAMPLER_VIEW;
+      }
+   }
+
    if (bindings & PIPE_BIND_SAMPLER_VIEW) {
       tex->key.flags |= SVGA3D_SURFACE_HINT_TEXTURE;
       tex->key.flags |= SVGA3D_SURFACE_BIND_SHADER_RESOURCE;