From 52659e3c238d961de1f25bed9254747f2f931547 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 1 Jan 2008 15:17:30 -0700 Subject: Clean-up, re-org some vertex/fragment shader state code. --- src/mesa/pipe/softpipe/sp_context.h | 7 ++----- src/mesa/pipe/softpipe/sp_state.h | 12 ++++++++--- src/mesa/pipe/softpipe/sp_state_derived.c | 2 +- src/mesa/pipe/softpipe/sp_state_fs.c | 35 +++++++++++++------------------ 4 files changed, 27 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 0b25e4c40b..394baf0109 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -43,13 +43,10 @@ struct softpipe_winsys; struct draw_context; struct draw_stage; struct softpipe_tile_cache; +struct sp_fragment_shader_state; +struct sp_vertex_shader_state; -struct sp_vertex_shader_state { - struct pipe_shader_state *state; - void *draw_data; -}; - struct softpipe_context { struct pipe_context pipe; /**< base class */ struct softpipe_winsys *winsys; /**< window system interface */ diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index ed16228ea2..c1f5555a86 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -60,9 +60,7 @@ struct gallivm_prog; -/** - * Softpipe fs state is derived from pipe_shader_state. - */ +/** Subclass of pipe_shader_state */ struct sp_fragment_shader_state { struct pipe_shader_state shader; #if defined(__i386__) || defined(__386__) @@ -74,6 +72,14 @@ struct sp_fragment_shader_state { }; +/** Subclass of pipe_shader_state */ +struct sp_vertex_shader_state { + struct pipe_shader_state shader; + void *draw_data; +}; + + + void * softpipe_create_blend_state(struct pipe_context *, const struct pipe_blend_state *); diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index a5e766781f..630ae3163f 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -40,7 +40,7 @@ */ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { - const struct pipe_shader_state *vs = softpipe->vs->state; + const struct pipe_shader_state *vs = &softpipe->vs->shader; const struct pipe_shader_state *fs = &softpipe->fs->shader; const enum interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index a360b4f02b..f72a91485f 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -42,18 +42,20 @@ void * softpipe_create_fs_state(struct pipe_context *pipe, const struct pipe_shader_state *templ) { struct softpipe_context *softpipe = softpipe_context(pipe); + struct sp_fragment_shader_state *state; /* Decide whether we'll be codegenerating this shader and if so do * that now. */ - struct sp_fragment_shader_state *state = MALLOC( sizeof(struct sp_fragment_shader_state) ); + state = CALLOC_STRUCT(sp_fragment_shader_state); + if (!state) + return NULL; + state->shader = *templ; - if( softpipe->dump_fs ) { - tgsi_dump( - state->shader.tokens, - 0 ); + if (softpipe->dump_fs) { + tgsi_dump(state->shader.tokens, 0); } #if defined(__i386__) || defined(__386__) @@ -75,6 +77,7 @@ void * softpipe_create_fs_state(struct pipe_context *pipe, return state; } + void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -84,6 +87,7 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) softpipe->dirty |= SP_NEW_FS; } + void softpipe_delete_fs_state(struct pipe_context *pipe, void *shader) { @@ -103,22 +107,16 @@ void * softpipe_create_vs_state(struct pipe_context *pipe, struct softpipe_context *softpipe = softpipe_context(pipe); struct sp_vertex_shader_state *state; - state = MALLOC( sizeof(struct sp_vertex_shader_state) ); + state = CALLOC_STRUCT(sp_vertex_shader_state); if (state == NULL ) { return NULL; } - state->state = MALLOC( sizeof(struct pipe_shader_state) ); - if (state->state == NULL) { - FREE( state ); - return NULL; - } - memcpy( state->state, templ, sizeof(struct pipe_shader_state) ); + state->shader = *templ; state->draw_data = draw_create_vertex_shader(softpipe->draw, - state->state); + &state->shader); if (state->draw_data == NULL) { - FREE( state->state ); FREE( state ); return NULL; } @@ -126,6 +124,7 @@ void * softpipe_create_vs_state(struct pipe_context *pipe, return state; } + void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -137,8 +136,8 @@ void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) softpipe->dirty |= SP_NEW_VS; } -void softpipe_delete_vs_state(struct pipe_context *pipe, - void *vs) + +void softpipe_delete_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -146,12 +145,10 @@ void softpipe_delete_vs_state(struct pipe_context *pipe, (struct sp_vertex_shader_state *)vs; draw_delete_vertex_shader(softpipe->draw, state->draw_data); - FREE( state->state ); FREE( state ); } - void softpipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf) @@ -170,5 +167,3 @@ void softpipe_set_constant_buffer(struct pipe_context *pipe, softpipe->dirty |= SP_NEW_CONSTANTS; } - - -- cgit v1.2.3