diff options
Diffstat (limited to 'src/gallium/auxiliary/util/u_simple_shaders.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_simple_shaders.c | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 706155e99a..e519c354d2 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -34,9 +34,8 @@ #include "pipe/p_context.h" -#include "pipe/p_debug.h" +#include "util/u_debug.h" #include "pipe/p_defines.h" -#include "pipe/p_inlines.h" #include "pipe/p_screen.h" #include "pipe/p_shader_tokens.h" @@ -56,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; @@ -69,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(); @@ -97,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 */ @@ -112,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 */ @@ -129,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 */ @@ -140,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); } @@ -161,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; @@ -173,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(); @@ -200,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(); @@ -213,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(); @@ -223,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(); @@ -240,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(); @@ -250,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); } @@ -270,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; @@ -282,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(); @@ -307,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(); @@ -320,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]; */ @@ -335,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(); @@ -345,17 +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); } + |