diff options
author | Mathias Fröhlich <[email protected]> | 2018-01-27 16:07:22 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-02-01 22:39:06 +0100 |
commit | 38b41fd718cfffd11dab637d9d0cbd6c2a30b2c2 (patch) | |
tree | 24910d5640ca92b20285f40cda11279fca976468 /src/mesa | |
parent | f37e29ac224887f1b4f0cb7c61e47fb4bc6671e1 (diff) |
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 <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_render_t.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_render.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv20_render.c | 20 | ||||
-rw-r--r-- | src/mesa/main/ffvertex_prog.c | 7 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_context.c | 4 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_array.c | 10 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_draw.c | 10 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_save_draw.c | 9 |
10 files changed, 45 insertions, 37 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c index db60b59c8fc..5699f38f4dc 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c @@ -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, diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index fdd135c5d7d..b9145e6851a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -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) diff --git a/src/mesa/drivers/dri/nouveau/nv10_render.c b/src/mesa/drivers/dri/nouveau/nv10_render.c index 701ba9a87a8..9b2cf229f85 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_render.c +++ b/src/mesa/drivers/dri/nouveau/nv10_render.c @@ -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, }, }; diff --git a/src/mesa/drivers/dri/nouveau/nv20_render.c b/src/mesa/drivers/dri/nouveau/nv20_render.c index 2627bfa354f..9a426ccec07 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_render.c +++ b/src/mesa/drivers/dri/nouveau/nv20_render.c @@ -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, }, }; diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 6d852496e02..6a022b83bdc 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -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 ); diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index ced2857fc97..48d7ced791f 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -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, diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 3f55e27f9be..4fa6f62ad09 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -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++) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index fc0d4890655..d1f4da0c0e7 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -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); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 5cea7fe8793..2b7784694f7 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -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; diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 486247f7441..bbc2d0dfedf 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -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: |