diff options
author | Keith Whitwell <[email protected]> | 2009-07-16 14:14:32 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2009-08-29 09:21:16 +0100 |
commit | 3121484a8bde7af053fb627bd716be957fcef18c (patch) | |
tree | a53dffd0a3b75323f03eecdfba7b06f9095ad880 /src/gallium/drivers/llvmpipe | |
parent | c9a5930fe45a0a0299769bd2b672ca516d1bf39e (diff) |
llvmpipe: remove backwards dependency from tilecache to llvmpipe
The tile cache is a utility, it shouldn't know anything about the
entity which is making use of it (ie llvmpipe).
Remove llvmpipe parameter to all the tilecache function calls, and
also remove the need to keep a llvmpipe pointer in the sampler structs.
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_context.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_flush.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_quad_blend.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_quad_colormask.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_quad_depth_test.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_quad_output.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_quad_stencil.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_derived.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_sampler.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_surface.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_tex_sample.c | 32 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_tex_sample.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_tile_cache.c | 20 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_tile_cache.h | 12 |
14 files changed, 62 insertions, 65 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 66a6e791931..8341cc1bc11 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -73,8 +73,8 @@ llvmpipe_unmap_transfers(struct llvmpipe_context *lp) uint i; for (i = 0; i < lp->framebuffer.nr_cbufs; i++) - lp_flush_tile_cache(lp, lp->cbuf_cache[i]); - lp_flush_tile_cache(lp, lp->zsbuf_cache); + lp_flush_tile_cache(lp->cbuf_cache[i]); + lp_flush_tile_cache(lp->zsbuf_cache); for (i = 0; i < lp->framebuffer.nr_cbufs; i++) { lp_tile_cache_unmap_transfers(lp->cbuf_cache[i]); @@ -254,8 +254,6 @@ llvmpipe_create( struct pipe_screen *screen ) /* vertex shader samplers */ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { llvmpipe->tgsi.vert_samplers[i].base.get_samples = lp_get_samples_vertex; - llvmpipe->tgsi.vert_samplers[i].unit = i; - llvmpipe->tgsi.vert_samplers[i].lp = llvmpipe; llvmpipe->tgsi.vert_samplers[i].cache = llvmpipe->tex_cache[i]; llvmpipe->tgsi.vert_samplers_list[i] = &llvmpipe->tgsi.vert_samplers[i]; } @@ -263,8 +261,6 @@ llvmpipe_create( struct pipe_screen *screen ) /* fragment shader samplers */ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { llvmpipe->tgsi.frag_samplers[i].base.get_samples = lp_get_samples_fragment; - llvmpipe->tgsi.frag_samplers[i].unit = i; - llvmpipe->tgsi.frag_samplers[i].lp = llvmpipe; llvmpipe->tgsi.frag_samplers[i].cache = llvmpipe->tex_cache[i]; llvmpipe->tgsi.frag_samplers_list[i] = &llvmpipe->tgsi.frag_samplers[i]; } diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 2bb6414b3f4..f815e79003c 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -52,17 +52,17 @@ llvmpipe_flush( struct pipe_context *pipe, if (flags & PIPE_FLUSH_TEXTURE_CACHE) { for (i = 0; i < llvmpipe->num_textures; i++) { - lp_flush_tile_cache(llvmpipe, llvmpipe->tex_cache[i]); + lp_flush_tile_cache(llvmpipe->tex_cache[i]); } } if (flags & PIPE_FLUSH_RENDER_CACHE) { for (i = 0; i < llvmpipe->framebuffer.nr_cbufs; i++) if (llvmpipe->cbuf_cache[i]) - lp_flush_tile_cache(llvmpipe, llvmpipe->cbuf_cache[i]); + lp_flush_tile_cache(llvmpipe->cbuf_cache[i]); if (llvmpipe->zsbuf_cache) - lp_flush_tile_cache(llvmpipe, llvmpipe->zsbuf_cache); + lp_flush_tile_cache(llvmpipe->zsbuf_cache); /* Need this call for hardware buffers before swapbuffers. * diff --git a/src/gallium/drivers/llvmpipe/lp_quad_blend.c b/src/gallium/drivers/llvmpipe/lp_quad_blend.c index b281d7641b2..98603be52e4 100644 --- a/src/gallium/drivers/llvmpipe/lp_quad_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_quad_blend.c @@ -130,8 +130,7 @@ logicop_quad(struct quad_stage *qs, struct quad_header *quad) uint *dst4 = (uint *) dst; uint *res4 = (uint *) res; struct llvmpipe_cached_tile * - tile = lp_get_cached_tile(llvmpipe, - llvmpipe->cbuf_cache[cbuf], + tile = lp_get_cached_tile(llvmpipe->cbuf_cache[cbuf], quad->input.x0, quad->input.y0); float (*quadColor)[4] = quad->output.color[cbuf]; uint i, j; @@ -260,8 +259,7 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad) for (cbuf = 0; cbuf < llvmpipe->framebuffer.nr_cbufs; cbuf++) { float source[4][QUAD_SIZE], dest[4][QUAD_SIZE]; struct llvmpipe_cached_tile *tile - = lp_get_cached_tile(llvmpipe, - llvmpipe->cbuf_cache[cbuf], + = lp_get_cached_tile(llvmpipe->cbuf_cache[cbuf], quad->input.x0, quad->input.y0); float (*quadColor)[4] = quad->output.color[cbuf]; uint i, j; diff --git a/src/gallium/drivers/llvmpipe/lp_quad_colormask.c b/src/gallium/drivers/llvmpipe/lp_quad_colormask.c index ef95eae4542..205dea48828 100644 --- a/src/gallium/drivers/llvmpipe/lp_quad_colormask.c +++ b/src/gallium/drivers/llvmpipe/lp_quad_colormask.c @@ -54,8 +54,7 @@ colormask_quad(struct quad_stage *qs, struct quad_header *quad) for (cbuf = 0; cbuf < llvmpipe->framebuffer.nr_cbufs; cbuf++) { float dest[4][QUAD_SIZE]; struct llvmpipe_cached_tile *tile - = lp_get_cached_tile(llvmpipe, - llvmpipe->cbuf_cache[cbuf], + = lp_get_cached_tile(llvmpipe->cbuf_cache[cbuf], quad->input.x0, quad->input.y0); float (*quadColor)[4] = quad->output.color[cbuf]; uint i, j; diff --git a/src/gallium/drivers/llvmpipe/lp_quad_depth_test.c b/src/gallium/drivers/llvmpipe/lp_quad_depth_test.c index 5a1daf0fed9..fdb64ac3b45 100644 --- a/src/gallium/drivers/llvmpipe/lp_quad_depth_test.c +++ b/src/gallium/drivers/llvmpipe/lp_quad_depth_test.c @@ -60,7 +60,7 @@ lp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad) unsigned zmask = 0; unsigned j; struct llvmpipe_cached_tile *tile - = lp_get_cached_tile(llvmpipe, llvmpipe->zsbuf_cache, quad->input.x0, quad->input.y0); + = lp_get_cached_tile(llvmpipe->zsbuf_cache, quad->input.x0, quad->input.y0); assert(ps); /* shouldn't get here if there's no zbuffer */ diff --git a/src/gallium/drivers/llvmpipe/lp_quad_output.c b/src/gallium/drivers/llvmpipe/lp_quad_output.c index 94d5f5a4c83..d344b4e3a72 100644 --- a/src/gallium/drivers/llvmpipe/lp_quad_output.c +++ b/src/gallium/drivers/llvmpipe/lp_quad_output.c @@ -50,8 +50,7 @@ output_quad(struct quad_stage *qs, struct quad_header *quad) /* loop over colorbuffer outputs */ for (cbuf = 0; cbuf < llvmpipe->framebuffer.nr_cbufs; cbuf++) { struct llvmpipe_cached_tile *tile - = lp_get_cached_tile(llvmpipe, - llvmpipe->cbuf_cache[cbuf], + = lp_get_cached_tile(llvmpipe->cbuf_cache[cbuf], quad->input.x0, quad->input.y0); float (*quadColor)[4] = quad->output.color[cbuf]; int i, j; diff --git a/src/gallium/drivers/llvmpipe/lp_quad_stencil.c b/src/gallium/drivers/llvmpipe/lp_quad_stencil.c index 4c99067d45c..229f0d054d7 100644 --- a/src/gallium/drivers/llvmpipe/lp_quad_stencil.c +++ b/src/gallium/drivers/llvmpipe/lp_quad_stencil.c @@ -206,7 +206,7 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad) ubyte ref, wrtMask, valMask; ubyte stencilVals[QUAD_SIZE]; struct llvmpipe_cached_tile *tile - = lp_get_cached_tile(llvmpipe, llvmpipe->zsbuf_cache, quad->input.x0, quad->input.y0); + = lp_get_cached_tile(llvmpipe->zsbuf_cache, quad->input.x0, quad->input.y0); uint j; uint face = quad->input.facing; diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index 05a3a0495b4..16ae435d3aa 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -184,11 +184,33 @@ compute_cliprect(struct llvmpipe_context *lp) } +static void +update_tgsi_samplers( struct llvmpipe_context *llvmpipe ) +{ + unsigned i; + + /* vertex shader samplers */ + for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { + llvmpipe->tgsi.vert_samplers[i].sampler = llvmpipe->sampler[i]; + llvmpipe->tgsi.vert_samplers[i].texture = llvmpipe->texture[i]; + } + + /* fragment shader samplers */ + for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { + llvmpipe->tgsi.frag_samplers[i].sampler = llvmpipe->sampler[i]; + llvmpipe->tgsi.frag_samplers[i].texture = llvmpipe->texture[i]; + } +} + /* Hopefully this will remain quite simple, otherwise need to pull in * something like the state tracker mechanism. */ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) { + if (llvmpipe->dirty & (LP_NEW_SAMPLER | + LP_NEW_TEXTURE)) + update_tgsi_samplers( llvmpipe ); + if (llvmpipe->dirty & (LP_NEW_RASTERIZER | LP_NEW_FS | LP_NEW_VS)) diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index 3a0497fad22..02ae2c17e19 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -97,7 +97,7 @@ llvmpipe_set_sampler_textures(struct pipe_context *pipe, struct pipe_texture *tex = i < num ? texture[i] : NULL; pipe_texture_reference(&llvmpipe->texture[i], tex); - lp_tile_cache_set_texture(pipe, llvmpipe->tex_cache[i], tex); + lp_tile_cache_set_texture(llvmpipe->tex_cache[i], tex); } llvmpipe->num_textures = num; diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c index f1a3e6ae471..d14621e3744 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c @@ -53,7 +53,7 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe, /* check if changing cbuf */ if (lp->framebuffer.cbufs[i] != fb->cbufs[i]) { /* flush old */ - lp_flush_tile_cache(lp, lp->cbuf_cache[i]); + lp_flush_tile_cache(lp->cbuf_cache[i]); /* assign new */ lp->framebuffer.cbufs[i] = fb->cbufs[i]; @@ -68,7 +68,7 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe, /* zbuf changing? */ if (lp->framebuffer.zsbuf != fb->zsbuf) { /* flush old */ - lp_flush_tile_cache(lp, lp->zsbuf_cache); + lp_flush_tile_cache(lp->zsbuf_cache); /* assign new */ lp->framebuffer.zsbuf = fb->zsbuf; diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index f9f20accf9d..5a11ba0175c 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -668,10 +668,8 @@ get_texel(const struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE], unsigned j) { const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - struct llvmpipe_context *lp = samp->lp; - const uint unit = samp->unit; - const struct pipe_texture *texture = lp->texture[unit]; - const struct pipe_sampler_state *sampler = lp->sampler[unit]; + const struct pipe_texture *texture = samp->texture; + const struct pipe_sampler_state *sampler = samp->sampler; if (x < 0 || x >= (int) texture->width[level] || y < 0 || y >= (int) texture->height[level] || @@ -685,7 +683,7 @@ get_texel(const struct tgsi_sampler *tgsi_sampler, const int tx = x % TILE_SIZE; const int ty = y % TILE_SIZE; const struct llvmpipe_cached_tile *tile - = lp_get_cached_tile_tex(lp, samp->cache, + = lp_get_cached_tile_tex(samp->cache, x, y, z, face, level); rgba[0][j] = tile->data.color[ty][tx][0]; rgba[1][j] = tile->data.color[ty][tx][1]; @@ -840,10 +838,8 @@ lp_get_samples_2d_common(const struct tgsi_sampler *tgsi_sampler, const unsigned faces[4]) { const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct llvmpipe_context *lp = samp->lp; - const uint unit = samp->unit; - const struct pipe_texture *texture = lp->texture[unit]; - const struct pipe_sampler_state *sampler = lp->sampler[unit]; + const struct pipe_texture *texture = samp->texture; + const struct pipe_sampler_state *sampler = samp->sampler; unsigned level0, level1, j, imgFilter; int width, height; float levelBlend; @@ -992,10 +988,8 @@ lp_get_samples_3d(const struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct llvmpipe_context *lp = samp->lp; - const uint unit = samp->unit; - const struct pipe_texture *texture = lp->texture[unit]; - const struct pipe_sampler_state *sampler = lp->sampler[unit]; + const struct pipe_texture *texture = samp->texture; + const struct pipe_sampler_state *sampler = samp->sampler; /* get/map pipe_surfaces corresponding to 3D tex slices */ unsigned level0, level1, j, imgFilter; int width, height, depth; @@ -1139,10 +1133,8 @@ lp_get_samples_rect(const struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct llvmpipe_context *lp = samp->lp; - const uint unit = samp->unit; - const struct pipe_texture *texture = lp->texture[unit]; - const struct pipe_sampler_state *sampler = lp->sampler[unit]; + const struct pipe_texture *texture = samp->texture; + const struct pipe_sampler_state *sampler = samp->sampler; const uint face = 0; unsigned level0, level1, j, imgFilter; int width, height; @@ -1216,10 +1208,8 @@ lp_get_samples(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct llvmpipe_context *lp = samp->lp; - const uint unit = samp->unit; - const struct pipe_texture *texture = lp->texture[unit]; - const struct pipe_sampler_state *sampler = lp->sampler[unit]; + const struct pipe_texture *texture = samp->texture; + const struct pipe_sampler_state *sampler = samp->sampler; if (!texture) return; diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.h b/src/gallium/drivers/llvmpipe/lp_tex_sample.h index 8d380b6e285..08f14513311 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.h +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.h @@ -39,8 +39,9 @@ struct lp_shader_sampler { struct tgsi_sampler base; /**< base class */ - uint unit; - struct llvmpipe_context *lp; + const struct pipe_texture *texture; + const struct pipe_sampler_state *sampler; + struct llvmpipe_tile_cache *cache; }; diff --git a/src/gallium/drivers/llvmpipe/lp_tile_cache.c b/src/gallium/drivers/llvmpipe/lp_tile_cache.c index 870fa8a3812..08c48e4d1c1 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_cache.c +++ b/src/gallium/drivers/llvmpipe/lp_tile_cache.c @@ -236,8 +236,7 @@ lp_tile_cache_unmap_transfers(struct llvmpipe_tile_cache *tc) * Specify the texture to cache. */ void -lp_tile_cache_set_texture(struct pipe_context *pipe, - struct llvmpipe_tile_cache *tc, +lp_tile_cache_set_texture(struct llvmpipe_tile_cache *tc, struct pipe_texture *texture) { uint i; @@ -344,8 +343,7 @@ clear_tile(struct llvmpipe_cached_tile *tile, * Actually clear the tiles which were flagged as being in a clear state. */ static void -lp_tile_cache_flush_clear(struct pipe_context *pipe, - struct llvmpipe_tile_cache *tc) +lp_tile_cache_flush_clear(struct llvmpipe_tile_cache *tc) { struct pipe_transfer *pt = tc->transfer; const uint w = tc->transfer->width; @@ -382,8 +380,7 @@ lp_tile_cache_flush_clear(struct pipe_context *pipe, * any tiles "flagged" as cleared will be "really" cleared. */ void -lp_flush_tile_cache(struct llvmpipe_context *llvmpipe, - struct llvmpipe_tile_cache *tc) +lp_flush_tile_cache(struct llvmpipe_tile_cache *tc) { struct pipe_transfer *pt = tc->transfer; int inuse = 0, pos; @@ -409,7 +406,7 @@ lp_flush_tile_cache(struct llvmpipe_context *llvmpipe, } #if TILE_CLEAR_OPTIMIZATION - lp_tile_cache_flush_clear(&llvmpipe->pipe, tc); + lp_tile_cache_flush_clear(tc); #endif } else if (tc->texture) { @@ -431,8 +428,7 @@ lp_flush_tile_cache(struct llvmpipe_context *llvmpipe, * \param x, y position of tile, in pixels */ struct llvmpipe_cached_tile * -lp_get_cached_tile(struct llvmpipe_context *llvmpipe, - struct llvmpipe_tile_cache *tc, int x, int y) +lp_get_cached_tile(struct llvmpipe_tile_cache *tc, int x, int y) { struct pipe_transfer *pt = tc->transfer; @@ -513,11 +509,11 @@ tex_cache_pos(int x, int y, int z, int face, int level) * Tiles are read-only and indexed with more params. */ const struct llvmpipe_cached_tile * -lp_get_cached_tile_tex(struct llvmpipe_context *lp, - struct llvmpipe_tile_cache *tc, int x, int y, int z, +lp_get_cached_tile_tex(struct llvmpipe_tile_cache *tc, + int x, int y, int z, int face, int level) { - struct pipe_screen *screen = lp->pipe.screen; + struct pipe_screen *screen = tc->screen; /* tile pos in framebuffer: */ const int tile_x = x & ~(TILE_SIZE - 1); const int tile_y = y & ~(TILE_SIZE - 1); diff --git a/src/gallium/drivers/llvmpipe/lp_tile_cache.h b/src/gallium/drivers/llvmpipe/lp_tile_cache.h index 91e14668134..e82b4b856a3 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_cache.h +++ b/src/gallium/drivers/llvmpipe/lp_tile_cache.h @@ -80,25 +80,21 @@ extern void lp_tile_cache_unmap_transfers(struct llvmpipe_tile_cache *tc); extern void -lp_tile_cache_set_texture(struct pipe_context *pipe, - struct llvmpipe_tile_cache *tc, +lp_tile_cache_set_texture(struct llvmpipe_tile_cache *tc, struct pipe_texture *texture); extern void -lp_flush_tile_cache(struct llvmpipe_context *llvmpipe, - struct llvmpipe_tile_cache *tc); +lp_flush_tile_cache(struct llvmpipe_tile_cache *tc); extern void lp_tile_cache_clear(struct llvmpipe_tile_cache *tc, const float *rgba, uint clearValue); extern struct llvmpipe_cached_tile * -lp_get_cached_tile(struct llvmpipe_context *llvmpipe, - struct llvmpipe_tile_cache *tc, int x, int y); +lp_get_cached_tile(struct llvmpipe_tile_cache *tc, int x, int y); extern const struct llvmpipe_cached_tile * -lp_get_cached_tile_tex(struct llvmpipe_context *llvmpipe, - struct llvmpipe_tile_cache *tc, int x, int y, int z, +lp_get_cached_tile_tex(struct llvmpipe_tile_cache *tc, int x, int y, int z, int face, int level); |