summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-08-30 12:36:03 +0100
committerJosé Fonseca <[email protected]>2009-08-30 12:37:03 +0100
commitc28f253ac26e2d5a8cc7befa35e754515d4510dd (patch)
tree863fc12797f182883199374b5da2da6d6d9b7470 /src/gallium
parent62b586fce43ac117dcb553baa1fe884053fdef12 (diff)
llvmpipe: Texture cache in 4 ubytes instead of 4 floats.
This is more a short term experiment than a long term commitment, as we'll need to support higher precision textures too, as this will all be be replaced by runtime generated code. With this change most Mesa demos fps increased around 10%. Not a huge improvement, but not a negligible one either.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tex_cache.c8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tex_cache.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tex_sample.c28
3 files changed, 19 insertions, 19 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_tex_cache.c b/src/gallium/drivers/llvmpipe/lp_tex_cache.c
index e5a6ab825c3..23a94b5b0d5 100644
--- a/src/gallium/drivers/llvmpipe/lp_tex_cache.c
+++ b/src/gallium/drivers/llvmpipe/lp_tex_cache.c
@@ -290,10 +290,10 @@ lp_find_cached_tex_tile(struct llvmpipe_tex_tile_cache *tc,
assert(0);
}
- util_format_read_4f(tc->tex_trans->format,
- (float *)tile->color, sizeof tile->color[0],
- tc->tex_trans_map, tc->tex_trans->stride,
- x, y, w, h);
+ util_format_read_4ub(tc->tex_trans->format,
+ (uint8_t *)tile->color, sizeof tile->color[0],
+ tc->tex_trans_map, tc->tex_trans->stride,
+ x, y, w, h);
}
tile->addr = addr;
diff --git a/src/gallium/drivers/llvmpipe/lp_tex_cache.h b/src/gallium/drivers/llvmpipe/lp_tex_cache.h
index 106b5059b71..9fa6c368125 100644
--- a/src/gallium/drivers/llvmpipe/lp_tex_cache.h
+++ b/src/gallium/drivers/llvmpipe/lp_tex_cache.h
@@ -61,7 +61,7 @@ union tex_tile_address {
struct llvmpipe_cached_tex_tile
{
union tex_tile_address addr;
- float color[TEX_TILE_SIZE][TEX_TILE_SIZE][4];
+ uint8_t color[TEX_TILE_SIZE][TEX_TILE_SIZE][4];
};
#define NUM_ENTRIES 50
diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c
index 13e1780f9ac..94eb6dad5af 100644
--- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c
+++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c
@@ -666,7 +666,7 @@ choose_mipmap_levels(struct tgsi_sampler *tgsi_sampler,
static void
get_texel_quad_2d(const struct tgsi_sampler *tgsi_sampler,
unsigned face, unsigned level, int x, int y,
- const float *out[4])
+ const uint8_t *out[4])
{
const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler);
@@ -683,7 +683,7 @@ get_texel_quad_2d(const struct tgsi_sampler *tgsi_sampler,
out[3] = &tile->color[y+1][x+1][0];
}
-static INLINE const float *
+static INLINE const uint8_t *
get_texel_2d_ptr(const struct tgsi_sampler *tgsi_sampler,
unsigned face, unsigned level, int x, int y)
{
@@ -705,7 +705,7 @@ get_texel_quad_2d_mt(const struct tgsi_sampler *tgsi_sampler,
unsigned face, unsigned level,
int x0, int y0,
int x1, int y1,
- const float *out[4])
+ const uint8_t *out[4])
{
unsigned i;
@@ -742,10 +742,10 @@ get_texel(const struct tgsi_sampler *tgsi_sampler,
tile = lp_get_cached_tex_tile(samp->cache,
tex_tile_address(x, y, z, face, level));
- rgba[0][j] = tile->color[ty][tx][0];
- rgba[1][j] = tile->color[ty][tx][1];
- rgba[2][j] = tile->color[ty][tx][2];
- rgba[3][j] = tile->color[ty][tx][3];
+ rgba[0][j] = ubyte_to_float(tile->color[ty][tx][0]);
+ rgba[1][j] = ubyte_to_float(tile->color[ty][tx][1]);
+ rgba[2][j] = ubyte_to_float(tile->color[ty][tx][2]);
+ rgba[3][j] = ubyte_to_float(tile->color[ty][tx][3]);
if (0)
{
debug_printf("Get texel %f %f %f %f from %s\n",
@@ -912,7 +912,7 @@ lp_get_samples_2d_linear_repeat_POT(struct tgsi_sampler *tgsi_sampler,
int x0 = uflr & (xpot - 1);
int y0 = vflr & (ypot - 1);
- const float *tx[4];
+ const uint8_t *tx[4];
/* Can we fetch all four at once:
@@ -933,8 +933,8 @@ lp_get_samples_2d_linear_repeat_POT(struct tgsi_sampler *tgsi_sampler,
/* interpolate R, G, B, A */
for (c = 0; c < 4; c++) {
rgba[c][j] = lerp_2d(xw, yw,
- tx[0][c], tx[1][c],
- tx[2][c], tx[3][c]);
+ ubyte_to_float(tx[0][c]), ubyte_to_float(tx[1][c]),
+ ubyte_to_float(tx[2][c]), ubyte_to_float(tx[3][c]));
}
}
}
@@ -966,10 +966,10 @@ lp_get_samples_2d_nearest_repeat_POT(struct tgsi_sampler *tgsi_sampler,
int x0 = uflr & (xpot - 1);
int y0 = vflr & (ypot - 1);
- const float *out = get_texel_2d_ptr(tgsi_sampler, 0, level, x0, y0);
+ const uint8_t *out = get_texel_2d_ptr(tgsi_sampler, 0, level, x0, y0);
for (c = 0; c < 4; c++) {
- rgba[c][j] = out[c];
+ rgba[c][j] = ubyte_to_float(out[c]);
}
}
}
@@ -996,7 +996,7 @@ lp_get_samples_2d_nearest_clamp_POT(struct tgsi_sampler *tgsi_sampler,
float v = t[j] * ypot;
int x0, y0;
- const float *out;
+ const uint8_t *out;
x0 = util_ifloor(u);
if (x0 < 0)
@@ -1013,7 +1013,7 @@ lp_get_samples_2d_nearest_clamp_POT(struct tgsi_sampler *tgsi_sampler,
out = get_texel_2d_ptr(tgsi_sampler, 0, level, x0, y0);
for (c = 0; c < 4; c++) {
- rgba[c][j] = out[c];
+ rgba[c][j] = ubyte_to_float(out[c]);
}
}
}