nir: Add some sanity assertions in opt_large_constants

We make some assumptions in opt_large_constants such as the size_align
function returning the obvious sizes for vectors.  Now that we've got
the deref_size lying around, we may as well assert it's consistent with
our assumptions.  In particular, we now assert that it really claims
booleans are 32-bit.  If anyone's driver ever decides to be clever and
change this, we'll now catch the breakage earlier.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4468>
This commit is contained in:
Jason Ekstrand 2020-04-08 15:11:57 -05:00 committed by Marge Bot
parent 33eb43349e
commit 9b17d7caac
1 changed files with 2 additions and 0 deletions

View File

@ -92,9 +92,11 @@ build_constant_load(nir_builder *b, nir_deref_instr *deref,
if (load->dest.ssa.bit_size < 8) {
/* Booleans are special-cased to be 32-bit */
assert(glsl_type_is_boolean(deref->type));
assert(deref_size == num_components * 4);
load->dest.ssa.bit_size = 32;
return nir_b2b1(b, &load->dest.ssa);
} else {
assert(deref_size == num_components * bit_size / 8);
return &load->dest.ssa;
}
}