From 5ddab654d93f6f23f3b0f0fa79b086810b3f5c58 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 26 Jun 2020 19:56:11 +1000 Subject: [PATCH] mesa: add _mesa_program_state_value_size() helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows us to query the uniform size required to store the state value. CC: Reviewed-by: Marek Olšák Reviewed-by: Eric Anholt Part-of: --- src/mesa/program/prog_statevars.c | 9 +++++++++ src/mesa/program/prog_statevars.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 1a3c8ab654f..71c33132a00 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -630,6 +630,15 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[], } } +unsigned +_mesa_program_state_value_size(const gl_state_index16 state[STATE_LENGTH]) +{ + if (state[0] == STATE_LIGHT && state[2] == STATE_SPOT_CUTOFF) + return 1; + + /* Everything else is packed into vec4s */ + return 4; +} /** * Return a bitmask of the Mesa state flags (_NEW_* values) which would diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h index de457d1a7f4..4dc0123776f 100644 --- a/src/mesa/program/prog_statevars.h +++ b/src/mesa/program/prog_statevars.h @@ -139,6 +139,8 @@ extern void _mesa_load_state_parameters(struct gl_context *ctx, struct gl_program_parameter_list *paramList); +extern unsigned +_mesa_program_state_value_size(const gl_state_index16 state[STATE_LENGTH]); extern GLbitfield _mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);