X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_pipe_fs.c;h=aadfb1a54e179fb00c30e1e219a07935e2ffd63d;hb=f804506d4d4aa1299ce0b1026848321641311672;hp=e3be840d92092e859bb1151b58f83ba8c9e4569c;hpb=11522b74b318db9d099466ff226124c23595e8e2;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_pipe_fs.c b/src/gallium/drivers/svga/svga_pipe_fs.c index e3be840d920..aadfb1a54e1 100644 --- a/src/gallium/drivers/svga/svga_pipe_fs.c +++ b/src/gallium/drivers/svga/svga_pipe_fs.c @@ -23,38 +23,33 @@ * **********************************************************/ -#include "pipe/p_inlines.h" +#include "util/u_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_bitmask.h" #include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_text.h" +#include "draw/draw_context.h" -#include "svga_screen.h" #include "svga_context.h" -#include "svga_state.h" -#include "svga_tgsi.h" #include "svga_hw_reg.h" #include "svga_cmd.h" -#include "svga_draw.h" #include "svga_debug.h" +#include "svga_shader.h" -/*********************************************************************** - * Fragment shaders - */ - static void * svga_create_fs_state(struct pipe_context *pipe, const struct pipe_shader_state *templ) { struct svga_context *svga = svga_context(pipe); - struct svga_screen *svgascreen = svga_screen(pipe->screen); struct svga_fragment_shader *fs; fs = CALLOC_STRUCT(svga_fragment_shader); if (!fs) return NULL; + SVGA_STATS_TIME_PUSH(svga_sws(svga), SVGA_STATS_TIME_CREATEFS); + fs->base.tokens = tgsi_dup_tokens(templ->tokens); /* Collect basic info that we'll need later: @@ -62,17 +57,18 @@ svga_create_fs_state(struct pipe_context *pipe, tgsi_scan_shader(fs->base.tokens, &fs->base.info); fs->base.id = svga->debug.shader_id++; - fs->base.use_sm30 = svgascreen->use_ps30; - - if (SVGA_DEBUG & DEBUG_TGSI || 0) { - debug_printf("%s id: %u, inputs: %u, outputs: %u\n", - __FUNCTION__, fs->base.id, - fs->base.info.num_inputs, fs->base.info.num_outputs); - } + fs->generic_inputs = svga_get_generic_inputs_mask(&fs->base.info); + + svga_remap_generics(fs->generic_inputs, fs->generic_remap_table); + + fs->draw_shader = draw_create_fragment_shader(svga->swtnl.draw, templ); + + SVGA_STATS_TIME_POP(svga_sws(svga)); return fs; } + static void svga_bind_fs_state(struct pipe_context *pipe, void *shader) { @@ -83,31 +79,41 @@ svga_bind_fs_state(struct pipe_context *pipe, void *shader) svga->dirty |= SVGA_NEW_FS; } -static -void svga_delete_fs_state(struct pipe_context *pipe, void *shader) + +static void +svga_delete_fs_state(struct pipe_context *pipe, void *shader) { struct svga_context *svga = svga_context(pipe); struct svga_fragment_shader *fs = (struct svga_fragment_shader *) shader; - struct svga_shader_result *result, *tmp; + struct svga_shader_variant *variant, *tmp; enum pipe_error ret; - svga_hwtnl_flush_retry( svga ); + svga_hwtnl_flush_retry(svga); + + assert(fs->base.parent == NULL); - for (result = fs->base.results; result; result = tmp ) { - tmp = result->next; + draw_delete_fragment_shader(svga->swtnl.draw, fs->draw_shader); - ret = SVGA3D_DestroyShader(svga->swc, - result->id, - SVGA3D_SHADERTYPE_PS ); - if(ret != PIPE_OK) { + for (variant = fs->base.variants; variant; variant = tmp) { + tmp = variant->next; + + /* Check if deleting currently bound shader */ + if (variant == svga->state.hw_draw.fs) { + ret = svga_set_shader(svga, SVGA3D_SHADERTYPE_PS, NULL); + if (ret != PIPE_OK) { + svga_context_flush(svga, NULL); + ret = svga_set_shader(svga, SVGA3D_SHADERTYPE_PS, NULL); + assert(ret == PIPE_OK); + } + svga->state.hw_draw.fs = NULL; + } + + ret = svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); + if (ret != PIPE_OK) { svga_context_flush(svga, NULL); - ret = SVGA3D_DestroyShader(svga->swc, - result->id, - SVGA3D_SHADERTYPE_PS ); + ret = svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); assert(ret == PIPE_OK); } - - svga_destroy_shader_result( result ); } FREE((void *)fs->base.tokens); @@ -115,10 +121,10 @@ void svga_delete_fs_state(struct pipe_context *pipe, void *shader) } -void svga_init_fs_functions( struct svga_context *svga ) +void +svga_init_fs_functions(struct svga_context *svga) { svga->pipe.create_fs_state = svga_create_fs_state; svga->pipe.bind_fs_state = svga_bind_fs_state; svga->pipe.delete_fs_state = svga_delete_fs_state; } -