glsl: fix constant expression evaluation for 16-bit types
Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073>
This commit is contained in:
@@ -694,6 +694,7 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
|||||||
if (this->type->is_error())
|
if (this->type->is_error())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
const glsl_type *return_type = this->type;
|
||||||
ir_constant *op[ARRAY_SIZE(this->operands)] = { NULL, };
|
ir_constant *op[ARRAY_SIZE(this->operands)] = { NULL, };
|
||||||
ir_constant_data data;
|
ir_constant_data data;
|
||||||
|
|
||||||
@@ -760,6 +761,33 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (return_type->base_type) {
|
||||||
|
case GLSL_TYPE_FLOAT16:
|
||||||
|
return_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||||
|
return_type->vector_elements,
|
||||||
|
return_type->matrix_columns,
|
||||||
|
return_type->explicit_stride,
|
||||||
|
return_type->interface_row_major);
|
||||||
|
break;
|
||||||
|
case GLSL_TYPE_INT16:
|
||||||
|
return_type = glsl_type::get_instance(GLSL_TYPE_INT,
|
||||||
|
return_type->vector_elements,
|
||||||
|
return_type->matrix_columns,
|
||||||
|
return_type->explicit_stride,
|
||||||
|
return_type->interface_row_major);
|
||||||
|
break;
|
||||||
|
case GLSL_TYPE_UINT16:
|
||||||
|
return_type = glsl_type::get_instance(GLSL_TYPE_UINT,
|
||||||
|
return_type->vector_elements,
|
||||||
|
return_type->matrix_columns,
|
||||||
|
return_type->explicit_stride,
|
||||||
|
return_type->interface_row_major);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* nothing to do */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (op[1] != NULL)
|
if (op[1] != NULL)
|
||||||
switch (this->operation) {
|
switch (this->operation) {
|
||||||
case ir_binop_lshift:
|
case ir_binop_lshift:
|
||||||
|
@@ -247,7 +247,7 @@ constant_template_vector_insert = mako.template.Template("""\
|
|||||||
|
|
||||||
memcpy(&data, &op[0]->value, sizeof(data));
|
memcpy(&data, &op[0]->value, sizeof(data));
|
||||||
|
|
||||||
switch (this->type->base_type) {
|
switch (return_type->base_type) {
|
||||||
% for dst_type, src_types in op.signatures():
|
% for dst_type, src_types in op.signatures():
|
||||||
case ${src_types[0].glsl_type}:
|
case ${src_types[0].glsl_type}:
|
||||||
data.${dst_type.union_field}[idx] = op[1]->value.${src_types[0].union_field}[0];
|
data.${dst_type.union_field}[idx] = op[1]->value.${src_types[0].union_field}[0];
|
||||||
@@ -262,8 +262,8 @@ constant_template_vector_insert = mako.template.Template("""\
|
|||||||
# This template is for ir_quadop_vector.
|
# This template is for ir_quadop_vector.
|
||||||
constant_template_vector = mako.template.Template("""\
|
constant_template_vector = mako.template.Template("""\
|
||||||
case ${op.get_enum_name()}:
|
case ${op.get_enum_name()}:
|
||||||
for (unsigned c = 0; c < this->type->vector_elements; c++) {
|
for (unsigned c = 0; c < return_type->vector_elements; c++) {
|
||||||
switch (this->type->base_type) {
|
switch (return_type->base_type) {
|
||||||
% for dst_type, src_types in op.signatures():
|
% for dst_type, src_types in op.signatures():
|
||||||
case ${src_types[0].glsl_type}:
|
case ${src_types[0].glsl_type}:
|
||||||
data.${dst_type.union_field}[c] = op[c]->value.${src_types[0].union_field}[0];
|
data.${dst_type.union_field}[c] = op[c]->value.${src_types[0].union_field}[0];
|
||||||
@@ -284,7 +284,7 @@ constant_template_lrp = mako.template.Template("""\
|
|||||||
|
|
||||||
unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
|
unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
|
||||||
for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
|
for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
|
||||||
switch (this->type->base_type) {
|
switch (return_type->base_type) {
|
||||||
% for dst_type, src_types in op.signatures():
|
% for dst_type, src_types in op.signatures():
|
||||||
case ${src_types[0].glsl_type}:
|
case ${src_types[0].glsl_type}:
|
||||||
data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types, ("c", "c", "c2"))};
|
data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types, ("c", "c", "c2"))};
|
||||||
@@ -303,7 +303,7 @@ constant_template_lrp = mako.template.Template("""\
|
|||||||
constant_template_csel = mako.template.Template("""\
|
constant_template_csel = mako.template.Template("""\
|
||||||
case ${op.get_enum_name()}:
|
case ${op.get_enum_name()}:
|
||||||
for (unsigned c = 0; c < components; c++) {
|
for (unsigned c = 0; c < components; c++) {
|
||||||
switch (this->type->base_type) {
|
switch (return_type->base_type) {
|
||||||
% for dst_type, src_types in op.signatures():
|
% for dst_type, src_types in op.signatures():
|
||||||
case ${src_types[1].glsl_type}:
|
case ${src_types[1].glsl_type}:
|
||||||
data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types)};
|
data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types)};
|
||||||
|
Reference in New Issue
Block a user