From fa0f48504a32642d688d4b81f62eea54c693b23f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 13 Mar 2009 16:22:35 +0000 Subject: gallium: no need to keep a copy of shader tokens in state tracker Any driver who needs a copy of the shader tokens must organize to do so itself. This has been the case for a long time, but there was still defensive code in the state tracker, which is now removed. Any bugs resulting from this need to be fixed in the offending driver... --- src/gallium/auxiliary/util/u_simple_shaders.c | 76 ++++++++++----------------- 1 file changed, 29 insertions(+), 47 deletions(-) (limited to 'src/gallium/auxiliary/util/u_simple_shaders.c') diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 8da18d6715..e519c354d2 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -55,12 +55,11 @@ void * util_make_vertex_passthrough_shader(struct pipe_context *pipe, uint num_attribs, const uint *semantic_names, - const uint *semantic_indexes, - struct pipe_shader_state *shader) + const uint *semantic_indexes) { - uint maxTokens = 100; - struct tgsi_token *tokens; + struct pipe_shader_state shader; + struct tgsi_token tokens[100]; struct tgsi_header *header; struct tgsi_processor *processor; struct tgsi_full_declaration decl; @@ -68,8 +67,6 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, const uint procType = TGSI_PROCESSOR_VERTEX; uint ti, i; - tokens = (struct tgsi_token *) MALLOC(maxTokens * sizeof(tokens[0])); - /* shader header */ *(struct tgsi_version *) &tokens[0] = tgsi_build_version(); @@ -96,7 +93,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, - maxTokens - ti); + Elements(tokens) - ti); } /* declare outputs */ @@ -111,7 +108,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, - maxTokens - ti); + Elements(tokens) - ti); } /* emit MOV instructions */ @@ -128,7 +125,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, - maxTokens - ti ); + Elements(tokens) - ti ); } /* END instruction */ @@ -139,16 +136,15 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, - maxTokens - ti ); + Elements(tokens) - ti ); #if 0 /*debug*/ tgsi_dump(tokens, 0); #endif - shader->tokens = tokens; - /*shader->num_tokens = ti;*/ + shader.tokens = tokens; - return pipe->create_vs_state(pipe, shader); + return pipe->create_vs_state(pipe, &shader); } @@ -160,11 +156,10 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, * END; */ void * -util_make_fragment_tex_shader(struct pipe_context *pipe, - struct pipe_shader_state *shader) +util_make_fragment_tex_shader(struct pipe_context *pipe) { - uint maxTokens = 100; - struct tgsi_token *tokens; + struct pipe_shader_state shader; + struct tgsi_token tokens[100]; struct tgsi_header *header; struct tgsi_processor *processor; struct tgsi_full_declaration decl; @@ -172,8 +167,6 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, const uint procType = TGSI_PROCESSOR_FRAGMENT; uint ti; - tokens = (struct tgsi_token *) MALLOC(maxTokens * sizeof(tokens[0])); - /* shader header */ *(struct tgsi_version *) &tokens[0] = tgsi_build_version(); @@ -199,7 +192,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, - maxTokens - ti); + Elements(tokens) - ti); /* declare color[0] output */ decl = tgsi_default_full_declaration(); @@ -212,7 +205,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, - maxTokens - ti); + Elements(tokens) - ti); /* declare sampler */ decl = tgsi_default_full_declaration(); @@ -222,7 +215,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, - maxTokens - ti); + Elements(tokens) - ti); /* TEX instruction */ inst = tgsi_default_full_instruction(); @@ -239,7 +232,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, - maxTokens - ti ); + Elements(tokens) - ti ); /* END instruction */ inst = tgsi_default_full_instruction(); @@ -249,16 +242,15 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, - maxTokens - ti ); + Elements(tokens) - ti ); #if 0 /*debug*/ tgsi_dump(tokens, 0); #endif - shader->tokens = tokens; - /*shader->num_tokens = ti;*/ + shader.tokens = tokens; - return pipe->create_fs_state(pipe, shader); + return pipe->create_fs_state(pipe, &shader); } @@ -269,11 +261,10 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, * Make simple fragment color pass-through shader. */ void * -util_make_fragment_passthrough_shader(struct pipe_context *pipe, - struct pipe_shader_state *shader) +util_make_fragment_passthrough_shader(struct pipe_context *pipe) { - uint maxTokens = 40; - struct tgsi_token *tokens; + struct pipe_shader_state shader; + struct tgsi_token tokens[40]; struct tgsi_header *header; struct tgsi_processor *processor; struct tgsi_full_declaration decl; @@ -281,8 +272,6 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, const uint procType = TGSI_PROCESSOR_FRAGMENT; uint ti; - tokens = (struct tgsi_token *) MALLOC(maxTokens * sizeof(tokens[0])); - /* shader header */ *(struct tgsi_version *) &tokens[0] = tgsi_build_version(); @@ -306,7 +295,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, - maxTokens - ti); + Elements(tokens) - ti); /* declare output */ decl = tgsi_default_full_declaration(); @@ -319,7 +308,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, - maxTokens - ti); + Elements(tokens) - ti); /* MOVE out[0], in[0]; */ @@ -334,7 +323,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, - maxTokens - ti ); + Elements(tokens) - ti ); /* END instruction */ inst = tgsi_default_full_instruction(); @@ -344,24 +333,17 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, - maxTokens - ti ); + Elements(tokens) - ti ); - assert(ti < maxTokens); + assert(ti < Elements(tokens)); #if 0 /*debug*/ tgsi_dump(tokens, 0); #endif - shader->tokens = tokens; - /*shader->num_tokens = ti;*/ + shader.tokens = tokens; - return pipe->create_fs_state(pipe, shader); + return pipe->create_fs_state(pipe, &shader); } -void -util_free_shader(struct pipe_shader_state *shader) -{ - FREE((struct tgsi_token *)shader->tokens); - shader->tokens = NULL; -} -- cgit v1.2.3