On 5/3/22 04:57, Giovanni Mascellani wrote:
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 95ce9445..ed94e903 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -165,6 +165,8 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type { unsigned int element_size = type->e.array.type->reg_size;
+ if (type->e.array.elements_count == HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT) + type->reg_size = 0;
This ends up breaking copy-prop, though, which is the main reason we needed to set reg_size for objects in the first place. Consider the following program, which is (surprisingly) legal in 5.1: Texture2D t1[]; float4 main() : sv_target { Texture2D t2[] = t1; return t2[4].Load(0); } On the other hand, this is legal in 5.0, but illegal in 5.1: Texture2D t1[5]; Texture2D t3; float4 main() : sv_target { Texture2D t2[] = t1; t2[4] = t3; return t2[4].Load(0); } Which suggests that, for the purposes of copy-prop, reg_size should be 1 for texture arrays (regardless of element count) in 5.1. (Perhaps there's an argument we shouldn't be abusing reg_size like that. I have never liked the logic, but I've also never found a better way to write it.) It'd be fine to punt for now though, by skipping creation of resource array types (and variables).
if (is_sm4) type->reg_size = (type->e.array.elements_count - 1) * align(element_size, 4) + element_size; else
...
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 44e4964f..eb96a4c2 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -789,7 +789,26 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx,
field->type = type; for (i = 0; i < v->arrays.count; ++i) + { + if (v->arrays.sizes[i] == HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT) + { + if (i < v->arrays.count - 1) + { + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + "Inner array cannot be implicit.");
Nitpick, I'd say "array /size/ cannot be implicit". Same below.