freedreno: add support for user index buffers
authorMarek Olšák <marek.olsak@amd.com>
Fri, 17 Feb 2017 01:14:36 +0000 (02:14 +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>
src/gallium/drivers/freedreno/freedreno_draw.c
src/gallium/drivers/freedreno/freedreno_screen.c

index cfe13cd6782895b60f71fe57fe07dfc0967076b3..5d5b7c11beb14b3fbccf0e828e573baa97ae2102 100644 (file)
@@ -31,6 +31,7 @@
 #include "util/u_memory.h"
 #include "util/u_prim.h"
 #include "util/u_format.h"
+#include "util/u_helpers.h"
 
 #include "freedreno_draw.h"
 #include "freedreno_context.h"
@@ -84,6 +85,14 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                return;
        }
 
+       /* Upload a user index buffer. */
+       struct pipe_index_buffer ibuffer_saved = {};
+       if (info->indexed && ctx->indexbuf.user_buffer &&
+           !util_save_and_upload_index_buffer(pctx, info, &ctx->indexbuf,
+                                              &ibuffer_saved)) {
+               return;
+       }
+
        if (ctx->in_blit) {
                fd_batch_reset(batch);
                ctx->dirty = ~0;
@@ -201,6 +210,9 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                ctx->dirty = 0xffffffff;
 
        fd_batch_check_size(batch);
+
+       if (info->indexed && ibuffer_saved.user_buffer)
+           pctx->set_index_buffer(pctx, &ibuffer_saved);
 }
 
 /* Generic clear implementation (partially) using u_blitter: */
index 1122e29269d0846d491601956259f91057c3dcba..e1b95a6debb7706e83ca0ac397552b9ab1a3cbd7 100644 (file)
@@ -179,6 +179,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
        case PIPE_CAP_STRING_MARKER:
        case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
+       case PIPE_CAP_USER_INDEX_BUFFERS:
                return 1;
 
        case PIPE_CAP_VERTEXID_NOBASE:
@@ -253,7 +254,6 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
        case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
        case PIPE_CAP_USER_VERTEX_BUFFERS:
-       case PIPE_CAP_USER_INDEX_BUFFERS:
        case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
        case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
        case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: