draw_pipe_stipple.c \
draw_pipe_twoside.c \
draw_pipe_unfilled.c \
+ draw_pipe_util.c \
draw_pipe_validate.c \
draw_pipe_vbuf.c \
draw_pipe_wide_line.c \
'draw_pipe_stipple.c',
'draw_pipe_twoside.c',
'draw_pipe_unfilled.c',
+ 'draw_pipe_util.c',
'draw_pipe_validate.c',
'draw_pipe_vbuf.c',
'draw_pipe_wide_line.c',
-/* This is only used for temporary verts.
- */
-#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
-
-
-/**
- * Allocate space for temporary post-transform vertices, such as for clipping.
- */
-void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
-{
- assert(!stage->tmp);
-
- stage->nr_tmps = nr;
-
- if (nr) {
- ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
- unsigned i;
-
- stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
-
- for (i = 0; i < nr; i++)
- stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
- }
-}
-
-
-void draw_free_temp_verts( struct draw_stage *stage )
-{
- if (stage->tmp) {
- FREE( stage->tmp[0] );
- FREE( stage->tmp );
- stage->tmp = NULL;
- }
-}
}
-/* Reset vertex ids. This is basically a type of flush.
- *
- * Called only from draw_pipe_vbuf.c
- */
-void draw_reset_vertex_ids(struct draw_context *draw)
-{
- struct draw_stage *stage = draw->pipeline.first;
-
- while (stage) {
- unsigned i;
-
- for (i = 0; i < stage->nr_tmps; i++)
- stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID;
-
- stage = stage->next;
- }
-
- if (draw->pipeline.verts)
- {
- unsigned i;
- char *verts = draw->pipeline.verts;
- unsigned stride = draw->pipeline.vertex_stride;
-
- for (i = 0; i < draw->pipeline.vertex_count; i++) {
- ((struct vertex_header *)verts)->vertex_id = UNDEFINED_VERTEX_ID;
- verts += stride;
- }
- }
-}
/* Code to run the pipeline on a fairly arbitary collection of vertices.
extern void draw_free_temp_verts( struct draw_stage *stage );
-extern void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );
+extern boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );
extern void draw_reset_vertex_ids( struct draw_context *draw );
+void draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header);
+void draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header);
+void draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header);
+
/**
* Generate the frag shader we'll use for drawing AA lines.
* This will be the user's shader plus some texture/modulate instructions.
*/
-static void
+static boolean
generate_aaline_fs(struct aaline_stage *aaline)
{
const struct pipe_shader_state *orig_fs = &aaline->fs->state;
aaline_fs = *orig_fs; /* copy to init */
aaline_fs.tokens = MALLOC(sizeof(struct tgsi_token) * MAX);
+ if (aaline_fs.tokens == NULL)
+ return FALSE;
memset(&transform, 0, sizeof(transform));
transform.colorOutput = -1;
= aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
aaline->fs->generic_attrib = transform.maxGeneric + 1;
+ return TRUE;
}
* When we're about to draw our first AA line in a batch, this function is
* called to tell the driver to bind our modified fragment shader.
*/
-static void
+static boolean
bind_aaline_fragment_shader(struct aaline_stage *aaline)
{
- if (!aaline->fs->aaline_fs) {
- generate_aaline_fs(aaline);
- }
+ if (!aaline->fs->aaline_fs &&
+ !generate_aaline_fs(aaline))
+ return FALSE;
+
aaline->driver_bind_fs_state(aaline->pipe, aaline->fs->aaline_fs);
+ return TRUE;
}
}
-static void
-passthrough_point(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->point(stage->next, header);
-}
-
-
-static void
-passthrough_tri(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->tri(stage->next, header);
-}
-
-
/**
* Draw a wide line by drawing a quad, using geometry which will
* fullfill GL's antialiased line requirements.
/*
* Bind (generate) our fragprog, sampler and texture
*/
- bind_aaline_fragment_shader(aaline);
+ if (!bind_aaline_fragment_shader(aaline)) {
+ stage->line = draw_pipe_passthrough_line;
+ return;
+ }
/* update vertex attrib info */
aaline->tex_slot = draw->num_vs_outputs;
aaline->stage.draw = draw;
aaline->stage.next = NULL;
- aaline->stage.point = passthrough_point;
+ aaline->stage.point = draw_pipe_passthrough_point;
aaline->stage.line = aaline_first_line;
- aaline->stage.tri = passthrough_tri;
+ aaline->stage.tri = draw_pipe_passthrough_tri;
aaline->stage.flush = aaline_flush;
aaline->stage.reset_stipple_counter = aaline_reset_stipple_counter;
aaline->stage.destroy = aaline_destroy;
}
-static void
-passthrough_line(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->line(stage->next, header);
-}
-
-
-static void
-passthrough_tri(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->tri(stage->next, header);
-}
/**
aapoint->stage.draw = draw;
aapoint->stage.next = NULL;
aapoint->stage.point = aapoint_first_point;
- aapoint->stage.line = passthrough_line;
- aapoint->stage.tri = passthrough_tri;
+ aapoint->stage.line = draw_pipe_passthrough_line;
+ aapoint->stage.tri = draw_pipe_passthrough_tri;
aapoint->stage.flush = aapoint_flush;
aapoint->stage.reset_stipple_counter = aapoint_reset_stipple_counter;
aapoint->stage.destroy = aapoint_destroy;
-static void cull_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line( stage->next, header );
-}
-
-
-static void cull_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-
static void cull_flush( struct draw_stage *stage, unsigned flags )
{
stage->tri = cull_first_tri;
cull->stage.draw = draw;
cull->stage.next = NULL;
- cull->stage.point = cull_point;
- cull->stage.line = cull_line;
+ cull->stage.point = draw_pipe_passthrough_point;
+ cull->stage.line = draw_pipe_passthrough_line;
cull->stage.tri = cull_first_tri;
cull->stage.flush = cull_flush;
cull->stage.reset_stipple_counter = cull_reset_stipple_counter;
}
-/* Flatshade point -- passthrough.
- */
-static void flatshade_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
static void flatshade_init_state( struct draw_stage *stage )
flatshade->stage.draw = draw;
flatshade->stage.next = NULL;
- flatshade->stage.point = flatshade_point;
+ flatshade->stage.point = draw_pipe_passthrough_point;
flatshade->stage.line = flatshade_first_line;
flatshade->stage.tri = flatshade_first_tri;
flatshade->stage.flush = flatshade_flush;
}
-static void offset_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line( stage->next, header );
-}
-
-
-static void offset_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
static void offset_flush( struct draw_stage *stage,
offset->stage.draw = draw;
offset->stage.next = NULL;
- offset->stage.point = offset_point;
- offset->stage.line = offset_line;
+ offset->stage.point = draw_pipe_passthrough_point;
+ offset->stage.line = draw_pipe_passthrough_line;
offset->stage.tri = offset_first_tri;
offset->stage.flush = offset_flush;
offset->stage.reset_stipple_counter = offset_reset_stipple_counter;
}
-static void
-passthrough_point(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->point(stage->next, header);
-}
-
-
-static void
-passthrough_line(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->line(stage->next, header);
-}
-
-
-static void
-passthrough_tri(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->tri(stage->next, header);
-}
pstip->driver_set_sampler_textures(pipe, num_samplers, pstip->state.textures);
/* now really draw first line */
- stage->tri = passthrough_tri;
+ stage->tri = draw_pipe_passthrough_tri;
stage->tri(stage, header);
}
pstip->stage.draw = draw;
pstip->stage.next = NULL;
- pstip->stage.point = passthrough_point;
- pstip->stage.line = passthrough_line;
+ pstip->stage.point = draw_pipe_passthrough_point;
+ pstip->stage.line = draw_pipe_passthrough_line;
pstip->stage.tri = pstip_first_tri;
pstip->stage.flush = pstip_flush;
pstip->stage.reset_stipple_counter = pstip_reset_stipple_counter;
}
-static void
-passthrough_point(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->point( stage->next, header );
-}
-
-
-static void
-passthrough_tri(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->tri(stage->next, header);
-}
static void
stipple->stage.draw = draw;
stipple->stage.next = NULL;
- stipple->stage.point = passthrough_point;
+ stipple->stage.point = draw_pipe_passthrough_point;
stipple->stage.line = stipple_first_line;
- stipple->stage.tri = passthrough_tri;
+ stipple->stage.tri = draw_pipe_passthrough_tri;
stipple->stage.reset_stipple_counter = reset_stipple_counter;
stipple->stage.flush = stipple_flush;
stipple->stage.destroy = stipple_destroy;
}
-static void twoside_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- /* pass-through */
- stage->next->line( stage->next, header );
-}
-
-
-static void twoside_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- /* pass-through */
- stage->next->point( stage->next, header );
-}
-
static void twoside_first_tri( struct draw_stage *stage,
struct prim_header *header )
twoside->stage.draw = draw;
twoside->stage.next = NULL;
- twoside->stage.point = twoside_point;
- twoside->stage.line = twoside_line;
+ twoside->stage.point = draw_pipe_passthrough_point;
+ twoside->stage.line = draw_pipe_passthrough_line;
twoside->stage.tri = twoside_first_tri;
twoside->stage.flush = twoside_flush;
twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter;
}
-static void unfilled_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line( stage->next, header );
-}
-
-
-static void unfilled_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
static void unfilled_flush( struct draw_stage *stage,
unsigned flags )
unfilled->stage.draw = draw;
unfilled->stage.next = NULL;
unfilled->stage.tmp = NULL;
- unfilled->stage.point = unfilled_point;
- unfilled->stage.line = unfilled_line;
+ unfilled->stage.point = draw_pipe_passthrough_point;
+ unfilled->stage.line = draw_pipe_passthrough_line;
unfilled->stage.tri = unfilled_first_tri;
unfilled->stage.flush = unfilled_flush;
unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter;
--- /dev/null
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "pipe/p_util.h"
+#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
+
+
+
+void
+draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header)
+{
+ stage->next->point(stage->next, header);
+}
+
+void
+draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header)
+{
+ stage->next->line(stage->next, header);
+}
+
+void
+draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header)
+{
+ stage->next->tri(stage->next, header);
+}
+
+
+
+
+
+/* This is only used for temporary verts.
+ */
+#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
+
+
+/**
+ * Allocate space for temporary post-transform vertices, such as for clipping.
+ */
+boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
+{
+ unsigned i;
+ ubyte *store;
+
+ assert(!stage->tmp);
+
+ stage->tmp = NULL;
+ stage->nr_tmps = nr;
+ if (nr == 0)
+ return FALSE;
+
+ store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
+ if (store == NULL)
+ return FALSE;
+
+ stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
+
+ for (i = 0; i < nr; i++)
+ stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
+
+ return TRUE;
+}
+
+
+void draw_free_temp_verts( struct draw_stage *stage )
+{
+ if (stage->tmp) {
+ FREE( stage->tmp[0] );
+ FREE( stage->tmp );
+ stage->tmp = NULL;
+ }
+}
+
+
+/* Reset vertex ids. This is basically a type of flush.
+ *
+ * Called only from draw_pipe_vbuf.c
+ */
+void draw_reset_vertex_ids(struct draw_context *draw)
+{
+ struct draw_stage *stage = draw->pipeline.first;
+
+ while (stage) {
+ unsigned i;
+
+ for (i = 0; i < stage->nr_tmps; i++)
+ stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID;
+
+ stage = stage->next;
+ }
+
+ if (draw->pipeline.verts)
+ {
+ unsigned i;
+ char *verts = draw->pipeline.verts;
+ unsigned stride = draw->pipeline.vertex_stride;
+
+ for (i = 0; i < draw->pipeline.vertex_count; i++) {
+ ((struct vertex_header *)verts)->vertex_id = UNDEFINED_VERTEX_ID;
+ verts += stride;
+ }
+ }
+}
+
}
-static void wideline_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-
-static void wideline_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->tri(stage->next, header);
-}
-
/**
* Draw a wide line by drawing a quad (two triangles).
wide->stage.draw = draw;
wide->stage.next = NULL;
- wide->stage.point = wideline_point;
+ wide->stage.point = draw_pipe_passthrough_point;
wide->stage.line = wideline_line;
- wide->stage.tri = wideline_tri;
+ wide->stage.tri = draw_pipe_passthrough_point;
wide->stage.flush = wideline_flush;
wide->stage.reset_stipple_counter = wideline_reset_stipple_counter;
wide->stage.destroy = wideline_destroy;
}
-static void passthrough_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-static void widepoint_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line(stage->next, header);
-}
-
-static void widepoint_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->tri(stage->next, header);
-}
/**
stage->point = widepoint_point;
}
else {
- stage->point = passthrough_point;
+ stage->point = draw_pipe_passthrough_point;
}
if (draw->rasterizer->point_sprite) {
wide->stage.draw = draw;
wide->stage.next = NULL;
wide->stage.point = widepoint_first_point;
- wide->stage.line = widepoint_line;
- wide->stage.tri = widepoint_tri;
+ wide->stage.line = draw_pipe_passthrough_line;
+ wide->stage.tri = draw_pipe_passthrough_tri;
wide->stage.flush = widepoint_flush;
wide->stage.reset_stipple_counter = widepoint_reset_stipple_counter;
wide->stage.destroy = widepoint_destroy;