diff options
author | Dave Airlie <airlied@redhat.com> | 2018-03-28 09:50:38 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2018-03-28 15:10:18 +1000 |
commit | 4e47edb0cb294d5e3483bcaae7d4951c2f3af070 (patch) | |
tree | 6c591ffbc79b9cfba72229fd94b5a12a07ad0f44 | |
parent | 10283b93541e49ff665832d13b14376a3fb72999 (diff) |
basic compute shader + dispatchvirgl-gles31-sketch
-rw-r--r-- | src/gallium/drivers/virgl/virgl_context.c | 32 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_encode.c | 19 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_encode.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/virgl/virgl_protocol.h | 10 |
4 files changed, 62 insertions, 2 deletions
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index e99eddcb8f7..bd3d38dda58 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -868,22 +868,50 @@ static void virgl_memory_barrier(struct pipe_context *ctx, static void *virgl_create_compute_state(struct pipe_context *ctx, const struct pipe_compute_state *state) { - return NULL; + struct virgl_context *vctx = virgl_context(ctx); + uint32_t handle; + struct tgsi_token *new_tokens = state->prog; + struct pipe_stream_output_info so_info = {}; + int ret; + + // new_tokens = virgl_tgsi_transform(vctx, state->prog); + // if (!new_tokens) + // return NULL; + + handle = virgl_object_assign_handle(); + /* encode VS state */ + ret = virgl_encode_shader_state(vctx, handle, PIPE_SHADER_COMPUTE, + &so_info, + new_tokens); + if (ret) { + return NULL; + } + + // FREE(new_tokens); + return (void *)(unsigned long)handle; } static void virgl_bind_compute_state(struct pipe_context *ctx, void *state) { + uint32_t handle = (unsigned long)state; + struct virgl_context *vctx = virgl_context(ctx); + + virgl_encode_bind_shader(vctx, handle, PIPE_SHADER_COMPUTE); } static void virgl_delete_compute_state(struct pipe_context *ctx, void *state) { + uint32_t handle = (unsigned long)state; + struct virgl_context *vctx = virgl_context(ctx); + virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_SHADER); } static void virgl_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info *info) { - + struct virgl_context *vctx = virgl_context(ctx); + virgl_encode_launch_grid(vctx, info); } diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index e51dec0d853..403601a25a2 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -953,3 +953,22 @@ int virgl_encode_memory_barrier(struct virgl_context *ctx, virgl_encoder_write_dword(ctx->cbuf, flags); return 0; } + +int virgl_encode_launch_grid(struct virgl_context *ctx, + const struct pipe_grid_info *grid_info) +{ + virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_LAUNCH_GRID, 0, VIRGL_LAUNCH_GRID_SIZE)); + virgl_encoder_write_dword(ctx->cbuf, grid_info->block[0]); + virgl_encoder_write_dword(ctx->cbuf, grid_info->block[1]); + virgl_encoder_write_dword(ctx->cbuf, grid_info->block[2]); + virgl_encoder_write_dword(ctx->cbuf, grid_info->grid[0]); + virgl_encoder_write_dword(ctx->cbuf, grid_info->grid[1]); + virgl_encoder_write_dword(ctx->cbuf, grid_info->grid[2]); + if (grid_info->indirect) { + struct virgl_resource *res = virgl_resource(grid_info->indirect); + virgl_encoder_write_res(ctx, res); + } else + virgl_encoder_write_dword(ctx->cbuf, 0); + virgl_encoder_write_dword(ctx->cbuf, grid_info->indirect_offset); + return 0; +} diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h index 010c61547b4..37802d2ff4c 100644 --- a/src/gallium/drivers/virgl/virgl_encode.h +++ b/src/gallium/drivers/virgl/virgl_encode.h @@ -262,4 +262,7 @@ int virgl_encode_set_shader_images(struct virgl_context *ctx, const struct pipe_image_view *images); int virgl_encode_memory_barrier(struct virgl_context *ctx, unsigned flags); + +int virgl_encode_launch_grid(struct virgl_context *ctx, + const struct pipe_grid_info *grid_info); #endif diff --git a/src/gallium/drivers/virgl/virgl_protocol.h b/src/gallium/drivers/virgl/virgl_protocol.h index fa775389016..547d1e591df 100644 --- a/src/gallium/drivers/virgl/virgl_protocol.h +++ b/src/gallium/drivers/virgl/virgl_protocol.h @@ -87,6 +87,7 @@ enum virgl_context_cmd { VIRGL_CCMD_SET_SHADER_IMAGES, VIRGL_CCMD_SET_SHADER_BUFFERS, VIRGL_CCMD_MEMORY_BARRIER, + VIRGL_CCMD_LAUNCH_GRID, }; /* @@ -505,4 +506,13 @@ enum virgl_context_cmd { #define VIRGL_MEMORY_BARRIER_FLAGS 1 +#define VIRGL_LAUNCH_GRID_SIZE 8 +#define VIRGL_LAUNCH_BLOCK_X 1 +#define VIRGL_LAUNCH_BLOCK_Y 2 +#define VIRGL_LAUNCH_BLOCK_Z 3 +#define VIRGL_LAUNCH_GRID_X 4 +#define VIRGL_LAUNCH_GRID_Y 5 +#define VIRGL_LAUNCH_GRID_Z 6 +#define VIRGL_LAUNCH_INDIRECT_HANDLE 7 +#define VIRGL_LAUNCH_INDIRECT_OFFSET 8 #endif |