diff options
author | Dave Airlie <airlied@redhat.com> | 2016-04-26 14:32:52 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-04-26 15:06:43 +1000 |
commit | 477f65a6ab74a76efc34b85adc8df647d3e86c54 (patch) | |
tree | 5c62cddda4773480c79f224a6b3aa1c3b76a02dd /src/gallium/drivers/softpipe/sp_state_shader.c | |
parent | 10c0fa7f7b457d996b3405f749af3976fa42af78 (diff) |
This enables ARB_compute_shader on softpipe. I've only
tested this with piglit so far, and I hopefully plan
on integrating it with my vulkan work. I'll get to
testing it with deqp more later.
The basic premise is to create up to 1024 restartable
TGSI machines, and execute workgroups of those machines.
v1.1: free machines.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_state_shader.c')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_state_shader.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c index f0d66a53ec6..c871beeffc8 100644 --- a/src/gallium/drivers/softpipe/sp_state_shader.c +++ b/src/gallium/drivers/softpipe/sp_state_shader.c @@ -378,6 +378,53 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, } } +static void * +softpipe_create_compute_state(struct pipe_context *pipe, + const struct pipe_compute_state *templ) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + const struct tgsi_token *tokens; + struct sp_compute_shader *state; + if (templ->ir_type != PIPE_SHADER_IR_TGSI) + return NULL; + + tokens = templ->prog; + /* debug */ + if (softpipe->dump_cs) + tgsi_dump(tokens, 0); + + state = CALLOC_STRUCT(sp_compute_shader); + + state->shader = *templ; + state->tokens = tgsi_dup_tokens(tokens); + + tgsi_scan_shader(state->tokens, &state->info); + return state; +} + +static void +softpipe_bind_compute_state(struct pipe_context *pipe, + void *cs) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + struct sp_compute_shader *state = (struct sp_compute_shader *)cs; + if (softpipe->cs == state) + return; + + softpipe->cs = state; +} + +static void +softpipe_delete_compute_state(struct pipe_context *pipe, + void *cs) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + struct sp_compute_shader *state = (struct sp_compute_shader *)cs; + + assert(softpipe->cs != state); + tgsi_free_tokens(state->tokens); + FREE(state); +} void softpipe_init_shader_funcs(struct pipe_context *pipe) @@ -395,4 +442,8 @@ softpipe_init_shader_funcs(struct pipe_context *pipe) pipe->delete_gs_state = softpipe_delete_gs_state; pipe->set_constant_buffer = softpipe_set_constant_buffer; + + pipe->create_compute_state = softpipe_create_compute_state; + pipe->bind_compute_state = softpipe_bind_compute_state; + pipe->delete_compute_state = softpipe_delete_compute_state; } |