From cc4afb21010993a2d3fcac8a17c9bc3e49cf32bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 28 Sep 2020 21:54:04 -0400 Subject: [PATCH] mesa: demystify material_attrib() the next commit would break this magic math Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/ffvertex_prog.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 86b556238d4..d0be9f12d07 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -836,7 +836,20 @@ static void build_hpos( struct tnl_program *p ) static GLuint material_attrib( GLuint side, GLuint property ) { - return (property - STATE_AMBIENT) * 2 + side; + switch (property) { + case STATE_AMBIENT: + return MAT_ATTRIB_FRONT_AMBIENT + side; + case STATE_DIFFUSE: + return MAT_ATTRIB_FRONT_DIFFUSE + side; + case STATE_SPECULAR: + return MAT_ATTRIB_FRONT_SPECULAR + side; + case STATE_EMISSION: + return MAT_ATTRIB_FRONT_EMISSION + side; + case STATE_SHININESS: + return MAT_ATTRIB_FRONT_SHININESS + side; + default: + unreachable("invalid value"); + } }