summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_rast.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-01-13 18:54:48 -0700
committerBrian Paul <[email protected]>2010-01-13 18:54:50 -0700
commitf94a99170ecdc3286408b3628fbae9f45518007e (patch)
treef7aab84e976d1347a6853f7565a02d443632f0e4 /src/gallium/drivers/llvmpipe/lp_rast.c
parentf19f218e7aad76639a6aacabda8101ba87bb4896 (diff)
llvmpipe: optimize lp_rast_clear_color() for non-gray colors
This makes a big difference in progs that clear to a non-gray color. Some demos are 30-50% faster.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_rast.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 6c7ece9fdbf..3849116758f 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -187,17 +187,33 @@ void lp_rast_clear_color( struct lp_rasterizer *rast,
if (clear_color[0] == clear_color[1] &&
clear_color[1] == clear_color[2] &&
clear_color[2] == clear_color[3]) {
+ /* clear to grayscale value {x, x, x, x} */
for (i = 0; i < rast->state.fb.nr_cbufs; i++) {
memset(color_tile[i], clear_color[0], TILE_SIZE * TILE_SIZE * 4);
}
}
else {
- unsigned x, y, chan;
- for (i = 0; i < rast->state.fb.nr_cbufs; i++)
- for (y = 0; y < TILE_SIZE; y++)
- for (x = 0; x < TILE_SIZE; x++)
- for (chan = 0; chan < 4; ++chan)
- TILE_PIXEL(color_tile[i], x, y, chan) = clear_color[chan];
+ /* Non-gray color.
+ * Note: if the swizzled tile layout changes (see TILE_PIXEL) this code
+ * will need to change. It'll be pretty obvious when clearing no longer
+ * works.
+ */
+ const unsigned chunk = TILE_SIZE / 4;
+ for (i = 0; i < rast->state.fb.nr_cbufs; i++) {
+ uint8_t *c = color_tile[i];
+ unsigned j;
+ for (j = 0; j < 4 * TILE_SIZE; j++) {
+ memset(c, clear_color[0], chunk);
+ c += chunk;
+ memset(c, clear_color[1], chunk);
+ c += chunk;
+ memset(c, clear_color[2], chunk);
+ c += chunk;
+ memset(c, clear_color[3], chunk);
+ c += chunk;
+ }
+ assert(c - color_tile[i] == TILE_SIZE * TILE_SIZE * 4);
+ }
}
}