aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/softpipe/sp_state_shader.c
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2016-04-26 14:32:52 +1000
committerDave Airlie <[email protected]>2016-04-27 09:01:03 +1000
commite749c30cebe071da450e28cb47b1b7deb8284a39 (patch)
treef979efb8e10bd77e8f83166efcd3777af4594a1c /src/gallium/drivers/softpipe/sp_state_shader.c
parentf78bcb7638be3c2612fd1ab0371361a8b53104c7 (diff)
softpipe: add support for compute shaders. (v2)
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. v2: deqp fixes - add samplers support, finish atomic operations, fix load/store writemasks. Acked-by: Roland Scheidegger <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_state_shader.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_state_shader.c53
1 files changed, 53 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..38673d85cdf 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -378,6 +378,55 @@ 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);
+
+ state->max_sampler = state->info.file_max[TGSI_FILE_SAMPLER];
+
+ 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 +444,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;
}