{
draw->render = render;
}
+
+void draw_set_edgeflags( struct draw_context *draw,
+ const unsigned *edgeflag )
+{
+ draw->user.edgeflag = edgeflag;
+}
+
+
+boolean draw_get_edgeflag( struct draw_context *draw,
+ unsigned idx )
+{
+ if (draw->user.edgeflag)
+ return (draw->user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
+ else
+ return 1;
+}
void draw_set_mapped_constant_buffer(struct draw_context *draw,
const void *buffer);
+void draw_set_edgeflags( struct draw_context *draw,
+ const unsigned *edgeflag );
+
/***********************************************************************
* draw_prim.c
/* user-space vertex data, buffers */
struct {
+ const unsigned *edgeflag;
+
/** vertex element/index buffer (ex: glDrawElements) */
const void *elts;
/** bytes per index (0, 1, 2 or 4) */
unsigned count );
-/* Prototype/hack (DEPRECATED)
- */
-boolean
-draw_passthrough_arrays(struct draw_context *draw,
- unsigned prim,
- unsigned start,
- unsigned count);
-
-
#define DRAW_FLUSH_SHADER_QUEUE 0x1 /* sized not to overflow, never raised */
#define DRAW_FLUSH_PRIM_QUEUE 0x2
#define DRAW_FLUSH_VERTEX_CACHE 0x4
void draw_do_flush( struct draw_context *draw, unsigned flags );
+boolean draw_get_edgeflag( struct draw_context *draw,
+ unsigned idx );
/**
struct draw_pt_middle_end base;
struct draw_context *draw;
+ void (*header)( const unsigned *edgeflag, unsigned count, float **out);
+
struct {
const ubyte *ptr;
unsigned pitch;
};
-static void fetch_NULL( const void *from,
- float *attrib )
-{
-}
-
-
static void emit_R32_FLOAT( const float *attrib,
float **out )
(*out) += 4;
}
-static void emit_header( const float *attrib,
- float **out )
+static void header( const unsigned *edgeflag,
+ unsigned idx,
+ float **out )
{
struct vertex_header *header = (struct vertex_header *) (*out);
(*out) += 5;
}
+
+static void header_ef( const unsigned *edgeflag,
+ unsigned idx,
+ float **out )
+{
+ struct vertex_header *header = (struct vertex_header *) (*out);
+
+ header->clipmask = 0;
+ header->edgeflag = (edgeflag[idx/32] & (1 << (idx%32))) != 0;
+ header->pad = 0;
+ header->vertex_id = UNDEFINED_VERTEX_ID;
+
+ (*out)[1] = 0;
+ (*out)[2] = 0;
+ (*out)[3] = 0;
+ (*out)[3] = 1;
+ (*out) += 5;
+}
+
+
/**
* General-purpose fetch from user's vertex arrays, emit to driver's
* vertex buffer.
const unsigned *fetch_elts,
unsigned count )
{
+ const unsigned *edgeflag = fpme->draw->user.edgeflag;
float *out = (float *)out_ptr;
uint i, j;
for (i = 0; i < count; i++) {
unsigned elt = fetch_elts[i];
+ fpme->header( edgeflag, i, &out );
+
for (j = 0; j < fpme->nr_fetch; j++) {
float attrib[4];
const ubyte *from = (fpme->fetch[j].ptr +
/* Emit the vertex header and empty clipspace coord field:
*/
- {
- fpme->fetch[nr].ptr = NULL;
- fpme->fetch[nr].pitch = 0;
- fpme->fetch[nr].fetch = fetch_NULL;
- fpme->fetch[nr].emit = emit_header;
- nr++;
+ if (draw->user.edgeflag) {
+ fpme->header = header_ef;
+ }
+ else {
+ fpme->header = header;
}
}
fpme->nr_fetch = nr;
- fpme->pipeline_vertex_size = (5 + (nr-1) * 4) * sizeof(float);
+ fpme->pipeline_vertex_size = sizeof(struct vertex_header) + nr * 4 * sizeof(float);
}
struct prim_header prim;
// _mesa_printf("tri %d %d %d\n", i0, i1, i2);
- prim.reset_line_stipple = 1;
- prim.edgeflags = ~0;
- prim.pad = 0;
prim.v[0] = (struct vertex_header *)v0;
prim.v[1] = (struct vertex_header *)v1;
prim.v[2] = (struct vertex_header *)v2;
+ prim.reset_line_stipple = 1;
+ prim.edgeflags = ((prim.v[0]->edgeflag) |
+ (prim.v[1]->edgeflag << 1) |
+ (prim.v[2]->edgeflag << 2));
+ prim.pad = 0;
draw->pipeline.first->tri( draw->pipeline.first, &prim );
}
draw->vs.queue[out].elt = i;
draw->vs.queue[out].vertex->clipmask = 0;
- draw->vs.queue[out].vertex->edgeflag = 1; /*XXX use user's edge flag! */
+ draw->vs.queue[out].vertex->edgeflag = draw_get_edgeflag(draw, i);
draw->vs.queue[out].vertex->pad = 0;
draw->vs.queue[out].vertex->vertex_id = UNDEFINED_VERTEX_ID;
void (*destroy)( struct pipe_context * );
+
+ /* Possible interface for setting edgeflags. These aren't really
+ * vertex elements, so don't fit there.
+ */
+ void (*set_edgeflags)( struct pipe_context *,
+ const unsigned *bitfield );
+
+
/**
* VBO drawing (return false on fallbacks (temporary??))
*/