diff options
author | José Fonseca <[email protected]> | 2009-10-09 15:52:18 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2009-10-09 15:53:53 +0100 |
commit | 85999695829823e459e11822b4846ed1db5c055d (patch) | |
tree | 7eb0ea2b8e65b0546361c5bbc39ff52512183495 /src/gallium/drivers | |
parent | f406ffaea62005157f56ea17709291326c4dca8a (diff) |
llvmpipe: Get jit_context/jit_function across the rasterizer.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.c | 28 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast_priv.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.c | 53 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup_context.h | 9 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup_tri.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 3 |
7 files changed, 50 insertions, 51 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 977f35c46cd..cba50c80491 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -188,14 +188,6 @@ void lp_rast_load_zstencil( struct lp_rasterizer *rast, /* Within a tile: */ -void lp_rast_set_state( struct lp_rasterizer *rast, - const union lp_rast_cmd_arg arg ) -{ - RAST_DEBUG("%s\n", __FUNCTION__); - - rast->shader_state = arg.set_state; -} - void lp_rast_shade_tile( struct lp_rasterizer *rast, const union lp_rast_cmd_arg arg ) @@ -219,7 +211,7 @@ void lp_rast_shade_quads( struct lp_rasterizer *rast, unsigned x, unsigned y, const unsigned *masks) { - const struct lp_rast_state *state = rast->shader_state; + const struct lp_rast_state *state = inputs->state; struct lp_rast_tile *tile = &rast->tile; void *color; void *depth; @@ -249,17 +241,17 @@ void lp_rast_shade_quads( struct lp_rasterizer *rast, assert(lp_check_alignment(depth, 16)); assert(lp_check_alignment(color, 16)); - assert(lp_check_alignment(state->jc.blend_color, 16)); + assert(lp_check_alignment(state->jit_context.blend_color, 16)); /* run shader */ - state->shader( &state->jc, - x, y, - inputs->a0, - inputs->dadx, - inputs->dady, - &mask[0][0], - color, - depth); + state->jit_function( &state->jit_context, + x, y, + inputs->a0, + inputs->dadx, + inputs->dady, + &mask[0][0], + color, + depth); } diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index 9dfdf25cda4..f371b709df3 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -45,12 +45,12 @@ struct pipe_screen; struct lp_rast_state { /* State for the shader: */ - struct lp_jit_context jc; + struct lp_jit_context jit_context; /* The shader itself. Probably we also need to pass a pointer to * the tile color/z/stencil data somehow: */ - lp_jit_frag_func shader; + lp_jit_frag_func jit_function; }; diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index eae8138aaf1..11e8e78e798 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -74,8 +74,6 @@ struct lp_rasterizer { unsigned clear_depth; char clear_stencil; } state; - - const struct lp_rast_state *shader_state; }; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 03c54798dca..428d2d00850 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -415,7 +415,7 @@ lp_setup_set_fs( struct setup_context *setup, SETUP_DEBUG("%s\n", __FUNCTION__); /* FIXME: reference count */ - setup->fs.jit_function = fs->current->jit_function; + setup->fs.current.jit_function = fs ? fs->current->jit_function : NULL; } void @@ -431,9 +431,9 @@ lp_setup_set_fs_constants(struct setup_context *setup, dummy = NULL; pipe_buffer_reference(&dummy, buffer); - setup->fs.jit_context.constants = data; + setup->fs.current.jit_context.constants = data; - setup->fs.jit_context_dirty = TRUE; + setup->fs.dirty = TRUE; } @@ -443,9 +443,9 @@ lp_setup_set_alpha_ref_value( struct setup_context *setup, { SETUP_DEBUG("%s\n", __FUNCTION__); - if(setup->fs.jit_context.alpha_ref_value != alpha_ref_value) { - setup->fs.jit_context.alpha_ref_value = alpha_ref_value; - setup->fs.jit_context_dirty = TRUE; + if(setup->fs.current.jit_context.alpha_ref_value != alpha_ref_value) { + setup->fs.current.jit_context.alpha_ref_value = alpha_ref_value; + setup->fs.dirty = TRUE; } } @@ -457,16 +457,16 @@ lp_setup_set_blend_color( struct setup_context *setup, SETUP_DEBUG("%s\n", __FUNCTION__); - if(!setup->fs.jit_context.blend_color) - setup->fs.jit_context.blend_color = align_malloc(4 * 16, 16); + if(!setup->fs.current.jit_context.blend_color) + setup->fs.current.jit_context.blend_color = align_malloc(4 * 16, 16); for (i = 0; i < 4; ++i) { uint8_t c = float_to_ubyte(blend_color->color[i]); for (j = 0; j < 16; ++j) - setup->fs.jit_context.blend_color[i*4 + j] = c; + setup->fs.current.jit_context.blend_color[i*4 + j] = c; } - setup->fs.jit_context_dirty = TRUE; + setup->fs.dirty = TRUE; } void @@ -490,7 +490,8 @@ lp_setup_set_sampler_textures( struct setup_context *setup, if(tex) { struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex); - struct lp_jit_texture *jit_tex = &setup->fs.jit_context.textures[i]; + struct lp_jit_texture *jit_tex; + jit_tex = &setup->fs.current.jit_context.textures[i]; jit_tex->width = tex->width[0]; jit_tex->height = tex->height[0]; jit_tex->stride = lp_tex->stride[0]; @@ -502,7 +503,7 @@ lp_setup_set_sampler_textures( struct setup_context *setup, } } - setup->fs.jit_context_dirty = TRUE; + setup->fs.dirty = TRUE; } boolean @@ -519,22 +520,28 @@ lp_setup_update_shader_state( struct setup_context *setup ) { SETUP_DEBUG("%s\n", __FUNCTION__); - if(setup->fs.jit_context_dirty) { - if(!setup->fs.last_jc || - memcmp(setup->fs.last_jc, &setup->fs.jit_context, sizeof *setup->fs.last_jc)) { - struct lp_jit_context *jc; - - jc = get_data(&setup->data, sizeof *jc); - if(jc) { - memcpy(jc, &setup->fs.jit_context, sizeof *jc); - setup->fs.last_jc = jc; + assert(setup->fs.current.jit_function); + + if(setup->fs.dirty) { + if(!setup->fs.stored || + memcmp(setup->fs.stored, + &setup->fs.current, + sizeof setup->fs.current) != 0) { + struct lp_rast_state *stored; + + stored = get_data(&setup->data, sizeof *stored); + if(stored) { + memcpy(stored, + &setup->fs.current, + sizeof setup->fs.current); + setup->fs.stored = stored; } } - setup->fs.jit_context_dirty = FALSE; + setup->fs.dirty = FALSE; } - assert(setup->fs.last_jc); + assert(setup->fs.stored); } diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h index 747e90fe202..c15a59e4d1e 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h @@ -110,12 +110,9 @@ struct setup_context { struct lp_shader_input input[PIPE_MAX_ATTRIBS]; unsigned nr_inputs; - struct lp_jit_context jit_context; - lp_jit_frag_func jit_function; - - boolean jit_context_dirty; - - const struct lp_jit_context *last_jc; + const struct lp_rast_state *stored; + struct lp_rast_state current; + boolean dirty; } fs; void (*point)( struct setup_context *, diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index 857fb6a9f88..78e53292ece 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -272,6 +272,8 @@ do_triangle_ccw(struct setup_context *setup, float c1, c2, c3; int minx, maxx, miny, maxy; + tri->inputs.state = setup->fs.stored; + tri->dx12 = x1 - x2; tri->dx23 = x2 - x3; tri->dx31 = x3 - x1; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index a12581a4868..0541d36580c 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -84,6 +84,7 @@ #include "lp_screen.h" #include "lp_context.h" #include "lp_buffer.h" +#include "lp_setup.h" #include "lp_state.h" #include "lp_tex_sample.h" #include "lp_debug.h" @@ -765,4 +766,6 @@ llvmpipe_update_fs(struct llvmpipe_context *lp) variant = generate_fragment(lp, shader, &key); shader->current = variant; + + lp_setup_set_fs(lp->setup, shader); } |