diff options
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_blit.c | 10 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_gen_mipmap.c | 10 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_simple_shaders.c | 76 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_simple_shaders.h | 13 |
4 files changed, 36 insertions, 73 deletions
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 3b3777b873..98bb6a2ce7 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -60,8 +60,6 @@ struct blit_state struct pipe_sampler_state sampler; struct pipe_viewport_state viewport; - struct pipe_shader_state vert_shader; - struct pipe_shader_state frag_shader; void *vs; void *fs; @@ -134,12 +132,11 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) TGSI_SEMANTIC_GENERIC }; const uint semantic_indexes[] = { 0, 0 }; ctx->vs = util_make_vertex_passthrough_shader(pipe, 2, semantic_names, - semantic_indexes, - &ctx->vert_shader); + semantic_indexes); } /* fragment shader */ - ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader); + ctx->fs = util_make_fragment_tex_shader(pipe); ctx->vbuf = NULL; /* init vertex data that doesn't change */ @@ -164,9 +161,6 @@ util_destroy_blit(struct blit_state *ctx) pipe->delete_vs_state(pipe, ctx->vs); pipe->delete_fs_state(pipe, ctx->fs); - FREE((void*) ctx->vert_shader.tokens); - FREE((void*) ctx->frag_shader.tokens); - pipe_buffer_reference(&ctx->vbuf, NULL); FREE(ctx); diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 2b675e71b2..847b4a6075 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -64,8 +64,6 @@ struct gen_mipmap_state struct pipe_sampler_state sampler; struct pipe_viewport_state viewport; - struct pipe_shader_state vert_shader; - struct pipe_shader_state frag_shader; void *vs; void *fs; @@ -1322,12 +1320,11 @@ util_create_gen_mipmap(struct pipe_context *pipe, TGSI_SEMANTIC_GENERIC }; const uint semantic_indexes[] = { 0, 0 }; ctx->vs = util_make_vertex_passthrough_shader(pipe, 2, semantic_names, - semantic_indexes, - &ctx->vert_shader); + semantic_indexes); } /* fragment shader */ - ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader); + ctx->fs = util_make_fragment_tex_shader(pipe); /* vertex data that doesn't change */ for (i = 0; i < 4; i++) { @@ -1412,9 +1409,6 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx) pipe->delete_vs_state(pipe, ctx->vs); pipe->delete_fs_state(pipe, ctx->fs); - FREE((void*) ctx->vert_shader.tokens); - FREE((void*) ctx->frag_shader.tokens); - pipe_buffer_reference(&ctx->vbuf, NULL); FREE(ctx); 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; -} diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h index 99b8d9067d..6f8d96af9b 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.h +++ b/src/gallium/auxiliary/util/u_simple_shaders.h @@ -46,22 +46,15 @@ extern 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); extern void * -util_make_fragment_tex_shader(struct pipe_context *pipe, - struct pipe_shader_state *shader); +util_make_fragment_tex_shader(struct pipe_context *pipe); extern void * -util_make_fragment_passthrough_shader(struct pipe_context *pipe, - struct pipe_shader_state *shader); - - -extern void -util_free_shader(struct pipe_shader_state *shader); +util_make_fragment_passthrough_shader(struct pipe_context *pipe); #ifdef __cplusplus |