diff options
author | Jason Ekstrand <[email protected]> | 2018-12-06 11:20:26 -0600 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-12-16 21:03:02 +0000 |
commit | 487514ae6120fd66d6b58cddea1c27b5fe8573e5 (patch) | |
tree | c923d86edf333591fffd780ab7f331ad53cb919f /src/compiler/nir | |
parent | 3191a823726053242696a7d96f37abd5475fadcc (diff) |
nir/large_constants: Properly handle 1-bit bools
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Tested-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir_opt_large_constants.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_opt_large_constants.c b/src/compiler/nir/nir_opt_large_constants.c index 634913aa9e5..aa22f05d809 100644 --- a/src/compiler/nir/nir_opt_large_constants.c +++ b/src/compiler/nir/nir_opt_large_constants.c @@ -53,7 +53,23 @@ build_constant_load(nir_builder *b, nir_deref_instr *deref, num_components, bit_size, NULL); nir_builder_instr_insert(b, &load->instr); - return &load->dest.ssa; + if (load->dest.ssa.bit_size < 8) { + /* Booleans are special-cased to be 32-bit + * + * Ideally, for drivers that can handle 32-bit booleans, we wouldn't + * emit the i2b here. However, at this point, the driver is likely to + * still have 1-bit booleans so we need to at least convert bit sizes. + * Unfortunately, we don't have a good way to annotate the load as + * loading a known boolean value so the optimizer isn't going to be + * able to get rid of the conversion. Some day, we may solve that + * problem but not today. + */ + assert(glsl_type_is_boolean(deref->type)); + load->dest.ssa.bit_size = 32; + return nir_i2b(b, &load->dest.ssa); + } else { + return &load->dest.ssa; + } } static void @@ -74,6 +90,12 @@ handle_constant_store(nir_builder *b, nir_intrinsic_instr *store, nir_const_value *val = nir_src_as_const_value(store->src[1]); switch (bit_size) { + case 1: + /* Booleans are special-cased to be 32-bit */ + for (unsigned i = 0; i < num_components; i++) + ((int32_t *)dst)[i] = -(int)val->b[i]; + break; + case 8: for (unsigned i = 0; i < num_components; i++) ((uint8_t *)dst)[i] = val->u8[i]; |