diff options
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_context.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.c | 99 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.h | 23 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup_context.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_blend.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_derived.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_sampler.c | 10 |
9 files changed, 150 insertions, 34 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index e34385bbae..17c6939ff5 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -59,7 +59,7 @@ struct llvmpipe_context { const struct lp_vertex_shader *vs; /** Other rendering state */ - struct pipe_blend_color blend_color[4][16]; + struct pipe_blend_color blend_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; @@ -120,7 +120,6 @@ struct llvmpipe_context { unsigned tex_timestamp; boolean no_rast; - struct lp_jit_context jit_context; }; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 56bbee1f7c..f999004a66 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -32,11 +32,15 @@ * lp_setup_flush(). */ -#include "lp_setup_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_pack_color.h" -#include "pipe/p_defines.h" +#include "lp_state.h" +#include "lp_buffer.h" +#include "lp_texture.h" +#include "lp_setup_context.h" static void set_state( struct setup_context *, unsigned ); @@ -394,14 +398,99 @@ lp_setup_set_fs_inputs( struct setup_context *setup, } void -lp_setup_set_shader_state( struct setup_context *setup, - const struct lp_jit_context *jc ) +lp_setup_set_fs( struct setup_context *setup, + struct lp_fragment_shader *fs ) { - + /* FIXME: reference count */ + + setup->fs.jit_function = fs->current->jit_function; } +void +lp_setup_set_fs_constants(struct setup_context *setup, + struct pipe_buffer *buffer) +{ + const void *data = buffer ? llvmpipe_buffer(buffer)->data : NULL; + struct pipe_buffer *dummy; + /* FIXME: hold on to the reference */ + dummy = NULL; + pipe_buffer_reference(&dummy, buffer); + setup->fs.jit_context.constants = data; + + setup->fs.jit_context_dirty = TRUE; +} + + +void +lp_setup_set_alpha_ref_value( struct setup_context *setup, + float alpha_ref_value ) +{ + 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; + } +} + +void +lp_setup_set_blend_color( struct setup_context *setup, + const struct pipe_blend_color *blend_color ) +{ + unsigned i, j; + + if(!setup->fs.jit_context.blend_color) + setup->fs.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.jit_context_dirty = TRUE; +} + +void +lp_setup_set_sampler_textures( struct setup_context *setup, + unsigned num, struct pipe_texture **texture) +{ + struct pipe_texture *dummy; + unsigned i; + + assert(num <= PIPE_MAX_SAMPLERS); + + for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { + struct pipe_texture *tex = i < num ? texture[i] : NULL; + + /* FIXME: hold on to the reference */ + dummy = NULL; + pipe_texture_reference(&dummy, tex); + + if(tex) { + struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex); + struct lp_jit_texture *jit_tex = &setup->fs.jit_context.textures[i]; + jit_tex->width = tex->width[0]; + jit_tex->height = tex->height[0]; + jit_tex->stride = lp_tex->stride[0]; + if(!lp_tex->dt) + jit_tex->data = lp_tex->data; + else + /* FIXME: map the rendertarget */ + assert(0); + } + } + + setup->fs.jit_context_dirty = TRUE; +} + +static void +lp_setup_set_shader_state( struct setup_context *setup, + const struct lp_jit_context *jc ) +{ + + +} /* Stubs for lines & points for now: diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index bd439fa857..ac9c3cc0ee 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -50,7 +50,9 @@ struct lp_shader_input { struct pipe_texture; struct pipe_surface; +struct pipe_blend_color; struct setup_context; +struct lp_fragment_shader; struct lp_jit_context; struct setup_context * @@ -100,8 +102,25 @@ lp_setup_set_fs_inputs( struct setup_context *setup, unsigned nr ); void -lp_setup_set_shader_state( struct setup_context *setup, - const struct lp_jit_context *jc ); +lp_setup_set_fs( struct setup_context *setup, + struct lp_fragment_shader *fs ); + +void +lp_setup_set_fs_constants(struct setup_context *setup, + struct pipe_buffer *buffer); + + +void +lp_setup_set_alpha_ref_value( struct setup_context *setup, + float alpha_ref_value ); + +void +lp_setup_set_blend_color( struct setup_context *setup, + const struct pipe_blend_color *blend_color ); + +void +lp_setup_set_sampler_textures( struct setup_context *setup, + unsigned num, struct pipe_texture **texture); boolean lp_setup_is_texture_referenced( struct setup_context *setup, diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h index b29fec8ef0..2e2380dd80 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h @@ -109,6 +109,11 @@ struct setup_context { struct { 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; } fs; void (*point)( struct setup_context *, diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index a9980d6f14..64fe3600f5 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -54,6 +54,7 @@ #define LP_NEW_VERTEX 0x1000 #define LP_NEW_VS 0x2000 #define LP_NEW_QUERY 0x4000 +#define LP_NEW_BLEND_COLOR 0x8000 struct tgsi_sampler; diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c index 3f03bd0057..48afe5f524 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c @@ -67,17 +67,16 @@ void llvmpipe_set_blend_color( struct pipe_context *pipe, const struct pipe_blend_color *blend_color ) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); - unsigned i, j; + + if(!blend_color) + return; + + if(memcmp(&llvmpipe->blend_color, blend_color, sizeof *blend_color) == 0) + return; memcpy(&llvmpipe->blend_color, blend_color, sizeof *blend_color); - if(!llvmpipe->jit_context.blend_color) - llvmpipe->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) - llvmpipe->jit_context.blend_color[i*4 + j] = c; - } + llvmpipe->dirty |= LP_NEW_BLEND_COLOR; } @@ -101,9 +100,6 @@ llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe, llvmpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil; - if(llvmpipe->depth_stencil) - llvmpipe->jit_context.alpha_ref_value = llvmpipe->depth_stencil->alpha.ref_value; - llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index b801f054a2..00903c8ef4 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -33,6 +33,7 @@ #include "draw/draw_private.h" #include "lp_context.h" #include "lp_screen.h" +#include "lp_setup.h" #include "lp_state.h" @@ -256,6 +257,23 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) LP_NEW_TEXTURE)) llvmpipe_update_fs( llvmpipe ); + if (llvmpipe->dirty & (LP_NEW_BLEND | + LP_NEW_DEPTH_STENCIL_ALPHA | + LP_NEW_SAMPLER | + LP_NEW_TEXTURE)) + llvmpipe_update_fs( llvmpipe ); + + if (llvmpipe->dirty & LP_NEW_BLEND_COLOR) + lp_setup_set_blend_color(llvmpipe->setup, &llvmpipe->blend_color); + + if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) + lp_setup_set_alpha_ref_value(llvmpipe->setup, llvmpipe->depth_stencil->alpha.ref_value); + + if (llvmpipe->dirty & LP_NEW_CONSTANTS) + lp_setup_set_fs_constants(llvmpipe->setup, llvmpipe->constants[PIPE_SHADER_FRAGMENT].buffer); + + if (llvmpipe->dirty & LP_NEW_TEXTURE) + lp_setup_set_sampler_textures(llvmpipe->setup, llvmpipe->num_textures, llvmpipe->texture); llvmpipe->dirty = 0; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 59c7afc6f7..63e675e584 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -681,16 +681,15 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, assert(shader < PIPE_SHADER_TYPES); assert(index == 0); + if(llvmpipe->constants[shader].buffer == buffer) + return; + if(shader == PIPE_SHADER_VERTEX) draw_flush(llvmpipe->draw); /* note: reference counting */ pipe_buffer_reference(&llvmpipe->constants[shader].buffer, buffer); - if(shader == PIPE_SHADER_FRAGMENT) { - llvmpipe->jit_context.constants = data; - } - if(shader == PIPE_SHADER_VERTEX) { draw_set_mapped_constant_buffer(llvmpipe->draw, data, size); } diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index ae787801eb..e19394a4c9 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -96,16 +96,6 @@ llvmpipe_set_sampler_textures(struct pipe_context *pipe, struct pipe_texture *tex = i < num ? texture[i] : NULL; pipe_texture_reference(&llvmpipe->texture[i], tex); - - if(tex) { - struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex); - struct lp_jit_texture *jit_tex = &llvmpipe->jit_context.textures[i]; - jit_tex->width = tex->width[0]; - jit_tex->height = tex->height[0]; - jit_tex->stride = lp_tex->stride[0]; - if(!lp_tex->dt) - jit_tex->data = lp_tex->data; - } } llvmpipe->num_textures = num; |