softpipe: move all color-combine code into sp_quad_blend.c

Consolidate the read-modify-write color combining code from
the blend, colormask and output stages.
This commit is contained in:
Keith Whitwell
2009-07-24 20:19:18 +01:00
parent 42f1757189
commit a2f7ab1d15
10 changed files with 734 additions and 979 deletions

View File

@@ -15,17 +15,15 @@ C_SOURCES = \
sp_prim_setup.c \
sp_prim_vbuf.c \
sp_quad_pipe.c \
sp_quad_alpha_test.c \
sp_quad_blend.c \
sp_quad_colormask.c \
sp_quad_coverage.c \
sp_quad_depth_test.c \
sp_quad_earlyz.c \
sp_quad_fs.c \
sp_quad_occlusion.c \
sp_quad_output.c \
sp_quad_stencil.c \
sp_quad_stipple.c \
sp_quad_earlyz.c \
sp_quad_depth_test.c \
sp_quad_stencil.c \
sp_quad_fs.c \
sp_quad_alpha_test.c \
sp_quad_occlusion.c \
sp_quad_coverage.c \
sp_quad_blend.c \
sp_screen.c \
sp_setup.c \
sp_state_blend.c \

View File

@@ -18,13 +18,11 @@ softpipe = env.ConvenienceLibrary(
'sp_quad_alpha_test.c',
'sp_quad_blend.c',
'sp_quad_pipe.c',
'sp_quad_colormask.c',
'sp_quad_coverage.c',
'sp_quad_depth_test.c',
'sp_quad_earlyz.c',
'sp_quad_fs.c',
'sp_quad_occlusion.c',
'sp_quad_output.c',
'sp_quad_stencil.c',
'sp_quad_stipple.c',
'sp_query.c',

View File

@@ -97,8 +97,6 @@ static void softpipe_destroy( struct pipe_context *pipe )
softpipe->quad.occlusion->destroy( softpipe->quad.occlusion );
softpipe->quad.coverage->destroy( softpipe->quad.coverage );
softpipe->quad.blend->destroy( softpipe->quad.blend );
softpipe->quad.colormask->destroy( softpipe->quad.colormask );
softpipe->quad.output->destroy( softpipe->quad.output );
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
@@ -241,8 +239,6 @@ softpipe_create( struct pipe_screen *screen )
softpipe->quad.occlusion = sp_quad_occlusion_stage(softpipe);
softpipe->quad.coverage = sp_quad_coverage_stage(softpipe);
softpipe->quad.blend = sp_quad_blend_stage(softpipe);
softpipe->quad.colormask = sp_quad_colormask_stage(softpipe);
softpipe->quad.output = sp_quad_output_stage(softpipe);
/* vertex shader samplers */
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {

View File

@@ -123,8 +123,6 @@ struct softpipe_context {
struct quad_stage *occlusion;
struct quad_stage *coverage;
struct quad_stage *blend;
struct quad_stage *colormask;
struct quad_stage *output;
struct quad_stage *first; /**< points to one of the above stages */
} quad;

View File

@@ -117,39 +117,17 @@ do { \
static void
logicop_quads(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
logicop_quad(struct quad_stage *qs,
float (*quadColor)[4],
float (*dest)[4])
{
struct softpipe_context *softpipe = qs->softpipe;
uint cbuf;
/* loop over colorbuffer outputs */
for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) {
float dest[4][QUAD_SIZE];
ubyte src[4][4], dst[4][4], res[4][4];
uint *src4 = (uint *) src;
uint *dst4 = (uint *) dst;
uint *res4 = (uint *) res;
uint i, j;
uint j;
struct softpipe_cached_tile *
tile = sp_get_cached_tile(softpipe->cbuf_cache[cbuf],
quads[0]->input.x0,
quads[0]->input.y0);
for (i = 0; i < nr; i++) {
struct quad_header *quad = quads[i];
float (*quadColor)[4] = quad->output.color[cbuf];
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
}
/* convert to ubyte */
for (j = 0; j < 4; j++) { /* loop over R,G,B,A channels */
@@ -240,130 +218,18 @@ logicop_quads(struct quad_stage *qs,
quadColor[j][3] = ubyte_to_float(res[j][3]);
}
}
}
/* pass blended quad to next stage */
qs->next->run(qs->next, quads, nr);
}
static void
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];
uint i, j, q;
struct softpipe_cached_tile *tile
= sp_get_cached_tile(qs->softpipe->cbuf_cache[0],
quads[0]->input.x0,
quads[0]->input.y0);
for (q = 0; q < nr; q++) {
struct quad_header *quad = quads[q];
float (*quadColor)[4] = quad->output.color[0];
const float *alpha = quadColor[3];
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
int y = (quad->input.y0 & (TILE_SIZE-1)) + (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 */
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 */
}
/* pass blended quad to next stage */
qs->next->run(qs->next, quads, nr);
}
static void
blend_single_add_one_one(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
{
float dest[4][QUAD_SIZE];
uint i, j, q;
struct softpipe_cached_tile *tile
= sp_get_cached_tile(qs->softpipe->cbuf_cache[0],
quads[0]->input.x0,
quads[0]->input.y0);
for (q = 0; q < nr; q++) {
struct quad_header *quad = quads[q];
float (*quadColor)[4] = quad->output.color[0];
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][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 */
}
/* pass blended quad to next stage */
qs->next->run(qs->next, quads, nr);
}
static void
blend_quads_fallback(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
blend_quad(struct quad_stage *qs,
float (*quadColor)[4],
float (*dest)[4])
{
static const float zero[4] = { 0, 0, 0, 0 };
static const float one[4] = { 1, 1, 1, 1 };
struct softpipe_context *softpipe = qs->softpipe;
uint cbuf;
/* loop over colorbuffer outputs */
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->cbuf_cache[cbuf],
quads[0]->input.x0,
quads[0]->input.y0);
uint q, i, j;
for (q = 0; q < nr; q++) {
struct quad_header *quad = quads[q];
float (*quadColor)[4] = quad->output.color[cbuf];
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
}
float source[4][QUAD_SIZE];
/*
* Compute src/first term RGB
@@ -835,28 +701,247 @@ blend_quads_fallback(struct quad_stage *qs,
assert(0);
}
}
} /* cbuf loop */
/* pass blended quad to next stage */
qs->next->run(qs->next, quads, nr);
static void
colormask_quad(struct quad_stage *qs,
float (*quadColor)[4],
float (*dest)[4])
{
struct softpipe_context *softpipe = qs->softpipe;
/* R */
if (!(softpipe->blend->colormask & PIPE_MASK_R))
COPY_4V(quadColor[0], dest[0]);
/* G */
if (!(softpipe->blend->colormask & PIPE_MASK_G))
COPY_4V(quadColor[1], dest[1]);
/* B */
if (!(softpipe->blend->colormask & PIPE_MASK_B))
COPY_4V(quadColor[2], dest[2]);
/* A */
if (!(softpipe->blend->colormask & PIPE_MASK_A))
COPY_4V(quadColor[3], dest[3]);
}
static void
blend_quad(struct quad_stage *qs,
blend_fallback(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
{
struct softpipe_context *softpipe = qs->softpipe;
const struct pipe_blend_state *blend = softpipe->blend;
unsigned cbuf;
for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++)
{
float dest[4][QUAD_SIZE];
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe->cbuf_cache[cbuf],
quads[0]->input.x0,
quads[0]->input.y0);
uint q, i, j;
for (q = 0; q < nr; q++) {
struct quad_header *quad = quads[q];
float (*quadColor)[4] = quad->output.color[cbuf];
const int itx = (quad->input.x0 & (TILE_SIZE-1));
const int ity = (quad->input.y0 & (TILE_SIZE-1));
/* 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];
}
}
if (blend->logicop_enable) {
logicop_quad( qs, quadColor, dest );
}
else if (blend->blend_enable) {
blend_quad( qs, quadColor, dest );
}
if (blend->colormask != 0xf)
colormask_quad( qs, quadColor, dest );
/* Output color values
*/
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];
}
}
}
}
}
}
static void
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];
uint i, j, q;
struct softpipe_cached_tile *tile
= sp_get_cached_tile(qs->softpipe->cbuf_cache[0],
quads[0]->input.x0,
quads[0]->input.y0);
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));
/* 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 */
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 (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];
}
}
}
}
}
static void
blend_single_add_one_one(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
{
float dest[4][QUAD_SIZE];
uint i, j, q;
struct softpipe_cached_tile *tile
= sp_get_cached_tile(qs->softpipe->cbuf_cache[0],
quads[0]->input.x0,
quads[0]->input.y0);
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));
/* 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_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];
}
}
}
}
}
static void
single_output_color(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
{
uint i, j, q;
struct softpipe_cached_tile *tile
= sp_get_cached_tile(qs->softpipe->cbuf_cache[0],
quads[0]->input.x0,
quads[0]->input.y0);
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));
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];
}
}
}
}
}
static void
choose_blend_quad(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
{
struct softpipe_context *softpipe = qs->softpipe;
const struct pipe_blend_state *blend = softpipe->blend;
if (softpipe->blend->logicop_enable) {
qs->run = logicop_quads;
}
else {
qs->run = blend_quads_fallback;
qs->run = blend_fallback;
if (blend->rgb_src_factor == blend->alpha_src_factor &&
if (!softpipe->blend->logicop_enable &&
softpipe->blend->colormask == 0xf)
{
if (!blend->blend_enable) {
qs->run = single_output_color;
}
else if (blend->rgb_src_factor == blend->alpha_src_factor &&
blend->rgb_dst_factor == blend->alpha_dst_factor &&
blend->rgb_func == blend->alpha_func &&
softpipe->framebuffer.nr_cbufs == 1)
@@ -880,8 +965,7 @@ blend_quad(struct quad_stage *qs,
static void blend_begin(struct quad_stage *qs)
{
qs->run = blend_quad;
qs->next->begin(qs->next);
qs->run = choose_blend_quad;
}
@@ -897,7 +981,7 @@ struct quad_stage *sp_quad_blend_stage( struct softpipe_context *softpipe )
stage->softpipe = softpipe;
stage->begin = blend_begin;
stage->run = blend_quad;
stage->run = choose_blend_quad;
stage->destroy = blend_destroy;
return stage;

View File

@@ -1,74 +0,0 @@
#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_quad.h"
#include "sp_surface.h"
#include "sp_quad_pipe.h"
/**
* Loop over colorbuffers, passing quad to next stage each time.
*/
static void
cbuf_loop_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
float tmp[PIPE_MAX_COLOR_BUFS][4][QUAD_SIZE];
unsigned i;
assert(sizeof(quad->outputs.color) == sizeof(tmp));
assert(softpipe->framebuffer.nr_cbufs <= PIPE_MAX_COLOR_BUFS);
/* make copy of original colors since they can get modified
* by blending and masking.
* XXX we won't have to do this if the fragment program actually emits
* N separate colors and we're drawing to N color buffers (MRT).
* But if we emitted one color and glDrawBuffer(GL_FRONT_AND_BACK) is
* in effect, we need to save/restore colors like this.
*/
memcpy(tmp, quad->outputs.color, sizeof(tmp));
for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
/* set current cbuffer */
#if 0 /* obsolete & going away */
softpipe->current_cbuf = i;
#endif
/* pass blended quad to next stage */
qs->next->run(qs->next, quad);
/* restore quad's colors for next buffer */
memcpy(quad->outputs.color, tmp, sizeof(tmp));
}
}
static void cbuf_loop_begin(struct quad_stage *qs)
{
qs->next->begin(qs->next);
}
static void cbuf_loop_destroy(struct quad_stage *qs)
{
FREE( qs );
}
/**
* Create the colorbuffer loop stage.
* This is used to implement multiple render targets and GL_FRONT_AND_BACK
* rendering.
*/
struct quad_stage *sp_quad_bufloop_stage( struct softpipe_context *softpipe )
{
struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
stage->softpipe = softpipe;
stage->begin = cbuf_loop_begin;
stage->run = cbuf_loop_quad;
stage->destroy = cbuf_loop_destroy;
return stage;
}

