vinfo->slot_to_attrib[n] = vfAttr;
if (n >= 2) {
/* the first two slots are the vertex header & clippos */
+ assert(vfAttr < Elements(vinfo->attrib_to_slot));
vinfo->attrib_to_slot[vfAttr] = n - 2;
}
/*printf("Vertex slot %d = vfattrib %d\n", n, vfAttr);*/
struct vertex_info *vinfo = &draw->vertex_info;
unsigned i;
- assert(slot_to_vf_attr[0] == VF_ATTRIB_POS);
+ assert(slot_to_vf_attr[0] == TGSI_ATTRIB_POS);
memset(vinfo, 0, sizeof(*vinfo));
/*
* First three attribs are always the same: header, clip pos, winpos
*/
- emit_vertex_attr(vinfo, VF_ATTRIB_VERTEX_HEADER, FORMAT_1F);
- emit_vertex_attr(vinfo, VF_ATTRIB_CLIP_POS, FORMAT_4F);
- emit_vertex_attr(vinfo, VF_ATTRIB_POS, FORMAT_4F_VIEWPORT);
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_VERTEX_HEADER, FORMAT_1F);
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_CLIP_POS, FORMAT_4F);
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_4F_VIEWPORT);
/*
* Remaining attribs (color, texcoords, etc)
/* sanity checks. If these fail, review the clip/interp code! */
assert(stage->draw->vertex_info.num_attribs >= 3);
- assert(stage->draw->vertex_info.slot_to_attrib[0] == VF_ATTRIB_VERTEX_HEADER);
- assert(stage->draw->vertex_info.slot_to_attrib[1] == VF_ATTRIB_CLIP_POS);
+ assert(stage->draw->vertex_info.slot_to_attrib[0] == TGSI_ATTRIB_VERTEX_HEADER);
+ assert(stage->draw->vertex_info.slot_to_attrib[1] == TGSI_ATTRIB_CLIP_POS);
/* Hacky bitmask to use when we hit CLIP_USER_BIT:
*/
const struct flatshade_stage *flatshade = flatshade_stage(stage);
const unsigned *lookup = flatshade->lookup;
- copy_attr( lookup[VF_ATTRIB_COLOR0], dst, src );
- copy_attr( lookup[VF_ATTRIB_COLOR1], dst, src );
- copy_attr( lookup[VF_ATTRIB_BFC0], dst, src );
- copy_attr( lookup[VF_ATTRIB_BFC1], dst, src );
+ copy_attr( lookup[TGSI_ATTRIB_COLOR0], dst, src );
+ copy_attr( lookup[TGSI_ATTRIB_COLOR1], dst, src );
+ copy_attr( lookup[TGSI_ATTRIB_BFC0], dst, src );
+ copy_attr( lookup[TGSI_ATTRIB_BFC1], dst, src );
}
float data[][4]; /* Note variable size */
};
-#define MAX_VERTEX_SIZE ((2 + FRAG_ATTRIB_MAX) * 4 * sizeof(float))
+/* XXX This is too large */
+#define MAX_VERTEX_SIZE ((2 + TGSI_ATTRIB_MAX) * 4 * sizeof(float))
{
struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx );
- copy_color( twoside->lookup[VF_ATTRIB_COLOR0],
- twoside->lookup[VF_ATTRIB_BFC0],
+ copy_color( twoside->lookup[TGSI_ATTRIB_COLOR0],
+ twoside->lookup[TGSI_ATTRIB_BFC0],
tmp );
- copy_color( twoside->lookup[VF_ATTRIB_COLOR1],
- twoside->lookup[VF_ATTRIB_BFC1],
+ copy_color( twoside->lookup[TGSI_ATTRIB_COLOR1],
+ twoside->lookup[TGSI_ATTRIB_BFC1],
tmp );
return tmp;
#ifndef DRAW_VERTEX_H
#define DRAW_VERTEX_H
-
-/***
- *** XXX There's a lot of legacy tokens here that'll eventually go away.
- *** (at least we don't include vf/vf.h anymore)
- ***/
-
-
-enum {
- VF_ATTRIB_POS = 0,
- VF_ATTRIB_WEIGHT = 1,
- VF_ATTRIB_NORMAL = 2,
- VF_ATTRIB_COLOR0 = 3,
- VF_ATTRIB_COLOR1 = 4,
- VF_ATTRIB_FOG = 5,
- VF_ATTRIB_COLOR_INDEX = 6,
- VF_ATTRIB_EDGEFLAG = 7,
- VF_ATTRIB_TEX0 = 8,
- VF_ATTRIB_TEX1 = 9,
- VF_ATTRIB_TEX2 = 10,
- VF_ATTRIB_TEX3 = 11,
- VF_ATTRIB_TEX4 = 12,
- VF_ATTRIB_TEX5 = 13,
- VF_ATTRIB_TEX6 = 14,
- VF_ATTRIB_TEX7 = 15,
- VF_ATTRIB_VAR0 = 16,
- VF_ATTRIB_VAR1 = 17,
- VF_ATTRIB_VAR2 = 18,
- VF_ATTRIB_VAR3 = 19,
- VF_ATTRIB_VAR4 = 20,
- VF_ATTRIB_VAR5 = 21,
- VF_ATTRIB_VAR6 = 22,
- VF_ATTRIB_VAR7 = 23,
- VF_ATTRIB_POINTSIZE = 24,
- VF_ATTRIB_BFC0 = 25,
- VF_ATTRIB_BFC1 = 26,
- VF_ATTRIB_CLIP_POS = 27,
- VF_ATTRIB_VERTEX_HEADER = 28,
- VF_ATTRIB_MAX = 29
-};
-
-#define MAX_VARYING 8
-enum
-{
- FRAG_ATTRIB_WPOS = 0,
- FRAG_ATTRIB_COL0 = 1,
- FRAG_ATTRIB_COL1 = 2,
- FRAG_ATTRIB_FOGC = 3,
- FRAG_ATTRIB_TEX0 = 4,
- FRAG_ATTRIB_TEX1 = 5,
- FRAG_ATTRIB_TEX2 = 6,
- FRAG_ATTRIB_TEX3 = 7,
- FRAG_ATTRIB_TEX4 = 8,
- FRAG_ATTRIB_TEX5 = 9,
- FRAG_ATTRIB_TEX6 = 10,
- FRAG_ATTRIB_TEX7 = 11,
- FRAG_ATTRIB_VAR0 = 12, /**< shader varying */
- FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
-};
-
-#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
-#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
-#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
-#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
-#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
-
-
-
-#define MAX_DRAW_BUFFERS 4
-
-enum
-{
- FRAG_RESULT_COLR = 0,
- FRAG_RESULT_COLH = 1,
- FRAG_RESULT_DEPR = 2,
- FRAG_RESULT_DATA0 = 3,
- FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
-};
-
+#include "pipe/tgsi/core/tgsi_attribs.h"
#define MAX_VERT_ATTRIBS 12 /* OK? */
struct vertex_info
{
uint num_attribs;
- uint hwfmt[2]; /**< hardware format info for this format */
+ uint hwfmt[4]; /**< hardware format info for this format */
uint attr_mask; /**< mask of VF_ATTR_ bits */
uint slot_to_attrib[MAX_VERT_ATTRIBS];
- uint attrib_to_slot[VF_ATTRIB_MAX];
+ uint attrib_to_slot[TGSI_ATTRIB_MAX];
uint interp_mode[MAX_VERT_ATTRIBS];
uint format[MAX_VERT_ATTRIBS]; /**< FORMAT_x */
uint size; /**< total vertex size in dwords */
return UREG(REG_TYPE_CONST, fp->param[i].reg);
}
-#if 0
- if (fp->nr_constants == I915_MAX_CONSTANT ||
- fp->nr_params == I915_MAX_CONSTANT) {
-#else
if (p->constants->nr_constants == I915_MAX_CONSTANT ||
fp->nr_params == I915_MAX_CONSTANT) {
-#endif
i915_program_error(p, "i915_emit_param4fv: out of constants\n");
return 0;
}
{
-#if 0
- int reg = fp->nr_constants++;
-#else
int reg = p->constants->nr_constants++;
-#endif
int i = fp->nr_params++;
assert (p->constant_flags[reg] == 0);
index = p->vertex_info->slot_to_attrib[index];
switch (index) {
- case VF_ATTRIB_POS:
+ case TGSI_ATTRIB_POS:
assert(p->wpos_tex != -1);
src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL);
break;
- case VF_ATTRIB_COLOR0:
+ case TGSI_ATTRIB_COLOR0:
src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL);
break;
- case VF_ATTRIB_COLOR1:
+ case TGSI_ATTRIB_COLOR1:
src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ);
src = swizzle(src, X, Y, Z, ONE);
break;
- case VF_ATTRIB_FOG:
+ case TGSI_ATTRIB_FOG:
src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W);
src = swizzle(src, W, W, W, W);
break;
- case VF_ATTRIB_TEX0:
- case VF_ATTRIB_TEX1:
- case VF_ATTRIB_TEX2:
- case VF_ATTRIB_TEX3:
- case VF_ATTRIB_TEX4:
- case VF_ATTRIB_TEX5:
- case VF_ATTRIB_TEX6:
- case VF_ATTRIB_TEX7:
+ case TGSI_ATTRIB_TEX0:
+ case TGSI_ATTRIB_TEX1:
+ case TGSI_ATTRIB_TEX2:
+ case TGSI_ATTRIB_TEX3:
+ case TGSI_ATTRIB_TEX4:
+ case TGSI_ATTRIB_TEX5:
+ case TGSI_ATTRIB_TEX6:
+ case TGSI_ATTRIB_TEX7:
src = i915_emit_decl(p, REG_TYPE_T,
- T_TEX0 + (index - VF_ATTRIB_TEX0),
+ T_TEX0 + (index - TGSI_ATTRIB_TEX0),
D0_CHANNEL_ALL);
break;
default:
switch (dest->DstRegister.File) {
case TGSI_FILE_OUTPUT:
switch (dest->DstRegister.Index) {
- case 1: /*COLOR*/ /*FRAG_RESULT_COLR:*/
+ case TGSI_ATTRIB_COLOR0:
return UREG(REG_TYPE_OC, 0);
- case 0: /*DEPTH*/ /*FRAG_RESULT_DEPR:*/
+ case TGSI_ATTRIB_POS:
return UREG(REG_TYPE_OD, 0);
default:
i915_program_error(p, "Bad inst->DstReg.Index");
static void
i915_find_wpos_space(struct i915_fp_compile *p)
{
- const uint inputs = p->shader->inputs_read | FRAG_BIT_WPOS; /*XXX hack*/
+ const uint inputs
+ = p->shader->inputs_read | (1 << TGSI_ATTRIB_POS); /*XXX hack*/
uint i;
p->wpos_tex = -1;
- if (inputs & FRAG_BIT_WPOS) {
+ if (inputs & (1 << TGSI_ATTRIB_POS)) {
for (i = 0; i < I915_TEX_UNITS; i++) {
- if ((inputs & (FRAG_BIT_TEX0 << i)) == 0) {
+ if ((inputs & (1 << (TGSI_ATTRIB_TEX0 + i))) == 0) {
p->wpos_tex = i;
return;
}
static void
i915_fixup_depth_write(struct i915_fp_compile *p)
{
- if (p->shader->outputs_written & (1<<FRAG_RESULT_DEPR)) {
+ if (p->shader->outputs_written & (1 << TGSI_ATTRIB_POS)) {
uint depth = UREG(REG_TYPE_OD, 0);
i915_emit_arith(p,
#include "i915_fpc.h"
-
-static const unsigned frag_to_vf[FRAG_ATTRIB_MAX] =
-{
- VF_ATTRIB_POS,
- VF_ATTRIB_COLOR0,
- VF_ATTRIB_COLOR1,
- VF_ATTRIB_FOG,
- VF_ATTRIB_TEX0,
- VF_ATTRIB_TEX1,
- VF_ATTRIB_TEX2,
- VF_ATTRIB_TEX3,
- VF_ATTRIB_TEX4,
- VF_ATTRIB_TEX5,
- VF_ATTRIB_TEX6,
- VF_ATTRIB_TEX7,
- VF_ATTRIB_VAR0,
- VF_ATTRIB_VAR1,
- VF_ATTRIB_VAR2,
- VF_ATTRIB_VAR3,
- VF_ATTRIB_VAR4,
- VF_ATTRIB_VAR5,
- VF_ATTRIB_VAR6,
- VF_ATTRIB_VAR7,
-};
-
-
static INLINE void
emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format)
{
{
const unsigned inputsRead = i915->fs.inputs_read;
struct vertex_info *vinfo = &i915->current.vertex_info;
- uint i;
memset(vinfo, 0, sizeof(*vinfo));
/* TODO - Figure out if we need to do perspective divide, etc.
*/
- emit_vertex_attr(vinfo, VF_ATTRIB_POS, FORMAT_3F);
+
+ /* pos */
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_3F);
vinfo->hwfmt[0] |= S4_VFMT_XYZ;
-
- /* Pull in the rest of the attributes. They are all in float4
- * format. Future optimizations could be to keep some attributes
- * as fixed point or ubyte format.
- */
- for (i = 1; i < FRAG_ATTRIB_TEX0; i++) {
- if (inputsRead & (1 << i)) {
- assert(i < Elements(frag_to_vf));
- if (i915->setup.flatshade
- && (i == FRAG_ATTRIB_COL0 || i == FRAG_ATTRIB_COL1)) {
- emit_vertex_attr(vinfo, frag_to_vf[i], FORMAT_4UB);
- }
- else {
- emit_vertex_attr(vinfo, frag_to_vf[i], FORMAT_4UB);
- }
- vinfo->hwfmt[0] |= S4_VFMT_COLOR;
- }
+
+ /* color0 */
+ if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) {
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, FORMAT_4UB);
+ vinfo->hwfmt[0] |= S4_VFMT_COLOR;
}
- for (i = FRAG_ATTRIB_TEX0; i <= FRAG_ATTRIB_TEX7/*MAX*/; i++) {
- uint hwtc;
- if (inputsRead & (1 << i)) {
- hwtc = TEXCOORDFMT_4D;
- assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0]));
- emit_vertex_attr(vinfo, frag_to_vf[i], FORMAT_4F);
- }
- else {
- hwtc = TEXCOORDFMT_NOT_PRESENT;
+ /* color 1 */
+ if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) {
+ assert(0); /* untested */
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, FORMAT_4UB);
+ vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG;
+ }
+
+ /* XXX fog? */
+
+ /* texcoords */
+ {
+ uint i;
+ for (i = TGSI_ATTRIB_TEX0; i <= TGSI_ATTRIB_TEX7; i++) {
+ uint hwtc;
+ if (inputsRead & (1 << i)) {
+ emit_vertex_attr(vinfo, i, FORMAT_4F);
+ hwtc = TEXCOORDFMT_4D;
+ }
+ else {
+ hwtc = TEXCOORDFMT_NOT_PRESENT;
+ }
+ vinfo->hwfmt[1] |= hwtc << ((i - TGSI_ATTRIB_TEX0) * 4);
}
- vinfo->hwfmt[1] |= hwtc << ((i - FRAG_ATTRIB_TEX0) * 4);
}
/* Additional attributes required for setup: Just twosided
* the vertex header.
*/
if (i915->setup.light_twoside) {
- if (inputsRead & FRAG_BIT_COL0) {
- emit_vertex_attr(vinfo, VF_ATTRIB_BFC0, FORMAT_OMIT);
- }
-
- if (inputsRead & FRAG_BIT_COL1) {
- emit_vertex_attr(vinfo, VF_ATTRIB_BFC1, FORMAT_OMIT);
+ if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) {
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT);
+ }
+ if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) {
+ emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC1, FORMAT_OMIT);
}
}
struct pipe_shader_state {
- unsigned inputs_read; /**< FRAG/VERT_ATTRIB_x */
- unsigned outputs_written; /**< FRAG/VERT_RESULT_x */
+ unsigned inputs_read; /**< TGSI_ATTRIB_ bits */
+ unsigned outputs_written; /**< TGSI_ATTRIB_ bits */
const struct tgsi_token *tokens;
};
#include "pipe/draw/draw_private.h"
#include "pipe/p_util.h"
-
-/** XXX remove */
-#define FRAG_ATTRIB_WPOS 0
-#define FRAG_ATTRIB_MAX 13
+#include "pipe/draw/draw_vertex.h"
/**
float oneoverarea;
- struct tgsi_interp_coef coef[FRAG_ATTRIB_MAX];
+ struct tgsi_interp_coef coef[TGSI_ATTRIB_MAX];
struct quad_header quad;
struct {
unsigned slot,
unsigned i )
{
- assert(slot < FRAG_ATTRIB_MAX);
+ assert(slot < TGSI_ATTRIB_MAX);
assert(i <= 3);
setup->coef[slot].dadx[i] = 0;
float a = setup->ebot.dy * majda - botda * setup->emaj.dy;
float b = setup->emaj.dx * botda - majda * setup->ebot.dx;
- assert(slot < FRAG_ATTRIB_MAX);
+ assert(slot < TGSI_ATTRIB_MAX);
assert(i <= 3);
setup->coef[slot].dadx[i] = a * setup->oneoverarea;
float a = setup->ebot.dy * majda - botda * setup->emaj.dy;
float b = setup->emaj.dx * botda - majda * setup->ebot.dx;
- assert(slot < FRAG_ATTRIB_MAX);
+ assert(slot < TGSI_ATTRIB_MAX);
assert(i <= 3);
setup->coef[slot].dadx[i] = a * setup->oneoverarea;
const float halfSize = 0.5f * setup->softpipe->setup.point_size;
const boolean round = setup->softpipe->setup.point_smooth;
const struct vertex_header *v0 = prim->v[0];
- const float x = v0->data[FRAG_ATTRIB_WPOS][0];
- const float y = v0->data[FRAG_ATTRIB_WPOS][1];
+ const float x = v0->data[TGSI_ATTRIB_POS][0];
+ const float y = v0->data[TGSI_ATTRIB_POS][1];
unsigned slot, j;
/* For points, all interpolants are constant-valued.
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
+#include "pipe/tgsi/core/tgsi_attribs.h"
#include "sp_context.h"
#include "sp_headers.h"
/* store result color */
memcpy(
quad->outputs.color,
- &machine.Outputs[1].xyzw[0].f[0],
+ &machine.Outputs[TGSI_ATTRIB_COLOR0].xyzw[0].f[0],
sizeof( quad->outputs.color ) );
#if 0
#include "sp_context.h"
#include "sp_state.h"
+#include "pipe/tgsi/core/tgsi_attribs.h"
-#define EMIT_ATTR( VF_ATTR, FRAG_ATTR, INTERP ) \
+
+#define EMIT_ATTR( ATTR, FRAG_ATTR, INTERP ) \
do { \
- slot_to_vf_attr[softpipe->nr_attrs] = VF_ATTR; \
- softpipe->vf_attr_to_slot[VF_ATTR] = softpipe->nr_attrs; \
+ slot_to_vf_attr[softpipe->nr_attrs] = ATTR; \
+ softpipe->vf_attr_to_slot[ATTR] = softpipe->nr_attrs; \
softpipe->fp_attr_to_slot[FRAG_ATTR] = softpipe->nr_attrs; \
softpipe->interp[softpipe->nr_attrs] = INTERP; \
softpipe->nr_attrs++; \
- attr_mask |= (1 << (VF_ATTR)); \
+ attr_mask |= (1 << (ATTR)); \
} while (0)
static const unsigned frag_to_vf[PIPE_ATTRIB_MAX] =
{
- VF_ATTRIB_POS,
- VF_ATTRIB_COLOR0,
- VF_ATTRIB_COLOR1,
- VF_ATTRIB_FOG,
- VF_ATTRIB_TEX0,
- VF_ATTRIB_TEX1,
- VF_ATTRIB_TEX2,
- VF_ATTRIB_TEX3,
- VF_ATTRIB_TEX4,
- VF_ATTRIB_TEX5,
- VF_ATTRIB_TEX6,
- VF_ATTRIB_TEX7,
- VF_ATTRIB_VAR0,
- VF_ATTRIB_VAR1,
- VF_ATTRIB_VAR2,
- VF_ATTRIB_VAR3,
- VF_ATTRIB_VAR4,
- VF_ATTRIB_VAR5,
- VF_ATTRIB_VAR6,
- VF_ATTRIB_VAR7,
+ TGSI_ATTRIB_POS,
+ TGSI_ATTRIB_COLOR0,
+ TGSI_ATTRIB_COLOR1,
+ TGSI_ATTRIB_FOG,
+ TGSI_ATTRIB_TEX0,
+ TGSI_ATTRIB_TEX1,
+ TGSI_ATTRIB_TEX2,
+ TGSI_ATTRIB_TEX3,
+ TGSI_ATTRIB_TEX4,
+ TGSI_ATTRIB_TEX5,
+ TGSI_ATTRIB_TEX6,
+ TGSI_ATTRIB_TEX7,
+ TGSI_ATTRIB_VAR0,
+ TGSI_ATTRIB_VAR1,
+ TGSI_ATTRIB_VAR2,
+ TGSI_ATTRIB_VAR3,
+ TGSI_ATTRIB_VAR4,
+ TGSI_ATTRIB_VAR5,
+ TGSI_ATTRIB_VAR6,
+ TGSI_ATTRIB_VAR7,
};
static void calculate_vertex_layout( struct softpipe_context *softpipe )
{
const unsigned inputsRead = softpipe->fs.inputs_read;
- unsigned slot_to_vf_attr[VF_ATTRIB_MAX];
+ unsigned slot_to_vf_attr[TGSI_ATTRIB_MAX];
unsigned attr_mask = 0x0;
unsigned i;
* fragment position (XYZW).
*/
if (softpipe->depth_test.enabled ||
- (inputsRead & (1 << FRAG_ATTRIB_WPOS)))
+ (inputsRead & (1 << TGSI_ATTRIB_POS)))
softpipe->need_z = TRUE;
else
softpipe->need_z = FALSE;
/* Need W if we do any perspective-corrected interpolation or the
* fragment program uses the fragment position.
*/
- if (inputsRead & (1 << FRAG_ATTRIB_WPOS))
+ if (inputsRead & (1 << TGSI_ATTRIB_POS))
softpipe->need_w = TRUE;
else
softpipe->need_w = FALSE;
/* TODO - Figure out if we need to do perspective divide, etc.
*/
- EMIT_ATTR(VF_ATTRIB_POS, FRAG_ATTRIB_WPOS, INTERP_LINEAR);
+ EMIT_ATTR(TGSI_ATTRIB_POS, TGSI_ATTRIB_POS, INTERP_LINEAR);
/* Pull in the rest of the attributes. They are all in float4
* format. Future optimizations could be to keep some attributes
* as fixed point or ubyte format.
*/
- for (i = 1; i < FRAG_ATTRIB_TEX0; i++) {
+ for (i = 1; i < TGSI_ATTRIB_TEX0; i++) {
if (inputsRead & (1 << i)) {
assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0]));
if (softpipe->setup.flatshade
- && (i == FRAG_ATTRIB_COL0 || i == FRAG_ATTRIB_COL1))
+ && (i == TGSI_ATTRIB_COLOR0 || i == TGSI_ATTRIB_COLOR1))
EMIT_ATTR(frag_to_vf[i], i, INTERP_CONSTANT);
else
EMIT_ATTR(frag_to_vf[i], i, INTERP_LINEAR);
}
}
- for (i = FRAG_ATTRIB_TEX0; i < FRAG_ATTRIB_MAX; i++) {
+ for (i = TGSI_ATTRIB_TEX0; i < TGSI_ATTRIB_MAX; i++) {
if (inputsRead & (1 << i)) {
assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0]));
EMIT_ATTR(frag_to_vf[i], i, INTERP_PERSPECTIVE);
* the vertex header.
*/
if (softpipe->setup.light_twoside) {
- if (inputsRead & FRAG_BIT_COL0) {
- EMIT_ATTR(VF_ATTRIB_BFC0, FRAG_ATTRIB_MAX, 0); /* XXX: mark as discarded after setup */
+ if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) {
+ EMIT_ATTR(TGSI_ATTRIB_BFC0, TGSI_ATTRIB_MAX, 0); /* XXX: mark as discarded after setup */
}
- if (inputsRead & FRAG_BIT_COL1) {
- EMIT_ATTR(VF_ATTRIB_BFC1, FRAG_ATTRIB_MAX, 0); /* XXX: discard after setup */
+ if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) {
+ EMIT_ATTR(TGSI_ATTRIB_BFC1, TGSI_ATTRIB_MAX, 0); /* XXX: discard after setup */
}
}
};
-/**
- * The specific values here are not important.
- */
-enum {
- TGSI_ATTRIB_POS = 0,
- TGSI_ATTRIB_WEIGHT = 1,
- TGSI_ATTRIB_NORMAL = 2,
- TGSI_ATTRIB_COLOR0 = 3,
- TGSI_ATTRIB_COLOR1 = 4,
- TGSI_ATTRIB_FOG = 5,
- TGSI_ATTRIB_COLOR_INDEX = 6, /* XXX omit? */
- TGSI_ATTRIB_EDGEFLAG = 7,
- TGSI_ATTRIB_TEX0 = 8,
- TGSI_ATTRIB_TEX1 = 9,
- TGSI_ATTRIB_TEX2 = 10,
- TGSI_ATTRIB_TEX3 = 11,
- TGSI_ATTRIB_TEX4 = 12,
- TGSI_ATTRIB_TEX5 = 13,
- TGSI_ATTRIB_TEX6 = 14,
- TGSI_ATTRIB_TEX7 = 15,
- TGSI_ATTRIB_VAR0 = 16,
- TGSI_ATTRIB_VAR1 = 17,
- TGSI_ATTRIB_VAR2 = 18,
- TGSI_ATTRIB_VAR3 = 19,
- TGSI_ATTRIB_VAR4 = 20,
- TGSI_ATTRIB_VAR5 = 21,
- TGSI_ATTRIB_VAR6 = 22,
- TGSI_ATTRIB_VAR7 = 23,
- TGSI_ATTRIB_POINTSIZE = 24,
- TGSI_ATTRIB_BFC0 = 25,
- TGSI_ATTRIB_BFC1 = 26,
- TGSI_ATTRIB_CLIP_POS = 27,
- TGSI_ATTRIB_VERTEX_HEADER = 28,
- TGSI_ATTRIB_MAX = 29
-};
-
-
-#define TGSI_MAX_TEXTURE 8
-#define TGSI_MAX_VARYING 8
-
-
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#include "tgsi_platform.h"\r
#include "tgsi_mesa.h"\r
+#include "pipe/tgsi/core/tgsi_attribs.h"\r
+#include "pipe/tgsi/mesa/mesa_to_tgsi.h"\r
\r
#define TGSI_DEBUG 1\r
\r
/**\r
* Convert a VERT_ATTRIB_x to a TGSI_ATTRIB_y\r
*/\r
-static GLuint\r
-translate_vertex_input(GLuint attrib)\r
+uint\r
+tgsi_mesa_translate_vertex_input(GLuint attrib)\r
{\r
/* XXX these could be implemented with array lookups too.... */\r
switch (attrib) {\r
/**\r
* Convert VERT_RESULT_x to TGSI_ATTRIB_y\r
*/\r
-static GLuint\r
-translate_vertex_ouput(GLuint attrib)\r
+uint\r
+tgsi_mesa_translate_vertex_output(GLuint attrib)\r
{\r
switch (attrib) {\r
case VERT_RESULT_HPOS:\r
/**\r
* Convert a FRAG_ATTRIB_x to a TGSI_ATTRIB_y\r
*/\r
-static GLuint\r
-translate_fragment_input(GLuint attrib)\r
+uint\r
+tgsi_mesa_translate_fragment_input(GLuint attrib)\r
{\r
switch (attrib) {\r
case FRAG_ATTRIB_WPOS:\r
/**\r
* Convert FRAG_RESULT_x to TGSI_ATTRIB_y\r
*/\r
-static GLuint\r
-translate_fragment_output(GLuint attrib)\r
+uint\r
+tgsi_mesa_translate_fragment_output(GLuint attrib)\r
{\r
switch (attrib) {\r
case FRAG_RESULT_DEPR:\r
}\r
\r
\r
+uint\r
+tgsi_mesa_translate_vertex_input_mask(GLbitfield mask)\r
+{\r
+ uint tgsiMask = 0x0;\r
+ uint i;\r
+ for (i = 0; i < VERT_ATTRIB_MAX && mask; i++) {\r
+ if (mask & (1 << i)) {\r
+ tgsiMask |= 1 << tgsi_mesa_translate_vertex_input(i);\r
+ }\r
+ mask &= ~(1 << i);\r
+ }\r
+ return tgsiMask;\r
+}\r
+\r
+\r
+uint\r
+tgsi_mesa_translate_vertex_output_mask(GLbitfield mask)\r
+{\r
+ uint tgsiMask = 0x0;\r
+ uint i;\r
+ for (i = 0; i < VERT_RESULT_MAX && mask; i++) {\r
+ if (mask & (1 << i)) {\r
+ tgsiMask |= 1 << tgsi_mesa_translate_vertex_output(i);\r
+ }\r
+ mask &= ~(1 << i);\r
+ }\r
+ return tgsiMask;\r
+}\r
+\r
+uint\r
+tgsi_mesa_translate_fragment_input_mask(GLbitfield mask)\r
+{\r
+ uint tgsiMask = 0x0;\r
+ uint i;\r
+ for (i = 0; i < FRAG_ATTRIB_MAX && mask; i++) {\r
+ if (mask & (1 << i)) {\r
+ tgsiMask |= 1 << tgsi_mesa_translate_fragment_input(i);\r
+ }\r
+ mask &= ~(1 << i);\r
+ }\r
+ return tgsiMask;\r
+}\r
+\r
+\r
+uint\r
+tgsi_mesa_translate_fragment_output_mask(GLbitfield mask)\r
+{\r
+ uint tgsiMask = 0x0;\r
+ uint i;\r
+ for (i = 0; i < FRAG_RESULT_MAX && mask; i++) {\r
+ if (mask & (1 << i)) {\r
+ tgsiMask |= 1 << tgsi_mesa_translate_fragment_output(i);\r
+ }\r
+ mask &= ~(1 << i);\r
+ }\r
+ return tgsiMask;\r
+}\r
+\r
+\r
+\r
+\r
+\r
\r
/*\r
* Map mesa register file to TGSI register file.\r
* color results -> index 1, 2, ...\r
*/\r
if( index == FRAG_RESULT_DEPR ) {\r
- mapped_index = 0;\r
+ mapped_index = TGSI_ATTRIB_POS;\r
}\r
else {\r
assert( index == FRAG_RESULT_COLR );\r
- mapped_index = index + 1;\r
+ mapped_index = TGSI_ATTRIB_COLOR0;\r
}\r
}\r
else {\r
struct tgsi_token *tokens,\r
GLuint maxTokens );\r
\r
+uint\r
+tgsi_mesa_translate_vertex_input(GLuint attrib);\r
+\r
+uint\r
+tgsi_mesa_translate_vertex_output(GLuint attrib);\r
+\r
+uint\r
+tgsi_mesa_translate_fragment_input(GLuint attrib);\r
+\r
+uint\r
+tgsi_mesa_translate_fragment_output(GLuint attrib);\r
+\r
+uint\r
+tgsi_mesa_translate_vertex_input_mask(GLbitfield mask);\r
+\r
+uint\r
+tgsi_mesa_translate_vertex_output_mask(GLbitfield mask);\r
+\r
+uint\r
+tgsi_mesa_translate_fragment_input_mask(GLbitfield mask);\r
+\r
+uint\r
+tgsi_mesa_translate_fragment_output_mask(GLbitfield mask);\r
+\r
+\r
#if defined __cplusplus\r
} // extern "C"\r
#endif // defined __cplusplus\r
/* update pipe state */
memset( &fs, 0, sizeof(fs) );
- fs.inputs_read = fp->Base.Base.InputsRead;
- fs.outputs_written = fp->Base.Base.OutputsWritten;
+ fs.inputs_read
+ = tgsi_mesa_translate_fragment_input_mask(fp->Base.Base.InputsRead);
+ fs.outputs_written
+ = tgsi_mesa_translate_fragment_output_mask(fp->Base.Base.OutputsWritten);
fs.tokens = &fp->tokens[0];
if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 ||
stfp = make_color_shader(st);
}
memset(&fs, 0, sizeof(fs));
- fs.inputs_read = stfp->Base.Base.InputsRead;
+ fs.inputs_read = tgsi_mesa_translate_fragment_input_mask(stfp->Base.Base.InputsRead);
+ fs.outputs_written = tgsi_mesa_translate_fragment_output_mask(stfp->Base.Base.OutputsWritten);
fs.tokens = &stfp->tokens[0];
pipe->set_fs_state(pipe, &fs);
}