diff options
author | Dave Airlie <[email protected]> | 2018-06-15 11:20:53 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2018-08-01 14:00:31 +1000 |
commit | f8a8ea6a2da89bb6f7d97f286a0cf1202fb95d8e (patch) | |
tree | 0f5bf124b156536ecad986785104f7d9b3a538a2 /src/gallium/drivers/virgl/virgl_context.c | |
parent | 157c6e81958d3b2223adf5567722b0502ada78ec (diff) |
virgl: add initial ARB_compute_shader support
This hooks up compute shader creation and launch grid support.
Reviewed-by: Gurchetan Singh <[email protected]>
Diffstat (limited to 'src/gallium/drivers/virgl/virgl_context.c')
-rw-r--r-- | src/gallium/drivers/virgl/virgl_context.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index d224b68cfcd..ae1da337994 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -506,7 +506,7 @@ static void *virgl_shader_encoder(struct pipe_context *ctx, handle = virgl_object_assign_handle(); /* encode VS state */ ret = virgl_encode_shader_state(vctx, handle, type, - &shader->stream_output, + &shader->stream_output, 0, new_tokens); if (ret) { return NULL; @@ -961,7 +961,7 @@ static void virgl_set_shader_buffers(struct pipe_context *ctx, pipe_resource_reference(&vctx->ssbos[shader][idx], NULL); } - uint32_t max_shader_buffer = shader == PIPE_SHADER_FRAGMENT ? + uint32_t max_shader_buffer = (shader == PIPE_SHADER_FRAGMENT || shader == PIPE_SHADER_COMPUTE) ? rs->caps.caps.v2.max_shader_buffer_frag_compute : rs->caps.caps.v2.max_shader_buffer_other_stages; if (!max_shader_buffer) @@ -989,7 +989,7 @@ static void virgl_set_shader_images(struct pipe_context *ctx, pipe_resource_reference(&vctx->images[shader][idx], NULL); } - uint32_t max_shader_images = shader == PIPE_SHADER_FRAGMENT ? + uint32_t max_shader_images = (shader == PIPE_SHADER_FRAGMENT || shader == PIPE_SHADER_COMPUTE) ? rs->caps.caps.v2.max_shader_image_frag_compute : rs->caps.caps.v2.max_shader_image_other_stages; if (!max_shader_images) @@ -1008,6 +1008,50 @@ static void virgl_memory_barrier(struct pipe_context *ctx, virgl_encode_memory_barrier(vctx, flags); } +static void *virgl_create_compute_state(struct pipe_context *ctx, + const struct pipe_compute_state *state) +{ + struct virgl_context *vctx = virgl_context(ctx); + uint32_t handle; + const struct tgsi_token *new_tokens = state->prog; + struct pipe_stream_output_info so_info = {}; + int ret; + + handle = virgl_object_assign_handle(); + ret = virgl_encode_shader_state(vctx, handle, PIPE_SHADER_COMPUTE, + &so_info, + state->req_local_mem, + new_tokens); + if (ret) { + return NULL; + } + + 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); +} + static void virgl_context_destroy( struct pipe_context *ctx ) { @@ -1118,6 +1162,11 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen, vctx->base.delete_gs_state = virgl_delete_gs_state; vctx->base.delete_fs_state = virgl_delete_fs_state; + vctx->base.create_compute_state = virgl_create_compute_state; + vctx->base.bind_compute_state = virgl_bind_compute_state; + vctx->base.delete_compute_state = virgl_delete_compute_state; + vctx->base.launch_grid = virgl_launch_grid; + vctx->base.clear = virgl_clear; vctx->base.draw_vbo = virgl_draw_vbo; vctx->base.flush = virgl_flush_from_st; |