glsl_to_nir: Fix NIR bit-size of ir_triop_bitfield_extract and ir_quadop_bitfield_insert
Previously these would return result->bit_size of 32 even though the
type might have been int16_t or uint16_t. This prevents many assertion
failures in "glsl: Use nir_type_convert instead of
nir_type_conversion_op" on zink.
Fixes: 5e922fbc16
("glsl_to_nir: fix bitfield_extract with 16-bit operands")
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15121>
This commit is contained in:
@@ -2345,11 +2345,25 @@ nir_visitor::visit(ir_expression *ir)
|
||||
result = ir->type->is_int_16_32() ?
|
||||
nir_ibitfield_extract(&b, nir_i2i32(&b, srcs[0]), nir_i2i32(&b, srcs[1]), nir_i2i32(&b, srcs[2])) :
|
||||
nir_ubitfield_extract(&b, nir_u2u32(&b, srcs[0]), nir_i2i32(&b, srcs[1]), nir_i2i32(&b, srcs[2]));
|
||||
|
||||
if (ir->type->base_type == GLSL_TYPE_INT16) {
|
||||
result = nir_i2i16(&b, result);
|
||||
} else if (ir->type->base_type == GLSL_TYPE_UINT16) {
|
||||
result = nir_u2u16(&b, result);
|
||||
}
|
||||
|
||||
break;
|
||||
case ir_quadop_bitfield_insert:
|
||||
result = nir_bitfield_insert(&b,
|
||||
nir_u2u32(&b, srcs[0]), nir_u2u32(&b, srcs[1]),
|
||||
nir_i2i32(&b, srcs[2]), nir_i2i32(&b, srcs[3]));
|
||||
|
||||
if (ir->type->base_type == GLSL_TYPE_INT16) {
|
||||
result = nir_i2i16(&b, result);
|
||||
} else if (ir->type->base_type == GLSL_TYPE_UINT16) {
|
||||
result = nir_u2u16(&b, result);
|
||||
}
|
||||
|
||||
break;
|
||||
case ir_quadop_vector:
|
||||
result = nir_vec(&b, srcs, ir->type->vector_elements);
|
||||
@@ -2358,6 +2372,11 @@ nir_visitor::visit(ir_expression *ir)
|
||||
default:
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
/* The bit-size of the NIR SSA value must match the bit-size of the
|
||||
* original GLSL IR expression.
|
||||
*/
|
||||
assert(result->bit_size == glsl_base_type_get_bit_size(ir->type->base_type));
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user