vkd3d-shader/hlsl: Forbid referring to typedefs with "struct".

This commit is contained in:
Elizabeth Figura
2025-05-13 12:39:46 -05:00
committed by Henri Verbeet
parent 8ca50a2f7e
commit c1adf54a44
Notes: Henri Verbeet 2025-05-14 15:29:22 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1500
3 changed files with 5 additions and 2 deletions

View File

@@ -234,6 +234,8 @@ struct hlsl_type
/* Offset where the type's description starts in the output bytecode, in bytes. */ /* Offset where the type's description starts in the output bytecode, in bytes. */
size_t bytecode_offset; size_t bytecode_offset;
bool is_typedef;
uint32_t is_minimum_precision : 1; uint32_t is_minimum_precision : 1;
}; };

View File

@@ -1183,6 +1183,7 @@ static bool add_typedef(struct hlsl_ctx *ctx, struct hlsl_type *const orig_type,
vkd3d_free((void *)type->name); vkd3d_free((void *)type->name);
type->name = v->name; type->name = v->name;
type->is_typedef = true;
ret = hlsl_scope_add_type(ctx->cur_scope, type); ret = hlsl_scope_add_type(ctx->cur_scope, type);
if (!ret) if (!ret)
@@ -8219,7 +8220,7 @@ type_no_void:
| KW_STRUCT TYPE_IDENTIFIER | KW_STRUCT TYPE_IDENTIFIER
{ {
$$ = hlsl_get_type(ctx->cur_scope, $2, true, true); $$ = hlsl_get_type(ctx->cur_scope, $2, true, true);
if ($$->class != HLSL_CLASS_STRUCT) if ($$->class != HLSL_CLASS_STRUCT || $$->is_typedef)
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is not a structure.", $2); hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is not a structure.", $2);
vkd3d_free($2); vkd3d_free($2);
} }

View File

@@ -33,7 +33,7 @@
return 0; return 0;
} }
[pixel shader fail todo(sm<6)] [pixel shader fail]
struct apple struct apple
{ {
float4 f; float4 f;