Remove all dependencies on vertex_info, except for draw_vbuf.
Drawing stages now strictly operate on post-transformed vertices and don't
know anything about hw vertices.
Use vertex program output info for two-side/flat/etc stages.
Temporarily disable vbuf module in softpipe driver.
const struct vertex_header *out,
const struct vertex_header *in )
{
- const unsigned nr_attrs = clip->stage.draw->vertex_info.num_attribs;
+ const unsigned nr_attrs = clip->stage.draw->num_vs_outputs;
unsigned j;
/* Vertex header.
static void clip_begin( struct draw_stage *stage )
{
/* should always have position, at least */
- assert(stage->draw->vertex_info.num_attribs >= 1);
+ assert(stage->draw->num_vs_outputs > 0);
stage->next->begin( stage->next );
}
draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * MAX_VERTEX_SIZE);
}
- draw->attrib_front0 = 0;
- draw->attrib_back0 = 0;
- draw->attrib_front1 = 0;
- draw->attrib_back1 = 0;
-
draw->convert_wide_points = TRUE;
draw->convert_wide_lines = TRUE;
}
-
/**
* Allocate space for temporary post-transform vertices, such as for clipping.
*/
const void *buffer);
-
/***********************************************************************
* draw_prim.c
*/
*/
#include "pipe/p_util.h"
+#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
-static void flatshade_begin( struct draw_stage *stage )
+/** subclass of draw_stage */
+struct flat_stage
{
- stage->next->begin( stage->next );
-}
+ struct draw_stage stage;
+
+ uint num_color_attribs;
+ uint color_attribs[4]; /* front/back primary/secondary colors */
+};
+static INLINE struct flat_stage *
+flat_stage(struct draw_stage *stage)
+{
+ return (struct flat_stage *) stage;
+}
+
-static INLINE void copy_attr( unsigned attr,
- struct vertex_header *dst,
- const struct vertex_header *src )
+static void flatshade_begin( struct draw_stage *stage )
{
- if (attr) {
- memcpy( dst->data[attr],
- src->data[attr],
- sizeof(src->data[0]) );
+ struct flat_stage *flat = flat_stage(stage);
+ const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ uint i;
+
+ /* Find which vertex shader outputs are colors, make a list */
+ flat->num_color_attribs = 0;
+ for (i = 0; i < vs->num_outputs; i++) {
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
+ vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ flat->color_attribs[flat->num_color_attribs++] = i;
+ }
}
+
+ stage->next->begin( stage->next );
}
+/** Copy all the color attributes from 'src' vertex to 'dst' vertex */
static INLINE void copy_colors( struct draw_stage *stage,
struct vertex_header *dst,
const struct vertex_header *src )
{
- const uint num_attribs = stage->draw->vertex_info.num_attribs;
- const enum interp_mode *interp = stage->draw->vertex_info.interp_mode;
+ const struct flat_stage *flat = flat_stage(stage);
uint i;
/* Look for constant/flat attribs and duplicate from src to dst vertex */
/* skip attrib[0] which is vert pos */
- for (i = 1; i < num_attribs; i++) {
- if (interp[i] == INTERP_CONSTANT) {
- copy_attr( i, dst, src );
- }
+ for (i = 0; i < flat->num_color_attribs; i++) {
+ const uint attr = flat->color_attribs[i];
+ memcpy(dst->data[attr], src->data[attr], sizeof(src->data[0]));
}
}
*/
struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
{
- struct draw_stage *flatshade = CALLOC_STRUCT(draw_stage);
+ struct flat_stage *flatshade = CALLOC_STRUCT(flat_stage);
- draw_alloc_tmps( flatshade, 2 );
+ draw_alloc_tmps( &flatshade->stage, 2 );
- flatshade->draw = draw;
- flatshade->next = NULL;
- flatshade->begin = flatshade_begin;
- flatshade->point = flatshade_point;
- flatshade->line = flatshade_line;
- flatshade->tri = flatshade_tri;
- flatshade->end = flatshade_end;
- flatshade->reset_stipple_counter = flatshade_reset_stipple_counter;
- flatshade->destroy = flatshade_destroy;
+ flatshade->stage.draw = draw;
+ flatshade->stage.next = NULL;
+ flatshade->stage.begin = flatshade_begin;
+ flatshade->stage.point = flatshade_point;
+ flatshade->stage.line = flatshade_line;
+ flatshade->stage.tri = flatshade_tri;
+ flatshade->stage.end = flatshade_end;
+ flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter;
+ flatshade->stage.destroy = flatshade_destroy;
- return flatshade;
+ return &flatshade->stage;
}
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "draw_vertex.h"
-
#include "x86/rtasm/x86sse.h"
#include "pipe/tgsi/exec/tgsi_exec.h"
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
const struct draw_vertex_shader *vertex_shader;
+ uint num_vs_outputs; /**< convenience, from vertex_shader */
+
/* user-space vertex data, buffers */
struct {
/** vertex element/index buffer (ex: glDrawElements) */
float plane[12][4];
unsigned nr_planes;
- /** Describes the layout of post-transformation vertices */
- struct vertex_info vertex_info;
- /** Two-sided attributes: */
- uint attrib_front0, attrib_back0;
- uint attrib_front1, attrib_back1;
-
boolean convert_wide_points; /**< convert wide points to tris? */
boolean convert_wide_lines; /**< convert side lines to tris? */
unsigned idx )
{
struct vertex_header *tmp = stage->tmp[idx];
- memcpy(tmp, vert, stage->draw->vertex_info.size * sizeof(float) );
+ const uint vsize = sizeof(struct vertex_header)
+ + stage->draw->num_vs_outputs * 4 * sizeof(float);
+ memcpy(tmp, vert, vsize);
tmp->vertex_id = UNDEFINED_VERTEX_ID;
return tmp;
}
/**
* Compute interpolated vertex attributes for 'dst' at position 't'
* between 'v0' and 'v1'.
+ * XXX using linear interpolation for all attribs at this time.
*/
static void
screen_interp( struct draw_context *draw,
const struct vertex_header *v1 )
{
uint attr;
- for (attr = 0; attr < draw->vertex_info.num_attribs; attr++) {
- switch (draw->vertex_info.interp_mode[attr]) {
- case INTERP_NONE:
- case INTERP_CONSTANT:
- COPY_4FV(dst->data[attr], v0->data[attr]);
- break;
- case INTERP_PERSPECTIVE:
- /* Fall-through */
- /* XXX special-case perspective? */
- case INTERP_LINEAR:
- {
- const float *val0 = v0->data[attr];
- const float *val1 = v1->data[attr];
- float *newv = dst->data[attr];
- uint i;
- for (i = 0; i < 4; i++) {
- newv[i] = val0[i] + t * (val1[i] - val0[i]);
- }
- }
- break;
- default:
- abort();
+ for (attr = 0; attr < draw->num_vs_outputs; attr++) {
+ const float *val0 = v0->data[attr];
+ const float *val1 = v1->data[attr];
+ float *newv = dst->data[attr];
+ uint i;
+ for (i = 0; i < 4; i++) {
+ newv[i] = val0[i] + t * (val1[i] - val0[i]);
}
}
}
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
+#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
struct twoside_stage {
struct draw_stage stage;
float sign; /**< +1 or -1 */
+ uint attrib_front0, attrib_back0;
+ uint attrib_front1, attrib_back1;
};
static void twoside_begin( struct draw_stage *stage )
{
struct twoside_stage *twoside = twoside_stage(stage);
+ const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ uint i;
+
+ twoside->attrib_front0 = 0;
+ twoside->attrib_front1 = 0;
+ twoside->attrib_back0 = 0;
+ twoside->attrib_back1 = 0;
+
+ /* Find which vertex shader outputs are front/back colors */
+ for (i = 0; i < vs->num_outputs; i++) {
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
+ if (vs->output_semantic_index[i] == 0)
+ twoside->attrib_front0 = i;
+ else
+ twoside->attrib_front1 = i;
+ }
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ if (vs->output_semantic_index[i] == 0)
+ twoside->attrib_back0 = i;
+ else
+ twoside->attrib_back1 = i;
+ }
+ }
/*
* We'll multiply the primitive's determinant by this sign to determine
unsigned idx )
{
struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx );
- const struct draw_context *draw = twoside->stage.draw;
- if (draw->attrib_front0 && draw->attrib_back0) {
- copy_attrib(draw->attrib_front0, draw->attrib_back0, tmp);
+ if (twoside->attrib_front0 && twoside->attrib_back0) {
+ copy_attrib(twoside->attrib_front0, twoside->attrib_back0, tmp);
}
- if (draw->attrib_front1 && draw->attrib_back1) {
- copy_attrib(draw->attrib_front1, draw->attrib_back1, tmp);
+ if (twoside->attrib_front1 && twoside->attrib_back1) {
+ copy_attrib(twoside->attrib_front1, twoside->attrib_back1, tmp);
}
return tmp;
#include "pipe/draw/draw_vertex.h"
-static INLINE void
-emit_vertex_attr(struct vertex_info *vinfo,
- enum attrib_format format, enum interp_mode interp)
-{
- const uint n = vinfo->num_attribs;
- vinfo->interp_mode[n] = interp;
- vinfo->format[n] = format;
- vinfo->num_attribs++;
-}
-
-
/**
* Compute the size of a vertex, in dwords/floats, to update the
* vinfo->size field.
assert(vinfo->size * 4 <= MAX_VERTEX_SIZE);
}
-
-
-/**
- * Tell the drawing module about the contents of post-transformation vertices.
- * Note that the vertex attribute format info isn't used by 'draw'; all
- * attributes are handled as float[4]. But when the driver emits vertices
- * it'll use that info.
- * We _do_ care about the number of attributes and their interpolation modes.
- */
-void
-draw_set_vertex_info( struct draw_context *draw,
- const struct vertex_info *info)
-{
- assert(info->interp_mode[0] == INTERP_LINEAR); /* should be vert pos */
- assert(info->num_attribs <= PIPE_MAX_SHADER_OUTPUTS);
-
- memcpy(&draw->vertex_info, info, sizeof(*info));
-
- /* Need to know vertex size (in words) for vertex copying elsewhere.
- * Four words per attribute, plus vertex header (uint) and clip
- * position (float[4]).
- */
- draw->vertex_info.size = draw->vertex_info.num_attribs * 4 + 5;
-}
-
-
-/**
- * This function is used to tell the draw module about attributes
- * (like colors) that need to be selected based on front/back face
- * orientation.
- *
- * The logic is:
- * if (polygon is back-facing) {
- * vertex->attrib[front0] = vertex->attrib[back0];
- * vertex->attrib[front1] = vertex->attrib[back1];
- * }
- *
- * \param front0 first attrib to replace if the polygon is back-facing
- * \param back0 first attrib to copy if the polygon is back-facing
- * \param front1 second attrib to replace if the polygon is back-facing
- * \param back1 second attrib to copy if the polygon is back-facing
- *
- * Pass -1 to disable two-sided attributes.
- */
-void
-draw_set_twoside_attributes(struct draw_context *draw,
- uint front0, uint back0,
- uint front1, uint back1)
-{
- /* XXX we could alternately pass an array of front/back attribs if there's
- * ever need for more than two. One could imagine a shader extension
- * that allows arbitrary attributes to be selected based on polygon
- * orientation...
- */
- draw->attrib_front0 = front0;
- draw->attrib_back0 = back0;
- draw->attrib_front1 = front1;
- draw->attrib_back1 = back1;
-}
#define DRAW_VERTEX_H
-struct draw_context;
-
-
/**
* Vertex attribute format
*/
/**
- * Information about post-transformed vertex layout.
+ * Information about hardware/rasterization vertex layout.
*/
struct vertex_info
{
uint hwfmt[4]; /**< hardware format info for this format */
enum interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS];
enum attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */
- uint src_index[PIPE_MAX_SHADER_OUTPUTS];
+ uint src_index[PIPE_MAX_SHADER_OUTPUTS]; /**< map to post-xform attribs */
uint size; /**< total vertex size in dwords */
};
}
-extern void draw_set_vertex_info( struct draw_context *draw,
- const struct vertex_info *info);
-
-extern void draw_set_twoside_attributes(struct draw_context *draw,
- uint front0, uint back0,
- uint front1, uint back1);
-
extern void draw_compute_vertex_size(struct vertex_info *vinfo);
#include "pipe/p_util.h"
#include "draw_private.h"
#include "draw_context.h"
-#include "draw_vertex.h"
void draw_vertex_cache_invalidate( struct draw_context *draw )
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
#include "draw_context.h"
-#include "draw_vertex.h"
#define DRAW_DBG 0
#endif
#include "draw_private.h"
#include "draw_context.h"
-#include "draw_vertex.h"
#include "x86/rtasm/x86sse.h"
#include "pipe/llvm/gallivm.h"
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
*/
- for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
+ for (slot = 1; slot < draw->num_vs_outputs; slot++) {
vOut[j]->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
draw_flush(draw);
draw->vertex_shader = dvs;
+ draw->num_vs_outputs = dvs->state->num_outputs;
+
/* specify the fragment program to interpret/execute */
tgsi_exec_machine_init(&draw->machine,
draw->vertex_shader->state->tokens,
#include "pipe/p_util.h"
#include "draw_private.h"
#include "draw_context.h"
-#include "draw_vertex.h"
#ifdef MESA_LLVM
gallivm_prog_exec(prog, inputs, outputs, consts,
draw->vs.queue_nr,
draw->vertex_shader->state->num_inputs,
- draw->vertex_info.num_attribs - 2);
+ draw->vertex_shader->state->num_outputs);
/* store machine results */
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
*/
- for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
+ for (slot = 1; slot < draw->vs_num_outputs; slot++) {
vOut->data[slot][0] = dests[slot][0];
vOut->data[slot][1] = dests[slot][1];
vOut->data[slot][2] = dests[slot][2];
/* If the attributes have changed, tell the draw module about the new
* vertex layout. We'll also update the hardware vertex format info.
*/
- draw_set_vertex_info( i915->draw, &vinfo);
+ /*draw_set_vertex_info( i915->draw, &vinfo);*/
- draw_set_twoside_attributes(i915->draw,
- front0, back0, front1, back1);
+ /*draw_set_twoside_attributes(i915->draw,
+ front0, back0, front1, back1);*/
/* Need to set this flag so that the LIS2/4 registers get set.
* It also means the i915_update_immediate() function must be called
assert(softpipe->draw);
softpipe->setup = sp_draw_render_stage(softpipe);
- if (GETENV( "SP_VBUF" ) != NULL) {
+ if (0 && GETENV( "SP_VBUF" ) != NULL) {
softpipe->vbuf = sp_draw_vbuf_stage(softpipe->draw,
&softpipe->pipe,
sp_vbuf_render);
struct softpipe_winsys;
+struct softpipe_vbuf_render;
struct draw_context;
struct draw_stage;
struct softpipe_tile_cache;
struct draw_context *draw;
struct draw_stage *setup;
struct draw_stage *vbuf;
+ struct softpipe_vbuf_render *vbuf_render;
uint current_cbuf; /**< current color buffer being written to */
struct softpipe_context *softpipe = softpipe_context( pipe );
struct setup_stage *setup = setup_stage( softpipe->setup );
struct prim_header prim;
- unsigned vertex_size = setup->stage.draw->vertex_info.size * sizeof(float);
+ unsigned vertex_size = softpipe->vertex_info.size * sizeof(float);
unsigned i, j;
prim.det = 0;
static void vbuf_begin( struct draw_stage *stage )
{
struct vbuf_stage *vbuf = vbuf_stage(stage);
+ struct softpipe_context *softpipe = softpipe_context(vbuf->pipe);
- vbuf->vertex_size = vbuf->draw_context->vertex_info.size * sizeof(float);
+ //vbuf->vertex_size = vbuf->draw_context->vertex_info.size * sizeof(float);
+
+ vbuf->vertex_size = softpipe->vertex_info.size * sizeof(float);
}
}
}
+ draw_compute_vertex_size(vinfo);
+
softpipe->nr_frag_attrs = fs->num_inputs;
/* We want these after all other attribs since they won't get passed
if (1/*vinfo->attr_mask != softpipe->attr_mask*/) {
/*softpipe->attr_mask = vinfo->attr_mask;*/
- draw_set_vertex_info( softpipe->draw, vinfo);
+ /*draw_set_vertex_info( softpipe->draw, vinfo);*/
- draw_set_twoside_attributes(softpipe->draw,
+ /*draw_set_twoside_attributes(softpipe->draw,
front0, back0, front1, back1);
+ */
}
}
static void
set_feedback_vertex_format(GLcontext *ctx)
{
+#if 0
struct st_context *st = ctx->st;
struct vertex_info vinfo;
GLuint i;
+ memset(&vinfo, 0, sizeof(vinfo));
+
if (ctx->RenderMode == GL_SELECT) {
assert(ctx->RenderMode == GL_SELECT);
vinfo.num_attribs = 1;
}
draw_set_vertex_info(st->draw, &vinfo);
+#endif
}