Initial implementation of a software pipeline for quad rasterization (fragment ops).

This is very much like the clipper/setup pipeline for primitives.
This commit is contained in:
Brian
2007-06-20 14:29:14 -06:00
parent 1edb5aafad
commit fb5cdbd078
11 changed files with 252 additions and 23 deletions
+3 -3
View File
@@ -32,9 +32,6 @@
#include "imports.h"
#include "macros.h"
#include "tnl/t_context.h"
#include "vf/vf.h"
#include "sp_context.h"
#include "sp_clear.h"
#include "sp_prim.h"
@@ -88,6 +85,9 @@ struct pipe_context *softpipe_create( void )
softpipe->prim.flatshade = prim_flatshade( softpipe );
softpipe->prim.cull = prim_cull( softpipe );
softpipe->quad.blend = sp_quad_blend_stage(softpipe);
softpipe->quad.shade = sp_quad_shade_stage(softpipe);
softpipe->quad.output = sp_quad_output_stage(softpipe);
softpipe->draw = draw_create( softpipe );
+13 -2
View File
@@ -36,6 +36,7 @@
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "sp_tile.h"
struct softpipe_surface;
@@ -129,6 +130,18 @@ struct softpipe_context {
GLuint vertex_size;
} prim;
/*
* Software quad rendering pipeline
*/
struct {
struct quad_stage *shade;
struct quad_stage *depth_test;
struct quad_stage *blend;
struct quad_stage *output;
struct quad_stage *first; /**< points to one of the above stages */
} quad;
/* Temp kludge:
*/
struct draw_context *draw;
@@ -144,6 +157,4 @@ softpipe_context( struct pipe_context *pipe )
}
#endif
+17 -5
View File
@@ -36,6 +36,18 @@
#include "sp_tile.h"
/**
* Emit/render a quad.
* This passes the quad to the first stage of per-fragment operations.
*/
static INLINE void
quad_emit(struct softpipe_context *sp, struct quad_header *quad)
{
sp->quad.first->run(sp->quad.first, quad);
}
/**
* Triangle edge info
*/
@@ -121,7 +133,7 @@ static void run_shader_block( struct setup_stage *setup,
setup->quad.y0 = y;
setup->quad.mask = mask;
quad_shade( setup->stage.softpipe, &setup->quad );
quad_emit(setup->stage.softpipe, &setup->quad);
}
@@ -652,7 +664,7 @@ plot(struct setup_stage *setup, GLint x, GLint y)
/* flush prev quad, start new quad */
if (setup->quad.x0 != -1)
quad_shade(setup->stage.softpipe, &setup->quad);
quad_emit(setup->stage.softpipe, &setup->quad);
setup->quad.x0 = quadX;
setup->quad.y0 = quadY;
@@ -755,7 +767,7 @@ setup_line(struct prim_stage *stage, struct prim_header *prim)
/* draw final quad */
if (setup->quad.mask) {
quad_shade(setup->stage.softpipe, &setup->quad);
quad_emit(setup->stage.softpipe, &setup->quad);
}
}
@@ -810,7 +822,7 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
setup->quad.x0 = x - ix;
setup->quad.y0 = y - iy;
setup->quad.mask = (1 << ix) << (2 * iy);
quad_shade(setup->stage.softpipe, &setup->quad);
quad_emit(setup->stage.softpipe, &setup->quad);
}
else {
const GLint ixmin = block((GLint) (x - halfSize));
@@ -870,7 +882,7 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
if (setup->quad.mask) {
setup->quad.x0 = ix;
setup->quad.y0 = iy;
quad_shade( setup->stage.softpipe, &setup->quad );
quad_emit( setup->stage.softpipe, &setup->quad );
}
}
}
@@ -132,5 +132,8 @@ void softpipe_update_derived( struct softpipe_context *softpipe )
if (softpipe->dirty & (G_NEW_SETUP | G_NEW_FS))
calculate_vertex_layout( softpipe );
if (softpipe->dirty & (G_NEW_BLEND | G_NEW_FS))
sp_build_quad_pipeline(softpipe);
softpipe->dirty = 0;
}
+24
View File
@@ -0,0 +1,24 @@
#include "sp_context.h"
void
sp_build_quad_pipeline(struct softpipe_context *sp)
{
sp->quad.first = sp->quad.output;
if (sp->blend.blend_enable) {
sp->quad.blend->next = sp->quad.first;
sp->quad.first = sp->quad.blend;
}
/* XXX always enable shader? */
if (1) {
sp->quad.shade->next = sp->quad.first;
sp->quad.first = sp->quad.shade;
}
}
+18 -4
View File
@@ -33,10 +33,24 @@
struct softpipe_context;
struct quad_header;
void quad_shade( struct softpipe_context *softpipe,
struct quad_header *quad );
void quad_output( struct softpipe_context *softpipe,
struct quad_header *quad );
struct quad_stage {
struct softpipe_context *softpipe;
struct quad_stage *next;
/** the stage action */
void (*run)(struct quad_stage *qs, struct quad_header *quad);
};
struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_blend_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe );
void
sp_build_quad_pipeline(struct softpipe_context *sp);
#endif
+70
View File
@@ -0,0 +1,70 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 1999-2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
/**
* quad blending
*/
#include "glheader.h"
#include "imports.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
#include "sp_tile.h"
static void
blend_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
GLfloat dest[4][QUAD_SIZE], result[4][QUAD_SIZE];
GLuint i;
/* XXX we're also looping in output_quad() !?! */
for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
struct softpipe_surface *sps
= softpipe_surface(softpipe->framebuffer.cbufs[i]);
sps->read_quad_f_swz(sps, quad->x0, quad->y0, dest);
/* XXX do blend here */
qs->next->run(qs->next, quad);
}
}
struct quad_stage *sp_quad_blend_stage( struct softpipe_context *softpipe )
{
struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
stage->softpipe = softpipe;
stage->run = blend_quad;
return stage;
}
@@ -0,0 +1,73 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 1999-2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
/**
* quad blending
*/
#include "glheader.h"
#include "imports.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
#include "sp_tile.h"
static void
depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
#if 0
struct softpipe_context *softpipe = qs->softpipe;
GLfloat dest[4][QUAD_SIZE], result[4][QUAD_SIZE];
GLuint i;
/* XXX we're also looping in output_quad() !?! */
for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
struct softpipe_surface *sps
= softpipe_surface(softpipe->framebuffer.cbufs[i]);
sps->read_quad_f_swz(sps, quad->x0, quad->y0, dest);
/* XXX do blend here */
}
#endif
qs->next->run(qs->next, quad);
}
struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe )
{
struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
stage->softpipe = softpipe;
stage->run = depth_test_quad;
return stage;
}
+12 -7
View File
@@ -33,6 +33,7 @@
*/
#include "glheader.h"
#include "imports.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_tile.h"
@@ -116,9 +117,10 @@ static INLINE void pinterp( struct exec_machine *exec,
/* This should be done by the fragment shader execution unit (code
* generated from the decl instructions). Do it here for now.
*/
void quad_shade( struct softpipe_context *softpipe,
struct quad_header *quad )
static void
shade_quad( struct quad_stage *qs, struct quad_header *quad )
{
struct softpipe_context *softpipe = qs->softpipe;
struct exec_machine exec;
GLfloat fx = quad->x0;
GLfloat fy = quad->y0;
@@ -190,14 +192,17 @@ void quad_shade( struct softpipe_context *softpipe,
}
#endif
if (quad->mask)
quad_output( softpipe, quad );
qs->next->run(qs->next, quad);
}
struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe )
{
struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
stage->softpipe = softpipe;
stage->run = shade_quad;
return stage;
}
+16 -2
View File
@@ -33,6 +33,7 @@
*/
#include "glheader.h"
#include "imports.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -60,9 +61,10 @@ static void mask_copy( GLfloat (*dest)[4],
*
* Note that surfaces support only full quad reads and writes.
*/
void quad_output( struct softpipe_context *softpipe,
struct quad_header *quad )
static void
output_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
GLuint i;
for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
@@ -87,3 +89,15 @@ void quad_output( struct softpipe_context *softpipe,
}
}
}
struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe )
{
struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
stage->softpipe = softpipe;
stage->run = output_quad;
return stage;
}
+3
View File
@@ -171,6 +171,9 @@ SOFTPIPE_SOURCES = \
pipe/softpipe/sp_state_point.c \
pipe/softpipe/sp_state_setup.c \
pipe/softpipe/sp_state_surface.c \
pipe/softpipe/sp_tile.c \
pipe/softpipe/sp_tile_blend.c \
pipe/softpipe/sp_tile_depth_test.c \
pipe/softpipe/sp_tile_fs.c \
pipe/softpipe/sp_tile_output.c