svga: compute need_swvfetch in svga_create_vertex_elements_state()
authorBrian Paul <brianp@vmware.com>
Thu, 17 Apr 2014 18:27:53 +0000 (11:27 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 17 Apr 2014 18:31:15 +0000 (11:31 -0700)
This saves us doing it at state validation time.

Reviewed-by: Matthew McClure <mcclurem@vmware.com>
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_vertex.c
src/gallium/drivers/svga/svga_state_need_swtnl.c

index 4ff0ed7e66fc479c8a9696a78522ba2d4a4df57b..a75f2a8b570100cd3328d0e5c1914768d5702b16 100644 (file)
@@ -203,6 +203,7 @@ struct svga_velems_state {
    SVGA3dDeclType decl_type[PIPE_MAX_ATTRIBS]; /**< vertex attrib formats */
    unsigned adjust_attrib_range; /* bitmask of attrs needing range adjustment */
    unsigned adjust_attrib_w_1;   /* bitmask of attrs needing w = 1 */
+   boolean need_swvfetch;
 };
 
 /* Use to calculate differences between state emitted to hardware and
index f951c0da189afb37df24c18b9a66440e2094b3b0..faf77f3ab630391609d9eb15eab48241c5187099 100644 (file)
@@ -161,6 +161,7 @@ svga_create_vertex_elements_state(struct pipe_context *pipe,
       velems->count = count;
       memcpy(velems->velem, attribs, sizeof(*attribs) * count);
 
+      velems->need_swvfetch = FALSE;
       velems->adjust_attrib_range = 0x0;
       velems->adjust_attrib_w_1 = 0x0;
 
@@ -168,6 +169,11 @@ svga_create_vertex_elements_state(struct pipe_context *pipe,
       for (i = 0; i < count; i++) {
          enum pipe_format f = attribs[i].src_format;
          velems->decl_type[i] = translate_vertex_format(f);
+         if (velems->decl_type[i] == SVGA3D_DECLTYPE_MAX) {
+            /* Unsupported format - use software fetch */
+            velems->need_swvfetch = TRUE;
+            break;
+         }
 
          if (attrib_needs_range_adjustment(f)) {
             velems->adjust_attrib_range |= (1 << i);
index c89e00336ba7117f9c4a316462fef6f69721e082..cac39d62fd1b55291898b73b734e074d72465a2d 100644 (file)
 static enum pipe_error
 update_need_swvfetch(struct svga_context *svga, unsigned dirty)
 {
-   unsigned i;
-   boolean need_swvfetch = FALSE;
-
    if (!svga->curr.velems) {
       /* No vertex elements bound. */
       return PIPE_OK;
    }
 
-   for (i = 0; i < svga->curr.velems->count; i++) {
-      if (svga->curr.velems->decl_type[i] == SVGA3D_DECLTYPE_MAX) {
-         /* Unsupported format - use software fetch */
-         need_swvfetch = TRUE;
-         break;
-      }
-   }
-
-   if (need_swvfetch != svga->state.sw.need_swvfetch) {
-      svga->state.sw.need_swvfetch = need_swvfetch;
+   if (svga->state.sw.need_swvfetch != svga->curr.velems->need_swvfetch) {
+      svga->state.sw.need_swvfetch = svga->curr.velems->need_swvfetch;
       svga->dirty |= SVGA_NEW_NEED_SWVFETCH;
    }