This is very much like the clipper/setup pipeline for primitives.
#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"
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 );
#include "pipe/p_state.h"
#include "pipe/p_context.h"
+#include "sp_tile.h"
struct softpipe_surface;
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;
}
-
-
#endif
#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
*/
setup->quad.y0 = y;
setup->quad.mask = mask;
- quad_shade( setup->stage.softpipe, &setup->quad );
+ quad_emit(setup->stage.softpipe, &setup->quad);
}
/* 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;
/* draw final quad */
if (setup->quad.mask) {
- quad_shade(setup->stage.softpipe, &setup->quad);
+ quad_emit(setup->stage.softpipe, &setup->quad);
}
}
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));
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 );
}
}
}
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;
}
--- /dev/null
+
+
+#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;
+ }
+
+}
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
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
*/
#include "glheader.h"
+#include "imports.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_tile.h"
/* 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;
}
#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;
+}
*/
#include "glheader.h"
+#include "imports.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
*
* 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++) {
}
}
}
+
+
+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;
+}
+
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