X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fsoftpipe%2Fsp_state_shader.c;h=a7456628d80ae2575863ee5907b85efab7bb8d57;hb=54272e18a682c8b82d4a86b2c07b51c303d8cead;hp=8d18ca98d4d569dab95863b09b82a71f2142e0b8;hpb=ccd1ea9d52bc7fd11d9f05dc23ae7289fd0b9a99;p=mesa.git diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c index 8d18ca98d4d..a7456628d80 100644 --- a/src/gallium/drivers/softpipe/sp_state_shader.c +++ b/src/gallium/drivers/softpipe/sp_state_shader.c @@ -64,7 +64,8 @@ create_fs_variant(struct softpipe_context *softpipe, /* get new shader that implements polygon stippling */ var->tokens = util_pstipple_create_fragment_shader(curfs->tokens, - &var->stipple_sampler_unit); + &var->stipple_sampler_unit, 0, + TGSI_FILE_INPUT); } else #endif @@ -132,7 +133,7 @@ softpipe_create_fs_state(struct pipe_context *pipe, state->draw_shader = draw_create_fragment_shader(softpipe->draw, &state->shader); if (!state->draw_shader) { - FREE((void *) state->shader.tokens); + tgsi_free_tokens(state->shader.tokens); FREE(state); return NULL; } @@ -194,7 +195,7 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs) draw_delete_fragment_shader(softpipe->draw, state->draw_shader); - FREE((void *) state->shader.tokens); + tgsi_free_tokens(state->shader.tokens); FREE(state); } @@ -207,7 +208,7 @@ softpipe_create_vs_state(struct pipe_context *pipe, struct sp_vertex_shader *state; state = CALLOC_STRUCT(sp_vertex_shader); - if (state == NULL ) + if (!state) goto fail; /* copy shader tokens, the ones passed in will go away. @@ -226,7 +227,7 @@ softpipe_create_vs_state(struct pipe_context *pipe, fail: if (state) { - FREE( (void *)state->shader.tokens ); + tgsi_free_tokens(state->shader.tokens); FREE( state->draw_data ); FREE( state ); } @@ -256,7 +257,7 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs) struct sp_vertex_shader *state = (struct sp_vertex_shader *) vs; draw_delete_vertex_shader(softpipe->draw, state->draw_data); - FREE( (void *)state->shader.tokens ); + tgsi_free_tokens(state->shader.tokens); FREE( state ); } @@ -269,7 +270,7 @@ softpipe_create_gs_state(struct pipe_context *pipe, struct sp_geometry_shader *state; state = CALLOC_STRUCT(sp_geometry_shader); - if (state == NULL ) + if (!state) goto fail; state->shader = *templ; @@ -296,7 +297,7 @@ softpipe_create_gs_state(struct pipe_context *pipe, fail: if (state) { - FREE( (void *)state->shader.tokens ); + tgsi_free_tokens(state->shader.tokens); FREE( state->draw_data ); FREE( state ); } @@ -329,7 +330,7 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs) draw_delete_geometry_shader(softpipe->draw, (state) ? state->draw_data : 0); - FREE((void *) state->shader.tokens); + tgsi_free_tokens(state->shader.tokens); FREE(state); } @@ -337,7 +338,7 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs) static void softpipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_constant_buffer *cb) + const struct pipe_constant_buffer *cb) { struct softpipe_context *softpipe = softpipe_context(pipe); struct pipe_resource *constants = cb ? cb->buffer : NULL; @@ -377,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) @@ -394,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; }