From 4db8b171a5118d3ea6c773c62a40fc9cec03b1ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 Jan 2021 12:13:28 -0500 Subject: [PATCH] mesa: add STATIC_ASSERTs to the STATE_LIGHT_ATTRIBS case MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Zoltán Böszörményi Part-of: --- src/mesa/program/prog_statevars.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index e2c9039..f3b5d3b 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -134,13 +134,19 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[], value[0] = ctx->Light.LightSource[ln].SpotCutoff; return; } - case STATE_LIGHT_ATTRIBS: + case STATE_LIGHT_ATTRIBS: { + /* This must be exact because it must match the gl_LightSource layout + * in GLSL. + */ + STATIC_ASSERT(sizeof(struct gl_light_uniforms) == 29 * 4); + STATIC_ASSERT(ARRAY_SIZE(ctx->Light.LightSourceData) == 29 * MAX_LIGHTS); /* state[1] is the index of the first value */ /* state[2] is the number of values */ assert(state[1] + state[2] <= ARRAY_SIZE(ctx->Light.LightSourceData)); memcpy(value, &ctx->Light.LightSourceData[state[1]], state[2] * sizeof(float)); return; + } case STATE_LIGHTMODEL_AMBIENT: COPY_4V(value, ctx->Light.Model.Ambient); return; -- 2.7.4