summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-08-06 17:14:22 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-08-06 17:14:22 -0600
commitea0007cc4ca077c7e3951c4fda122bd242728d70 (patch)
treeb1fb2c0f4f35185fc2816aaaac14ef2df6c1ebe8 /src/gallium
parentb908ce93d4280e5fd3a3b14f54b42bb2040a3742 (diff)
softpipe: add texture border color code
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 63b3b91110..ed150527e2 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -601,15 +601,25 @@ get_texel(struct tgsi_sampler *sampler,
unsigned face, unsigned level, int x, int y, int z,
float rgba[NUM_CHANNELS][QUAD_SIZE], unsigned j)
{
- const int tx = x % TILE_SIZE;
- const int ty = y % TILE_SIZE;
- const struct softpipe_cached_tile *tile
- = sp_get_cached_tile_tex(sampler->pipe, sampler->cache,
- x, y, z, face, level);
- rgba[0][j] = tile->data.color[ty][tx][0];
- rgba[1][j] = tile->data.color[ty][tx][1];
- rgba[2][j] = tile->data.color[ty][tx][2];
- rgba[3][j] = tile->data.color[ty][tx][3];
+ if (x < 0 || x >= sampler->texture->width[level] ||
+ y < 0 || y >= sampler->texture->height[level] ||
+ z < 0 || z >= sampler->texture->depth[level]) {
+ rgba[0][j] = sampler->state->border_color[0];
+ rgba[1][j] = sampler->state->border_color[1];
+ rgba[2][j] = sampler->state->border_color[2];
+ rgba[3][j] = sampler->state->border_color[3];
+ }
+ else {
+ const int tx = x % TILE_SIZE;
+ const int ty = y % TILE_SIZE;
+ const struct softpipe_cached_tile *tile
+ = sp_get_cached_tile_tex(sampler->pipe, sampler->cache,
+ x, y, z, face, level);
+ rgba[0][j] = tile->data.color[ty][tx][0];
+ rgba[1][j] = tile->data.color[ty][tx][1];
+ rgba[2][j] = tile->data.color[ty][tx][2];
+ rgba[3][j] = tile->data.color[ty][tx][3];
+ }
}