mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-11 06:28:09 +02:00
Clean-up, re-org some vertex/fragment shader state code.
This commit is contained in:
parent
292bbd4a72
commit
52659e3c23
4 changed files with 27 additions and 29 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 *);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue