svga: implement user index buffers
authorMarek Olšák <marek.olsak@amd.com>
Fri, 17 Feb 2017 01:21:29 +0000 (02:21 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 24 Feb 2017 23:03:09 +0000 (00:03 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
Tested-by: Brian Paul <brianp@vmware.com> (VMware driver only)
src/gallium/drivers/svga/svga_pipe_draw.c
src/gallium/drivers/svga/svga_screen.c

index c51c0b27915a649d1665379e8ab0ca8ecb72b6d1..bbd443049507da7dcbaa0bb0b655c780fc7189e4 100644 (file)
@@ -25,6 +25,7 @@
 
 
 #include "util/u_format.h"
+#include "util/u_helpers.h"
 #include "util/u_inlines.h"
 #include "util/u_prim.h"
 #include "util/u_prim_restart.h"
@@ -194,6 +195,14 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
        svga->curr.rast->templ.cull_face == PIPE_FACE_FRONT_AND_BACK)
       goto done;
 
+   /* Upload a user index buffer. */
+   struct pipe_index_buffer ibuffer_saved = {};
+   if (info->indexed && svga->curr.ib.user_buffer &&
+       !util_save_and_upload_index_buffer(pipe, info, &svga->curr.ib,
+                                          &ibuffer_saved)) {
+      return;
+   }
+
    /*
     * Mark currently bound target surfaces as dirty
     * doesn't really matter if it is done before drawing.
@@ -277,8 +286,10 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    }
 
 done:
+   if (info->indexed && ibuffer_saved.user_buffer)
+      pipe->set_index_buffer(pipe, &ibuffer_saved);
+
    SVGA_STATS_TIME_POP(svga_sws(svga));
-;
 }
 
 
index f9dfcd2158567cffdbe9a8a4622ac704d42da7e4..8af66b7caaddba8879f9a3f18505e1ab531dbcbd 100644 (file)
@@ -182,6 +182,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_NPOT_TEXTURES:
    case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
    case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
+   case PIPE_CAP_USER_INDEX_BUFFERS:
       return 1;
    case PIPE_CAP_TWO_SIDED_STENCIL:
       return 1;
@@ -213,7 +214,6 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
       return 0;
    case PIPE_CAP_USER_VERTEX_BUFFERS:
-   case PIPE_CAP_USER_INDEX_BUFFERS:
       return 0;
    case PIPE_CAP_USER_CONSTANT_BUFFERS:
       return 1;