mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-21 14:10:37 +02:00
nir: make static assert more flexible
The static assert used in encode deref modes used the fact there was less than 16 modes that we wanted to compress as an opportunity to reuse MODE_ENC_GENERIC_BIT as it just happened to represent 16. However if we add more than 16 modes i.e need to compress to 6 bits not 5 bits then MODE_ENC_GENERIC_BIT becomes 32 and the logic in the assert breaks. Instead we more precisely make sure MODE_ENC_GENERIC_BIT is large enough to fit all but the last 4 generic modes and that the last 4 modes defined in the enum are in fact the 4 generic modes. Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30654>
This commit is contained in:
parent
85a70bbc05
commit
08b93c841a
1 changed files with 10 additions and 1 deletions
|
|
@ -825,6 +825,7 @@ read_alu(read_ctx *ctx, union packed_instr header)
|
|||
return alu;
|
||||
}
|
||||
|
||||
#define NUM_GENERIC_MODES 4
|
||||
#define MODE_ENC_GENERIC_BIT (1 << 4)
|
||||
|
||||
static nir_variable_mode
|
||||
|
|
@ -848,8 +849,16 @@ encode_deref_modes(nir_variable_mode modes)
|
|||
* can compress them by only storing the bit position. This, plus one bit
|
||||
* to select encoding, lets us pack the entire bitfield in 5 bits.
|
||||
*/
|
||||
|
||||
/* Assert that the modes we are compressing fit along with the generic bit
|
||||
*/
|
||||
STATIC_ASSERT((nir_num_variable_modes - NUM_GENERIC_MODES) <
|
||||
MODE_ENC_GENERIC_BIT);
|
||||
|
||||
/* Assert that the generic modes are defined at the end of the modes enum
|
||||
*/
|
||||
STATIC_ASSERT((nir_var_all & ~nir_var_mem_generic) <
|
||||
(1 << MODE_ENC_GENERIC_BIT));
|
||||
(1 << (nir_num_variable_modes - NUM_GENERIC_MODES)));
|
||||
|
||||
unsigned enc;
|
||||
if (modes == 0 || (modes & nir_var_mem_generic)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue