Commit a2f7ab1d authored by Keith Whitwell's avatar Keith Whitwell

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.
parent 42f17571
......@@ -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_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_output.c \
sp_quad_stencil.c \
sp_quad_stipple.c \
sp_quad_coverage.c \
sp_quad_blend.c \
sp_screen.c \
sp_setup.c \
sp_state_blend.c \
......
......@@ -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',
......
......@@ -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++) {
......
......@@ -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;
......
#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;
}
/**************************************************************************
*
* 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;
}
......@@ -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++)
......
/**************************************************************************
*
* 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;
}
......@@ -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 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment