On 10/19/22 22:36, Francisco Casas wrote:
In the following patches, compatible_data_types() and implicit_compatible_data_types() are improved so that:
- Casts that should be allowed actually reach add_cast().
- Casts that shouldn't be allowed because of special conditions (besides component count), e.g. matrix to matrix, don't reach add_cast().
Not an issue with these patches (nor do I think it should change anything about how they're implemented), but for what it's worth, we probably should let even the invalid casts "reach" add_cast(). Or, at least, they shouldn't abort compilation; maybe we can achieve that in some other way.
This is a more general problem we have—we should try to avoid aborting compilation where possible, so that multiple errors can be reported in a single pass.
matrix_cast = !broadcast && dst_comp_count != src_comp_count
&& src_type->type == HLSL_CLASS_MATRIX && dst_type->type == HLSL_CLASS_MATRIX;
assert(src_comp_count >= dst_comp_count || broadcast);
assert(!matrix_cast || dst_type->dimx <= src_type->dimx);
assert(!matrix_cast || dst_type->dimy <= src_type->dimy);
Nitpicking, I think this is a bit easier to read as
if (matrix_cast) { assert(dst_type->dimx <= src_type->dimx); assert(dst_type->dimy <= src_type->dimy); }