summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-07-16 14:14:32 +0100
committerKeith Whitwell <[email protected]>2009-07-22 12:47:59 +0100
commitaa5db684382bd8662a83ca09ed000e4a5a1013f9 (patch)
treed4ef507f02a680abbafd71ce02fd2924dc7664ea /src/gallium/drivers
parentede9f3b52ecb27ada81fee06a943bb595c60eaee (diff)
softpipe: remove backwards dependency from tilecache to softpipe
The tile cache is a utility, it shouldn't know anything about the entity which is making use of it (ie softpipe). Remove softpipe parameter to all the tilecache function calls, and also remove the need to keep a softpipe pointer in the sampler structs.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c8
-rw-r--r--src/gallium/drivers/softpipe/sp_flush.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_blend.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_colormask.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_depth_test.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_output.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stencil.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c22
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_surface.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c32
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.h5
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c20
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.h12
14 files changed, 62 insertions, 65 deletions
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 86df320ea8a..f085889d3a0 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -73,8 +73,8 @@ softpipe_unmap_transfers(struct softpipe_context *sp)
uint i;
for (i = 0; i < sp->framebuffer.nr_cbufs; i++)
- sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
- sp_flush_tile_cache(sp, sp->zsbuf_cache);
+ sp_flush_tile_cache(sp->cbuf_cache[i]);
+ sp_flush_tile_cache(sp->zsbuf_cache);
for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
sp_tile_cache_unmap_transfers(sp->cbuf_cache[i]);
@@ -254,8 +254,6 @@ softpipe_create( struct pipe_screen *screen )
/* vertex shader samplers */
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
softpipe->tgsi.vert_samplers[i].base.get_samples = sp_get_samples_vertex;
- softpipe->tgsi.vert_samplers[i].unit = i;
- softpipe->tgsi.vert_samplers[i].sp = softpipe;
softpipe->tgsi.vert_samplers[i].cache = softpipe->tex_cache[i];
softpipe->tgsi.vert_samplers_list[i] = &softpipe->tgsi.vert_samplers[i];
}
@@ -263,8 +261,6 @@ softpipe_create( struct pipe_screen *screen )
/* fragment shader samplers */
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
softpipe->tgsi.frag_samplers[i].base.get_samples = sp_get_samples_fragment;
- softpipe->tgsi.frag_samplers[i].unit = i;
- softpipe->tgsi.frag_samplers[i].sp = softpipe;
softpipe->tgsi.frag_samplers[i].cache = softpipe->tex_cache[i];
softpipe->tgsi.frag_samplers_list[i] = &softpipe->tgsi.frag_samplers[i];
}
diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c
index 4a14d49686e..732277a2c58 100644
--- a/src/gallium/drivers/softpipe/sp_flush.c
+++ b/src/gallium/drivers/softpipe/sp_flush.c
@@ -52,17 +52,17 @@ softpipe_flush( struct pipe_context *pipe,
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
for (i = 0; i < softpipe->num_textures; i++) {
- sp_flush_tile_cache(softpipe, softpipe->tex_cache[i]);
+ sp_flush_tile_cache(softpipe->tex_cache[i]);
}
}
if (flags & PIPE_FLUSH_RENDER_CACHE) {
for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++)
if (softpipe->cbuf_cache[i])
- sp_flush_tile_cache(softpipe, softpipe->cbuf_cache[i]);
+ sp_flush_tile_cache(softpipe->cbuf_cache[i]);
if (softpipe->zsbuf_cache)
- sp_flush_tile_cache(softpipe, softpipe->zsbuf_cache);
+ sp_flush_tile_cache(softpipe->zsbuf_cache);
/* Need this call for hardware buffers before swapbuffers.
*
diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c
index b1e18805c70..04b5daf3a41 100644
--- a/src/gallium/drivers/softpipe/sp_quad_blend.c
+++ b/src/gallium/drivers/softpipe/sp_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 softpipe_cached_tile *
- tile = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[cbuf],
+ tile = sp_get_cached_tile(softpipe->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 < softpipe->framebuffer.nr_cbufs; cbuf++) {
float source[4][QUAD_SIZE], dest[4][QUAD_SIZE];
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[cbuf],
+ = sp_get_cached_tile(softpipe->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/softpipe/sp_quad_colormask.c b/src/gallium/drivers/softpipe/sp_quad_colormask.c
index dc90e5d5e99..89efbe3b024 100644
--- a/src/gallium/drivers/softpipe/sp_quad_colormask.c
+++ b/src/gallium/drivers/softpipe/sp_quad_colormask.c
@@ -54,8 +54,7 @@ colormask_quad(struct quad_stage *qs, struct quad_header *quad)
for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) {
float dest[4][QUAD_SIZE];
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[cbuf],
+ = sp_get_cached_tile(softpipe->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/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
index d463930bae1..768b9275b30 100644
--- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
@@ -60,7 +60,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
unsigned zmask = 0;
unsigned j;
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
+ = sp_get_cached_tile(softpipe->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/softpipe/sp_quad_output.c b/src/gallium/drivers/softpipe/sp_quad_output.c
index 92d5f9f3c1a..dd8f5377e91 100644
--- a/src/gallium/drivers/softpipe/sp_quad_output.c
+++ b/src/gallium/drivers/softpipe/sp_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 < softpipe->framebuffer.nr_cbufs; cbuf++) {
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[cbuf],
+ = sp_get_cached_tile(softpipe->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/softpipe/sp_quad_stencil.c b/src/gallium/drivers/softpipe/sp_quad_stencil.c
index 5e9d447737d..34a8d9e9f6a 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stencil.c
+++ b/src/gallium/drivers/softpipe/sp_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 softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
+ = sp_get_cached_tile(softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
uint j;
uint face = quad->input.facing;
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index 75551000c9b..75be99768c9 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -184,11 +184,33 @@ compute_cliprect(struct softpipe_context *sp)
}
+static void
+update_tgsi_samplers( struct softpipe_context *softpipe )
+{
+ unsigned i;
+
+ /* vertex shader samplers */
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ softpipe->tgsi.vert_samplers[i].sampler = softpipe->sampler[i];
+ softpipe->tgsi.vert_samplers[i].texture = softpipe->texture[i];
+ }
+
+ /* fragment shader samplers */
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ softpipe->tgsi.frag_samplers[i].sampler = softpipe->sampler[i];
+ softpipe->tgsi.frag_samplers[i].texture = softpipe->texture[i];
+ }
+}
+
/* Hopefully this will remain quite simple, otherwise need to pull in
* something like the state tracker mechanism.
*/
void softpipe_update_derived( struct softpipe_context *softpipe )
{
+ if (softpipe->dirty & (SP_NEW_SAMPLER |
+ SP_NEW_TEXTURE))
+ update_tgsi_samplers( softpipe );
+
if (softpipe->dirty & (SP_NEW_RASTERIZER |
SP_NEW_FS |
SP_NEW_VS))
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index cb517b02e44..aa2f3f2ccd6 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -97,7 +97,7 @@ softpipe_set_sampler_textures(struct pipe_context *pipe,
struct pipe_texture *tex = i < num ? texture[i] : NULL;
pipe_texture_reference(&softpipe->texture[i], tex);
- sp_tile_cache_set_texture(pipe, softpipe->tex_cache[i], tex);
+ sp_tile_cache_set_texture(softpipe->tex_cache[i], tex);
}
softpipe->num_textures = num;
diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c
index 7c06d864a75..1621a276146 100644
--- a/src/gallium/drivers/softpipe/sp_state_surface.c
+++ b/src/gallium/drivers/softpipe/sp_state_surface.c
@@ -53,7 +53,7 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
/* check if changing cbuf */
if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {
/* flush old */
- sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
+ sp_flush_tile_cache(sp->cbuf_cache[i]);
/* assign new */
sp->framebuffer.cbufs[i] = fb->cbufs[i];
@@ -68,7 +68,7 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
/* zbuf changing? */
if (sp->framebuffer.zsbuf != fb->zsbuf) {
/* flush old */
- sp_flush_tile_cache(sp, sp->zsbuf_cache);
+ sp_flush_tile_cache(sp->zsbuf_cache);
/* assign new */
sp->framebuffer.zsbuf = fb->zsbuf;
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index a1d3bade27a..3daa88eedda 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_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 sp_shader_sampler *samp = sp_shader_sampler(tgsi_sampler);
- struct softpipe_context *sp = samp->sp;
- const uint unit = samp->unit;
- const struct pipe_texture *texture = sp->texture[unit];
- const struct pipe_sampler_state *sampler = sp->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 softpipe_cached_tile *tile
- = sp_get_cached_tile_tex(sp, samp->cache,
+ = sp_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 @@ sp_get_samples_2d_common(const struct tgsi_sampler *tgsi_sampler,
const unsigned faces[4])
{
const struct sp_shader_sampler *samp = sp_shader_sampler(tgsi_sampler);
- const struct softpipe_context *sp = samp->sp;
- const uint unit = samp->unit;
- const struct pipe_texture *texture = sp->texture[unit];
- const struct pipe_sampler_state *sampler = sp->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 @@ sp_get_samples_3d(const struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_shader_sampler *samp = sp_shader_sampler(tgsi_sampler);
- const struct softpipe_context *sp = samp->sp;
- const uint unit = samp->unit;
- const struct pipe_texture *texture = sp->texture[unit];
- const struct pipe_sampler_state *sampler = sp->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 @@ sp_get_samples_rect(const struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_shader_sampler *samp = sp_shader_sampler(tgsi_sampler);
- const struct softpipe_context *sp = samp->sp;
- const uint unit = samp->unit;
- const struct pipe_texture *texture = sp->texture[unit];
- const struct pipe_sampler_state *sampler = sp->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 @@ sp_get_samples(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_shader_sampler *samp = sp_shader_sampler(tgsi_sampler);
- const struct softpipe_context *sp = samp->sp;
- const uint unit = samp->unit;
- const struct pipe_texture *texture = sp->texture[unit];
- const struct pipe_sampler_state *sampler = sp->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/softpipe/sp_tex_sample.h b/src/gallium/drivers/softpipe/sp_tex_sample.h
index 40d8eb2c2a8..3c5beb560f2 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.h
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.h
@@ -39,8 +39,9 @@ struct sp_shader_sampler
{
struct tgsi_sampler base; /**< base class */
- uint unit;
- struct softpipe_context *sp;
+ const struct pipe_texture *texture;
+ const struct pipe_sampler_state *sampler;
+
struct softpipe_tile_cache *cache;
};
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 1f9b8f1f4fb..306284808cd 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -236,8 +236,7 @@ sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc)
* Specify the texture to cache.
*/
void
-sp_tile_cache_set_texture(struct pipe_context *pipe,
- struct softpipe_tile_cache *tc,
+sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
struct pipe_texture *texture)
{
uint i;
@@ -344,8 +343,7 @@ clear_tile(struct softpipe_cached_tile *tile,
* Actually clear the tiles which were flagged as being in a clear state.
*/
static void
-sp_tile_cache_flush_clear(struct pipe_context *pipe,
- struct softpipe_tile_cache *tc)
+sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
{
struct pipe_transfer *pt = tc->transfer;
const uint w = tc->transfer->width;
@@ -382,8 +380,7 @@ sp_tile_cache_flush_clear(struct pipe_context *pipe,
* any tiles "flagged" as cleared will be "really" cleared.
*/
void
-sp_flush_tile_cache(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc)
+sp_flush_tile_cache(struct softpipe_tile_cache *tc)
{
struct pipe_transfer *pt = tc->transfer;
int inuse = 0, pos;
@@ -409,7 +406,7 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
}
#if TILE_CLEAR_OPTIMIZATION
- sp_tile_cache_flush_clear(&softpipe->pipe, tc);
+ sp_tile_cache_flush_clear(tc);
#endif
}
else if (tc->texture) {
@@ -431,8 +428,7 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
* \param x, y position of tile, in pixels
*/
struct softpipe_cached_tile *
-sp_get_cached_tile(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc, int x, int y)
+sp_get_cached_tile(struct softpipe_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 softpipe_cached_tile *
-sp_get_cached_tile_tex(struct softpipe_context *sp,
- struct softpipe_tile_cache *tc, int x, int y, int z,
+sp_get_cached_tile_tex(struct softpipe_tile_cache *tc,
+ int x, int y, int z,
int face, int level)
{
- struct pipe_screen *screen = sp->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/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h
index 8f247d0e580..639cde67059 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.h
@@ -80,25 +80,21 @@ extern void
sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_set_texture(struct pipe_context *pipe,
- struct softpipe_tile_cache *tc,
+sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
struct pipe_texture *texture);
extern void
-sp_flush_tile_cache(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc);
+sp_flush_tile_cache(struct softpipe_tile_cache *tc);
extern void
sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba,
uint clearValue);
extern struct softpipe_cached_tile *
-sp_get_cached_tile(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc, int x, int y);
+sp_get_cached_tile(struct softpipe_tile_cache *tc, int x, int y);
extern const struct softpipe_cached_tile *
-sp_get_cached_tile_tex(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc, int x, int y, int z,
+sp_get_cached_tile_tex(struct softpipe_tile_cache *tc, int x, int y, int z,
int face, int level);