From: Brian Paul Date: Thu, 17 Apr 2014 18:27:53 +0000 (-0700) Subject: svga: compute need_swvfetch in svga_create_vertex_elements_state() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb34575e19e10b94e90ffb730b962e6930b47a19;p=mesa.git svga: compute need_swvfetch in svga_create_vertex_elements_state() This saves us doing it at state validation time. Reviewed-by: Matthew McClure --- diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 4ff0ed7e66f..a75f2a8b570 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -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 diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c index f951c0da189..faf77f3ab63 100644 --- a/src/gallium/drivers/svga/svga_pipe_vertex.c +++ b/src/gallium/drivers/svga/svga_pipe_vertex.c @@ -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); diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index c89e00336ba..cac39d62fd1 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -34,24 +34,13 @@ 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; }