mesa: Use defines for the aliased material array attributes.
Instead of just assuming that the material attributes just overlap with the generic attributes 0-12, give them symbolic defines so that we can easier move them to an other range. Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de> Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:

committed by
Mathias Fröhlich

parent
f37e29ac22
commit
38b41fd718
@@ -124,6 +124,9 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
|
||||
* VERT_ATTRIB_GENERIC
|
||||
* include the OpenGL 2.0+ GLSL generic shader attributes.
|
||||
* These alias the generic GL_ARB_vertex_shader attributes.
|
||||
* VERT_ATTRIB_MAT
|
||||
* include the generic shader attributes used to alias
|
||||
* varying material values for the TNL shader programs.
|
||||
*/
|
||||
#define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i))
|
||||
#define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0
|
||||
@@ -134,6 +137,9 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
|
||||
#define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
|
||||
#define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
|
||||
|
||||
#define VERT_ATTRIB_MAT(i) VERT_ATTRIB_GENERIC(i)
|
||||
#define VERT_ATTRIB_MAT_MAX MAT_ATTRIB_MAX
|
||||
|
||||
/**
|
||||
* Bitflags for vertex attributes.
|
||||
* These are used in bitfields in many places.
|
||||
@@ -169,6 +175,10 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
|
||||
#define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
|
||||
#define VERT_BIT_GENERIC_ALL \
|
||||
BITFIELD_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
|
||||
|
||||
#define VERT_BIT_MAT(i) VERT_BIT(VERT_ATTRIB_MAT(i))
|
||||
#define VERT_BIT_MAT_ALL \
|
||||
BITFIELD_RANGE(VERT_ATTRIB_MAT(0), VERT_ATTRIB_MAT_MAX)
|
||||
/*@}*/
|
||||
|
||||
#define MAX_VARYING 32 /**< number of float[4] vectors */
|
||||
|
@@ -188,7 +188,7 @@ static void
|
||||
TAG(emit_material)(struct gl_context *ctx, struct nouveau_array *a,
|
||||
const void *v)
|
||||
{
|
||||
int attr = a->attr - VERT_ATTRIB_GENERIC0;
|
||||
int attr = a->attr - VERT_ATTRIB_MAT(0);
|
||||
int state = ((int []) {
|
||||
NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
|
||||
NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
|
||||
|
@@ -118,8 +118,8 @@ vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array **ar
|
||||
render->mode = VBO;
|
||||
|
||||
if (ctx->Light.Enabled) {
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
|
||||
if (arrays[VERT_ATTRIB_GENERIC0 + i]->StrideB) {
|
||||
for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
|
||||
if (arrays[VERT_ATTRIB_MAT(i)]->StrideB) {
|
||||
render->mode = IMM;
|
||||
break;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array **arrays,
|
||||
RENDER_LOCALS(ctx);
|
||||
|
||||
if (!array->StrideB) {
|
||||
if (attr >= VERT_ATTRIB_GENERIC0)
|
||||
if (attr >= VERT_ATTRIB_MAT(0))
|
||||
/* nouveau_update_state takes care of materials. */
|
||||
return;
|
||||
|
||||
@@ -165,7 +165,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array **arrays,
|
||||
}
|
||||
}
|
||||
|
||||
#define MAT(a) (VERT_ATTRIB_GENERIC0 + MAT_ATTRIB_##a)
|
||||
#define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a)
|
||||
|
||||
static void
|
||||
vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array **arrays)
|
||||
|
@@ -72,19 +72,19 @@ static struct nouveau_attr_info nv10_vertex_attrs[VERT_ATTRIB_MAX] = {
|
||||
.imm_method = NV10_3D_VERTEX_FOG_1F,
|
||||
.imm_fields = 1,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC0] = {
|
||||
[VERT_ATTRIB_MAT(0)] = {
|
||||
.emit = nv10_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC2] = {
|
||||
[VERT_ATTRIB_MAT(2)] = {
|
||||
.emit = nv10_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC4] = {
|
||||
[VERT_ATTRIB_MAT(4)] = {
|
||||
.emit = nv10_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC6] = {
|
||||
[VERT_ATTRIB_MAT(6)] = {
|
||||
.emit = nv10_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC8] = {
|
||||
[VERT_ATTRIB_MAT(8)] = {
|
||||
.emit = nv10_emit_material,
|
||||
},
|
||||
};
|
||||
|
@@ -82,34 +82,34 @@ static struct nouveau_attr_info nv20_vertex_attrs[VERT_ATTRIB_MAX] = {
|
||||
.imm_method = NV20_3D_VERTEX_TX3_4F_S,
|
||||
.imm_fields = 4,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC0] = {
|
||||
[VERT_ATTRIB_MAT(0)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC1] = {
|
||||
[VERT_ATTRIB_MAT(1)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC2] = {
|
||||
[VERT_ATTRIB_MAT(2)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC3] = {
|
||||
[VERT_ATTRIB_MAT(3)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC4] = {
|
||||
[VERT_ATTRIB_MAT(4)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC5] = {
|
||||
[VERT_ATTRIB_MAT(5)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC6] = {
|
||||
[VERT_ATTRIB_MAT(6)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC7] = {
|
||||
[VERT_ATTRIB_MAT(7)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC8] = {
|
||||
[VERT_ATTRIB_MAT(8)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
[VERT_ATTRIB_GENERIC9] = {
|
||||
[VERT_ATTRIB_MAT(9)] = {
|
||||
.emit = nv20_emit_material,
|
||||
},
|
||||
};
|
||||
|
@@ -138,7 +138,7 @@ static GLboolean check_active_shininess( struct gl_context *ctx,
|
||||
(key->light_color_material_mask & (1 << attr)))
|
||||
return GL_TRUE;
|
||||
|
||||
if (key->varying_vp_inputs & VERT_BIT_GENERIC(attr))
|
||||
if (key->varying_vp_inputs & VERT_BIT_MAT(attr))
|
||||
return GL_TRUE;
|
||||
|
||||
if (ctx->Light.Material.Attrib[attr][0] != 0.0F)
|
||||
@@ -851,7 +851,8 @@ static void set_material_flags( struct tnl_program *p )
|
||||
p->color_materials = p->state->light_color_material_mask;
|
||||
}
|
||||
|
||||
p->materials |= (p->state->varying_vp_inputs >> VERT_ATTRIB_GENERIC0);
|
||||
p->materials |= ((p->state->varying_vp_inputs & VERT_BIT_MAT_ALL)
|
||||
>> VERT_ATTRIB_MAT(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -866,7 +867,7 @@ static struct ureg get_material( struct tnl_program *p, GLuint side,
|
||||
/* Put material values in the GENERIC slots -- they are not used
|
||||
* for anything in fixed function mode.
|
||||
*/
|
||||
return register_input( p, attrib + VERT_ATTRIB_GENERIC0 );
|
||||
return register_input( p, VERT_ATTRIB_MAT(attrib) );
|
||||
}
|
||||
else
|
||||
return register_param3( p, STATE_MATERIAL, side, property );
|
||||
|
@@ -126,7 +126,7 @@ enum {
|
||||
* generic attribute in order to pick up per-vertex material
|
||||
* data.
|
||||
*/
|
||||
_TNL_ATTRIB_MAT_FRONT_AMBIENT = _TNL_ATTRIB_GENERIC0,
|
||||
_TNL_ATTRIB_MAT_FRONT_AMBIENT=VERT_ATTRIB_MAT(MAT_ATTRIB_FRONT_AMBIENT),
|
||||
_TNL_ATTRIB_MAT_BACK_AMBIENT,
|
||||
_TNL_ATTRIB_MAT_FRONT_DIFFUSE,
|
||||
_TNL_ATTRIB_MAT_BACK_DIFFUSE,
|
||||
|
@@ -249,8 +249,8 @@ _vbo_CreateContext(struct gl_context *ctx)
|
||||
for (i = 0; i < ARRAY_SIZE(vbo->map_vp_none); i++)
|
||||
vbo->map_vp_none[i] = i;
|
||||
/* map material attribs to generic slots */
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++)
|
||||
vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)]
|
||||
for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++)
|
||||
vbo->map_vp_none[VERT_ATTRIB_MAT(i)]
|
||||
= VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(vbo->map_vp_arb); i++)
|
||||
|
@@ -331,20 +331,20 @@ recalculate_input_bindings(struct gl_context *ctx)
|
||||
inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
|
||||
else {
|
||||
inputs[i] = &vbo->currval[VBO_ATTRIB_POS + i];
|
||||
const_inputs |= VERT_BIT(i);
|
||||
const_inputs |= VERT_BIT_FF(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
|
||||
inputs[VERT_ATTRIB_GENERIC(i)] =
|
||||
for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
|
||||
inputs[VERT_ATTRIB_MAT(i)] =
|
||||
&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
|
||||
const_inputs |= VERT_BIT_GENERIC(i);
|
||||
const_inputs |= VERT_BIT_MAT(i);
|
||||
}
|
||||
|
||||
/* Could use just about anything, just to fill in the empty
|
||||
* slots:
|
||||
*/
|
||||
for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) {
|
||||
for (i = VERT_ATTRIB_MAT_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) {
|
||||
inputs[VERT_ATTRIB_GENERIC(i)] =
|
||||
&vbo->currval[VBO_ATTRIB_GENERIC0 + i];
|
||||
const_inputs |= VERT_BIT_GENERIC(i);
|
||||
|
@@ -187,11 +187,15 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
|
||||
/* Overlay other active attributes */
|
||||
switch (get_vp_mode(exec->ctx)) {
|
||||
case VP_FF:
|
||||
/* Point the generic attributes at the legacy material values */
|
||||
for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
|
||||
for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
|
||||
assert(VERT_ATTRIB_MAT(attr) < ARRAY_SIZE(exec->vtx.inputs));
|
||||
exec->vtx.inputs[VERT_ATTRIB_MAT(attr)] =
|
||||
&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
|
||||
}
|
||||
for (attr = VERT_ATTRIB_MAT_MAX; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
|
||||
assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
|
||||
exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
|
||||
&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
|
||||
&vbo->currval[VBO_ATTRIB_GENERIC0+attr];
|
||||
}
|
||||
map = vbo->map_vp_none;
|
||||
break;
|
||||
|
@@ -151,11 +151,14 @@ bind_vertex_list(struct gl_context *ctx,
|
||||
/* Overlay other active attributes */
|
||||
switch (get_vp_mode(ctx)) {
|
||||
case VP_FF:
|
||||
/* Point the generic attributes at the legacy material values */
|
||||
for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
|
||||
save->inputs[VERT_ATTRIB_GENERIC(attr)] =
|
||||
for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
|
||||
save->inputs[VERT_ATTRIB_MAT(attr)] =
|
||||
&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
|
||||
}
|
||||
for (attr = VERT_ATTRIB_MAT_MAX; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
|
||||
save->inputs[VERT_ATTRIB_GENERIC(attr)] =
|
||||
&vbo->currval[VBO_ATTRIB_GENERIC0+attr];
|
||||
}
|
||||
map = vbo->map_vp_none;
|
||||
break;
|
||||
case VP_SHADER:
|
||||
|
Reference in New Issue
Block a user