mesa: add _mesa_program_state_value_size() helper
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 26 Jun 2020 09:56:11 +0000 (19:56 +1000)
committerMarge Bot <eric+marge@anholt.net>
Tue, 30 Jun 2020 01:29:43 +0000 (01:29 +0000)
This allows us to query the uniform size required to store the
state value.

CC: <stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5656>

src/mesa/program/prog_statevars.c
src/mesa/program/prog_statevars.h

index 1a3c8ab654f44564821b9d5ce1371abaf92b7aab..71c33132a0092f5e121b573784431013d544846f 100644 (file)
@@ -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
index de457d1a7f42b9edf05c0933f28dd6f9e2835c7c..4dc0123776ffa53924e1c65e3b08ac13ab28d0d1 100644 (file)
@@ -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]);