View File

@@ -1,126 +0,0 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/**
* \brief quad colormask stage
* \author Brian Paul
*/
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_quad.h"
#include "sp_surface.h"
#include "sp_quad_pipe.h"
#include "sp_tile_cache.h"
/**
* XXX colormask could be rolled into blending...
*/
static void
colormask_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
uint cbuf;
/* loop over colorbuffer outputs */
for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) {
float dest[4][QUAD_SIZE];
struct softpipe_cached_tile *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;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
}
/* R */
if (!(softpipe->blend->colormask & PIPE_MASK_R))
COPY_4V(quadColor[0], dest[0]);
/* G */
if (!(softpipe->blend->colormask & PIPE_MASK_G))
COPY_4V(quadColor[1], dest[1]);
/* B */
if (!(softpipe->blend->colormask & PIPE_MASK_B))
COPY_4V(quadColor[2], dest[2]);
/* A */
if (!(softpipe->blend->colormask & PIPE_MASK_A))
COPY_4V(quadColor[3], dest[3]);
}
}
static void
colormask_quads(struct quad_stage *qs, struct quad_header *quads[],
unsigned nr)
{
unsigned i;
for (i = 0; i < nr; i++)
colormask_quad(qs, quads[i]);
/* pass quad to next stage */
qs->next->run(qs->next, quads, nr);
}
static void colormask_begin(struct quad_stage *qs)
{
qs->next->begin(qs->next);
}
static void colormask_destroy(struct quad_stage *qs)
{
FREE( qs );
}
struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe )
{
struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
stage->softpipe = softpipe;
stage->begin = colormask_begin;
stage->run = colormask_quads;
stage->destroy = colormask_destroy;
return stage;
}

