virgl: add ARB_draw_indirect support.
authorDave Airlie <airlied@redhat.com>
Tue, 13 Feb 2018 03:57:28 +0000 (13:57 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 14 Feb 2018 03:06:07 +0000 (13:06 +1000)
This relies on the renderer code landing first.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/virgl/virgl_encode.c
src/gallium/drivers/virgl/virgl_protocol.h
src/gallium/drivers/virgl/virgl_screen.c

index ee68fe068f50e43f711e9091fd79e7cf094b785e..2ee8eac771ca5ab969b5cca020c8bc036592a580 100644 (file)
@@ -417,7 +417,10 @@ int virgl_encoder_set_index_buffer(struct virgl_context *ctx,
 int virgl_encoder_draw_vbo(struct virgl_context *ctx,
                           const struct pipe_draw_info *info)
 {
-   virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_DRAW_VBO, 0, VIRGL_DRAW_VBO_SIZE));
+   uint32_t length = VIRGL_DRAW_VBO_SIZE;
+   if (info->indirect)
+      length = VIRGL_DRAW_VBO_SIZE_INDIRECT;
+   virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_DRAW_VBO, 0, length));
    virgl_encoder_write_dword(ctx->cbuf, info->start);
    virgl_encoder_write_dword(ctx->cbuf, info->count);
    virgl_encoder_write_dword(ctx->cbuf, info->mode);
@@ -433,6 +436,16 @@ int virgl_encoder_draw_vbo(struct virgl_context *ctx,
       virgl_encoder_write_dword(ctx->cbuf, info->count_from_stream_output->buffer_size);
    else
       virgl_encoder_write_dword(ctx->cbuf, 0);
+   if (length == VIRGL_DRAW_VBO_SIZE_INDIRECT) {
+      virgl_encoder_write_dword(ctx->cbuf, 0); /* vertices per patch */
+      virgl_encoder_write_dword(ctx->cbuf, 0); /* drawid */
+      virgl_encoder_write_res(ctx, virgl_resource(info->indirect->buffer));
+      virgl_encoder_write_dword(ctx->cbuf, info->indirect->offset);
+      virgl_encoder_write_dword(ctx->cbuf, 0); /* indirect stride */
+      virgl_encoder_write_dword(ctx->cbuf, 0); /* indirect draw count */
+      virgl_encoder_write_dword(ctx->cbuf, 0); /* indirect draw count offset */
+      virgl_encoder_write_dword(ctx->cbuf, 0); /* indirect draw count handle */
+   }
    return 0;
 }
 
index a2f1e818309d3a969387441f3399f05ceae3d537..1430422b9cfffc41c85da4ce0bb5c06698dfa321 100644 (file)
@@ -275,6 +275,8 @@ enum virgl_context_cmd {
 
 /* draw VBO */
 #define VIRGL_DRAW_VBO_SIZE 12
+#define VIRGL_DRAW_VBO_SIZE_TESS 14
+#define VIRGL_DRAW_VBO_SIZE_INDIRECT 20
 #define VIRGL_DRAW_VBO_START 1
 #define VIRGL_DRAW_VBO_COUNT 2
 #define VIRGL_DRAW_VBO_MODE 3
@@ -287,6 +289,16 @@ enum virgl_context_cmd {
 #define VIRGL_DRAW_VBO_MIN_INDEX 10
 #define VIRGL_DRAW_VBO_MAX_INDEX 11
 #define VIRGL_DRAW_VBO_COUNT_FROM_SO 12
+/* tess packet */
+#define VIRGL_DRAW_VBO_VERTICES_PER_PATCH 13
+#define VIRGL_DRAW_VBO_DRAWID 14
+/* indirect packet */
+#define VIRGL_DRAW_VBO_INDIRECT_HANDLE 15
+#define VIRGL_DRAW_VBO_INDIRECT_OFFSET 16
+#define VIRGL_DRAW_VBO_INDIRECT_STRIDE 17
+#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT 18
+#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT_OFFSET 19
+#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT_HANDLE 20
 
 /* create surface */
 #define VIRGL_OBJ_SURFACE_SIZE 5
index ae062917e63ff19f1ae6b6c9aa84cc335a740a15..2af621ec2dce6538f5cf1a1db9526bc2a6e91b7b 100644 (file)
@@ -191,6 +191,8 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return vscreen->caps.caps.v1.bset.texture_query_lod;
    case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
       return vscreen->caps.caps.v1.max_texture_gather_components;
+   case PIPE_CAP_DRAW_INDIRECT:
+      return vscreen->caps.caps.v1.bset.has_indirect_draw;
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_SAMPLE_SHADING:
@@ -198,7 +200,6 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
    case PIPE_CAP_MAX_VERTEX_STREAMS:
-   case PIPE_CAP_DRAW_INDIRECT:
    case PIPE_CAP_MULTI_DRAW_INDIRECT:
    case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE: