svga: avoid emitting redundant SetIndexBuffer commands
authorBrian Paul <brianp@vmware.com>
Wed, 9 Dec 2015 19:54:35 +0000 (12:54 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 11 Dec 2015 23:54:44 +0000 (16:54 -0700)
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_draw.c

index c4284cc3e5b491ef5a0255ee510b07941f1ca3db..db9491bc282ed920def0686cacbf87b8466d2d20 100644 (file)
@@ -343,6 +343,10 @@ struct svga_hw_draw_state
    SVGA3dElementLayoutId layout_id;
    SVGA3dPrimitiveType topology;
 
+   struct svga_winsys_surface *ib;  /**< index buffer for drawing */
+   SVGA3dSurfaceFormat ib_format;
+   unsigned ib_offset;
+
    /* used for rebinding */
    unsigned num_sampler_views[PIPE_SHADER_TYPES];
    unsigned default_constbuf_size[PIPE_SHADER_TYPES];
index cca499a65c7c8c581f0fe800469e4f601c46cee8..2d3631d6f9c93b8538c6b37c521e65f463fc23f0 100644 (file)
@@ -539,11 +539,18 @@ draw_vgpu10(struct svga_hwtnl *hwtnl,
       SVGA3dSurfaceFormat indexFormat = xlate_index_format(range->indexWidth);
 
       /* setup index buffer */
-      ret = SVGA3D_vgpu10_SetIndexBuffer(svga->swc, ib_handle,
-                                         indexFormat,
-                                         range->indexArray.offset);
-      if (ret != PIPE_OK)
-         return ret;
+      if (ib_handle != svga->state.hw_draw.ib ||
+          indexFormat != svga->state.hw_draw.ib_format ||
+          range->indexArray.offset != svga->state.hw_draw.ib_offset) {
+         ret = SVGA3D_vgpu10_SetIndexBuffer(svga->swc, ib_handle,
+                                            indexFormat,
+                                            range->indexArray.offset);
+         if (ret != PIPE_OK)
+            return ret;
+         svga->state.hw_draw.ib = ib_handle;
+         svga->state.hw_draw.ib_format = indexFormat;
+         svga->state.hw_draw.ib_offset = range->indexArray.offset;
+      }
 
       if (instance_count > 1) {
          ret = SVGA3D_vgpu10_DrawIndexedInstanced(svga->swc,