summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2018-02-13 13:57:28 +1000
committerDave Airlie <[email protected]>2018-02-14 13:06:07 +1000
commit9b95b70719bfd19e57a8ae89065eac84f513d297 (patch)
tree6b99fd6f95589cd8561ab4ed0e4aa0e7f085229a /src
parentf6718baabc7d6fed0d41f72fb22e57c0d67fbf1d (diff)
virgl: add ARB_draw_indirect support.
This relies on the renderer code landing first. Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/virgl/virgl_encode.c15
-rw-r--r--src/gallium/drivers/virgl/virgl_protocol.h12
-rw-r--r--src/gallium/drivers/virgl/virgl_screen.c3
3 files changed, 28 insertions, 2 deletions
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index ee68fe068f5..2ee8eac771c 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -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;
}
diff --git a/src/gallium/drivers/virgl/virgl_protocol.h b/src/gallium/drivers/virgl/virgl_protocol.h
index a2f1e818309..1430422b9cf 100644
--- a/src/gallium/drivers/virgl/virgl_protocol.h
+++ b/src/gallium/drivers/virgl/virgl_protocol.h
@@ -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
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index ae062917e63..2af621ec2dc 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -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: