OSDN Git Service

svga: fix PIPE_TEXTURE_RECT/BUFFER const buffer issue
authorBrian Paul <brianp@vmware.com>
Wed, 22 Aug 2018 17:11:22 +0000 (11:11 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 29 Aug 2018 17:29:07 +0000 (11:29 -0600)
The flag_rect and flag_buffer fields didn't sufficiently capture
the state changes needed for those resource types.  For example,
if a texture binding was changed from a 500x500 rect texture to a
400x400 rect texture we didn't set SVGA_NEW_TEXTURE_CONSTS.  But
we need to do that to emit the new texcoord scale factors to the
constant buffers.  Rather than track the sizes of all bound
resources, just set the flag if the resource is a rect.  Same
story with texture buffers.

Also, since rect/buffer textures are usable with VS/GS shaders,
add SVGA_NEW_TEXTURE_CONSTS to the flags we check for emitting
VS/GS constants.

This seems to help with XFCE / xfwm4 desktop scaling.
VMware issue 2156696.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_sampler.c
src/gallium/drivers/svga/svga_state_constants.c

index bc881c9..484fd55 100644 (file)
@@ -300,8 +300,6 @@ struct svga_state
    struct {
       unsigned flag_1d;
       unsigned flag_srgb;
-      unsigned flag_rect;  /* sampler views with rectangular texture target */
-      unsigned flag_buf;   /* sampler views with texture buffer target */
    } tex_flags;
 
    unsigned sample_mask;
index 4c38092..b32bb09 100644 (file)
@@ -446,8 +446,6 @@ svga_set_sampler_views(struct pipe_context *pipe,
    struct svga_context *svga = svga_context(pipe);
    unsigned flag_1d = 0;
    unsigned flag_srgb = 0;
-   unsigned flag_rect = 0;
-   unsigned flag_buf = 0;
    uint i;
    boolean any_change = FALSE;
 
@@ -493,12 +491,19 @@ svga_set_sampler_views(struct pipe_context *pipe,
          flag_srgb |= 1 << (start + i);
 
       target = views[i]->target;
-      if (target == PIPE_TEXTURE_1D)
+      if (target == PIPE_TEXTURE_1D) {
          flag_1d |= 1 << (start + i);
-      else if (target == PIPE_TEXTURE_RECT)
-         flag_rect |= 1 << (start + i);
-      else if (target == PIPE_BUFFER)
-         flag_buf |= 1 << (start + i);
+      } else if (target == PIPE_TEXTURE_RECT) {
+         /* If the size of the bound texture changes, we need to emit new
+          * const buffer values.
+          */
+         svga->dirty |= SVGA_NEW_TEXTURE_CONSTS;
+      } else if (target == PIPE_BUFFER) {
+         /* If the size of the bound buffer changes, we need to emit new
+          * const buffer values.
+          */
+         svga->dirty |= SVGA_NEW_TEXTURE_CONSTS;
+      }
    }
 
    if (!any_change) {
@@ -522,15 +527,6 @@ svga_set_sampler_views(struct pipe_context *pipe,
       svga->curr.tex_flags.flag_srgb = flag_srgb;
    }
 
-   if (flag_rect != svga->curr.tex_flags.flag_rect ||
-       flag_buf != svga->curr.tex_flags.flag_buf)
-   {
-      /* Need to re-emit texture constants */
-      svga->dirty |= SVGA_NEW_TEXTURE_CONSTS;
-      svga->curr.tex_flags.flag_rect = flag_rect;
-      svga->curr.tex_flags.flag_buf = flag_buf;
-   }
-
    /* Check if any of the sampler view resources collide with the framebuffer
     * color buffers or depth stencil resource. If so, set the NEW_FRAME_BUFFER
     * dirty bit so that emit_framebuffer can be invoked to create backed view
index 9af91fe..2c1b704 100644 (file)
@@ -769,7 +769,8 @@ struct svga_tracked_state svga_hw_vs_constants =
    "hw vs params",
    (SVGA_NEW_PRESCALE |
     SVGA_NEW_VS_CONST_BUFFER |
-    SVGA_NEW_VS_VARIANT),
+    SVGA_NEW_VS_VARIANT |
+    SVGA_NEW_TEXTURE_CONSTS),
    emit_vs_consts
 };
 
@@ -809,6 +810,7 @@ struct svga_tracked_state svga_hw_gs_constants =
    (SVGA_NEW_PRESCALE |
     SVGA_NEW_GS_CONST_BUFFER |
     SVGA_NEW_RAST |
-    SVGA_NEW_GS_VARIANT),
+    SVGA_NEW_GS_VARIANT |
+    SVGA_NEW_TEXTURE_CONSTS),
    emit_gs_consts
 };