svga: Move setting the rendered_to flags to framebuffer emit time
authorCharmaine Lee <charmainel@vmware.com>
Wed, 12 Apr 2017 23:21:51 +0000 (16:21 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 26 Apr 2017 17:37:59 +0000 (11:37 -0600)
Instead of setting the rendered_to flags at set time, this patch
moves the setting of the flags to framebuffer emit time.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/svga/svga_pipe_misc.c
src/gallium/drivers/svga/svga_state_framebuffer.c

index e5d37419cc286aaefb14ff4c7fecd404b0fe4fd7..04707f61d2a6b39447b615f646455f5f36b98ef8 100644 (file)
@@ -150,15 +150,6 @@ svga_set_framebuffer_state(struct pipe_context *pipe,
 
    util_copy_framebuffer_state(dst, fb);
 
-   /* Set the rendered-to flags */
-   for (i = 0; i < dst->nr_cbufs; i++) {
-      struct pipe_surface *s = dst->cbufs[i];
-      if (s) {
-         struct svga_texture *t = svga_texture(s->texture);
-         svga_set_texture_rendered_to(t, s->u.tex.first_layer, s->u.tex.level);
-      }
-   }
-
    if (svga->curr.framebuffer.zsbuf) {
       switch (svga->curr.framebuffer.zsbuf->format) {
       case PIPE_FORMAT_Z16_UNORM:
@@ -180,13 +171,6 @@ svga_set_framebuffer_state(struct pipe_context *pipe,
          svga->curr.depthscale = 0.0f;
          break;
       }
-
-      /* Set rendered-to flag */
-      {
-         struct pipe_surface *s = dst->zsbuf;
-         struct svga_texture *t = svga_texture(s->texture);
-         svga_set_texture_rendered_to(t, s->u.tex.first_layer, s->u.tex.level);
-      }
    }
    else {
       svga->curr.depthscale = 0.0f;
index 146d9dcf5d3683ddd401892699c8943592b00b8c..7fe09579c31d3ab3881ed6e98a1ce259157d7c71 100644 (file)
@@ -34,6 +34,7 @@
 #include "svga_debug.h"
 #include "svga_screen.h"
 #include "svga_surface.h"
+#include "svga_resource_texture.h"
 
 
 /*
@@ -82,6 +83,13 @@ emit_fb_vgpu9(struct svga_context *svga)
 
          pipe_surface_reference(&hw->cbufs[i], curr->cbufs[i]);
       }
+
+      /* Set the rendered-to flag */
+      struct pipe_surface *s = curr->cbufs[i];
+      if (s) {
+         svga_set_texture_rendered_to(svga_texture(s->texture),
+                                      s->u.tex.first_layer, s->u.tex.level);
+      }
    }
 
    if ((curr->zsbuf != hw->zsbuf) || (reemit && hw->zsbuf)) {
@@ -107,6 +115,13 @@ emit_fb_vgpu9(struct svga_context *svga)
       }
 
       pipe_surface_reference(&hw->zsbuf, curr->zsbuf);
+
+      /* Set the rendered-to flag */
+      struct pipe_surface *s = curr->zsbuf;
+      if (s) {
+         svga_set_texture_rendered_to(svga_texture(s->texture),
+                                      s->u.tex.first_layer, s->u.tex.level);
+      }
    }
 
    return PIPE_OK;
@@ -195,14 +210,19 @@ emit_fb_vgpu10(struct svga_context *svga)
     */
    for (i = 0; i < num_color; i++) {
       if (curr->cbufs[i]) {
-         rtv[i] = svga_validate_surface_view(svga,
-                                             svga_surface(curr->cbufs[i]));
+         struct pipe_surface *s = curr->cbufs[i];
+
+         rtv[i] = svga_validate_surface_view(svga, svga_surface(s));
          if (rtv[i] == NULL) {
             return PIPE_ERROR_OUT_OF_MEMORY;
          }
 
          assert(svga_surface(rtv[i])->view_id != SVGA3D_INVALID_ID);
          last_rtv = i;
+
+         /* Set the rendered-to flag */
+         svga_set_texture_rendered_to(svga_texture(s->texture),
+                                      s->u.tex.first_layer, s->u.tex.level);
       }
       else {
          rtv[i] = NULL;
@@ -211,10 +231,16 @@ emit_fb_vgpu10(struct svga_context *svga)
 
    /* Setup depth stencil view */
    if (curr->zsbuf) {
+      struct pipe_surface *s = curr->zsbuf;
+
       dsv = svga_validate_surface_view(svga, svga_surface(curr->zsbuf));
       if (!dsv) {
          return PIPE_ERROR_OUT_OF_MEMORY;
       }
+
+      /* Set the rendered-to flag */
+      svga_set_texture_rendered_to(svga_texture(s->texture),
+                                      s->u.tex.first_layer, s->u.tex.level);
    }
    else {
       dsv = NULL;