View File

@@ -68,7 +68,6 @@ coverage_run(struct quad_stage *qs,
struct quad_header *quads[],
unsigned nr)
{
struct softpipe_context *softpipe = qs->softpipe;
unsigned i;
for (i = 0; i < nr; i++)

View File

@@ -1,109 +0,0 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_quad.h"
#include "sp_surface.h"
#include "sp_quad_pipe.h"
#include "sp_tile_cache.h"
/**
* Last step of quad processing: write quad colors to the framebuffer,
* taking mask into account.
*/
static void
output_quad(struct quad_stage *qs, struct quad_header *quads[], unsigned nr)
{
struct softpipe_context *softpipe = qs->softpipe;
uint cbuf;
/* loop over colorbuffer outputs */
for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) {
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe->cbuf_cache[cbuf],
quads[0]->input.x0,
quads[0]->input.y0);
int i, j, q;
/* get/swizzle dest colors */
for (q = 0; q < nr; q++) {
struct quad_header *quad = quads[q];
float (*quadColor)[4] = quad->output.color[cbuf];
/* in-tile pos: */
const int itx = quad->input.x0 % TILE_SIZE;
const int ity = quad->input.y0 % TILE_SIZE;
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 (0) {
debug_printf("sp write pixel %d,%d: %g, %g, %g\n",
quad->input.x0 + x,
quad->input.y0 + y,
quadColor[0][j],
quadColor[1][j],
quadColor[2][j]);
}
}
}
}
}
}
static void output_begin(struct quad_stage *qs)
{
assert(qs->next == NULL);
}
static void output_destroy(struct quad_stage *qs)
{
FREE( qs );
}
struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe )
{
struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
stage->softpipe = softpipe;
stage->begin = output_begin;
stage->run = output_quad;
stage->destroy = output_destroy;
return stage;
}

View File

@@ -65,25 +65,16 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
/* Color combine
*/
sp->quad.first = sp->quad.output;
if (sp->blend->colormask != 0xf) {
sp_push_quad_first( sp, sp->quad.colormask );
}
if (sp->blend->blend_enable ||
sp->blend->logicop_enable) {
sp_push_quad_first( sp, sp->quad.blend );
}
sp->quad.first = sp->quad.blend;
/* Shade/Depth/Stencil/Alpha
*/
if ((sp->rasterizer->poly_smooth && sp->reduced_prim == PIPE_PRIM_TRIANGLES) ||
(sp->rasterizer->line_smooth && sp->reduced_prim == PIPE_PRIM_LINES) ||
(sp->rasterizer->point_smooth && sp->reduced_prim == PIPE_PRIM_POINTS)) {
sp_push_quad_first( sp, sp->quad.coverage );
}
/* Shade/Depth/Stencil/Alpha
*/
if (sp->active_query_count) {
sp_push_quad_first( sp, sp->quad.occlusion );
}