summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe/sp_quad_blend.c
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2009-07-30 11:35:50 +0100
committerKeith Whitwell <keithw@vmware.com>2009-07-30 11:35:50 +0100
commit1295cf423e21dad04a947960782ffa8db2739709 (patch)
tree67617d5c5568ed6751c9578aa5fb427cf6e370d8 /src/gallium/drivers/softpipe/sp_quad_blend.c
parent73a6178a73a4cc34195348a537d3f94aab6a43e1 (diff)
softpipe: rearrange blend fastpaths
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_quad_blend.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_blend.c82
1 files changed, 27 insertions, 55 deletions
diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c
index e243c63fa2..b8ed086734 100644
--- a/src/gallium/drivers/softpipe/sp_quad_blend.c
+++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
@@ -793,10 +793,7 @@ blend_single_add_src_alpha_inv_src_alpha(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
{
- static const float one[4] = { 1, 1, 1, 1 };
- float one_minus_alpha[QUAD_SIZE];
- float dest[4][QUAD_SIZE];
- float source[4][QUAD_SIZE];
+ float source[4];
uint i, j, q;
struct softpipe_cached_tile *tile
@@ -806,45 +803,26 @@ blend_single_add_src_alpha_inv_src_alpha(struct quad_stage *qs,
for (q = 0; q < nr; q++) {
struct quad_header *quad = quads[q];
- float (*quadColor)[4] = quad->output.color[0];
- const float *alpha = quadColor[3];
const int itx = (quad->input.x0 & (TILE_SIZE-1));
const int ity = (quad->input.y0 & (TILE_SIZE-1));
+ float (*swzColor)[4] = quad->output.color[0];
- /* get/swizzle dest colors */
- for (j = 0; j < QUAD_SIZE; j++) {
- int x = itx + (j & 1);
- int y = ity + (j >> 1);
- for (i = 0; i < 4; i++) {
- dest[i][j] = tile->data.color[y][x][i];
- }
- }
-
- VEC4_MUL(source[0], quadColor[0], alpha); /* R */
- VEC4_MUL(source[1], quadColor[1], alpha); /* G */
- VEC4_MUL(source[2], quadColor[2], alpha); /* B */
- VEC4_MUL(source[3], quadColor[3], alpha); /* A */
+ for (j = 0; j < 4; j++) {
+ if (quad->inout.mask & (1<<j)) {
+ float *dest = tile->data.color[ity + (j>>1)][itx + (j&1)];
+ const float alpha = swzColor[3][j];
+ const float one_minus_alpha = 1.0 - alpha;
- VEC4_SUB(one_minus_alpha, one, alpha);
- VEC4_MUL(dest[0], dest[0], one_minus_alpha); /* R */
- VEC4_MUL(dest[1], dest[1], one_minus_alpha); /* G */
- VEC4_MUL(dest[2], dest[2], one_minus_alpha); /* B */
- VEC4_MUL(dest[3], dest[3], one_minus_alpha); /* B */
-
- VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */
- VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */
- VEC4_ADD_SAT(quadColor[2], source[2], dest[2]); /* B */
- VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */
+ for (i = 0; i < 4; i++) {
+ dest[i] *= one_minus_alpha;
+ dest[i] += swzColor[i][j] * alpha;
- for (j = 0; j < QUAD_SIZE; j++) {
- if (quad->inout.mask & (1 << j)) {
- int x = itx + (j & 1);
- int y = ity + (j >> 1);
- for (i = 0; i < 4; i++) { /* loop over color chans */
- tile->data.color[y][x][i] = quadColor[i][j];
+ /* XXX: redundant, will be clamped later for argb8 surfaces:
+ */
+ dest[i] = CLAMP(dest[i], 0.0, 1.0);
}
}
- }
+ }
}
}
@@ -863,33 +841,27 @@ blend_single_add_one_one(struct quad_stage *qs,
for (q = 0; q < nr; q++) {
struct quad_header *quad = quads[q];
- float (*quadColor)[4] = quad->output.color[0];
const int itx = (quad->input.x0 & (TILE_SIZE-1));
const int ity = (quad->input.y0 & (TILE_SIZE-1));
-
+ float (*dest)[64][4] = (float (*)[64][4])&tile->data.color[ity][itx];
+ float (*swzColor)[4] = quad->output.color[0];
+ float quadColor[4][4];
+
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- int x = itx + (j & 1);
- int y = ity + (j >> 1);
for (i = 0; i < 4; i++) {
- dest[i][j] = tile->data.color[y][x][i];
+ quadColor[i][j] = swzColor[j][i];
}
}
- VEC4_ADD_SAT(quadColor[0], quadColor[0], dest[0]); /* R */
- VEC4_ADD_SAT(quadColor[1], quadColor[1], dest[1]); /* G */
- VEC4_ADD_SAT(quadColor[2], quadColor[2], dest[2]); /* B */
- VEC4_ADD_SAT(quadColor[3], quadColor[3], dest[3]); /* A */
-
- for (j = 0; j < QUAD_SIZE; j++) {
- if (quad->inout.mask & (1 << j)) {
- int x = itx + (j & 1);
- int y = ity + (j >> 1);
- for (i = 0; i < 4; i++) { /* loop over color chans */
- tile->data.color[y][x][i] = quadColor[i][j];
- }
- }
- }
+ if (quad->inout.mask & 1)
+ VEC4_ADD_SAT(dest[0][0], quadColor[0], dest[0][0]);
+ if (quad->inout.mask & 2)
+ VEC4_ADD_SAT(dest[0][1], quadColor[1], dest[0][1]);
+ if (quad->inout.mask & 4)
+ VEC4_ADD_SAT(dest[1][0], quadColor[2], dest[1][0]);
+ if (quad->inout.mask & 8)
+ VEC4_ADD_SAT(dest[1][1], quadColor[3], dest[1][1]);
}
}