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
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];
unsigned *size, unsigned *align)
{
switch (type->base_type) {
+ case GLSL_TYPE_BOOL:
+ /* We special-case Booleans to 32 bits to not cause heartburn for
+ * drivers that suddenly get an 8-bit load.
+ */
+ *size = 4 * type->components();
+ *align = 4;
+ break;
+
case GLSL_TYPE_UINT8:
case GLSL_TYPE_INT8:
case GLSL_TYPE_UINT16:
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
case GLSL_TYPE_FLOAT:
- case GLSL_TYPE_BOOL:
case GLSL_TYPE_DOUBLE:
case GLSL_TYPE_UINT64:
case GLSL_TYPE_INT64: {