From 5c02e121876be2d0b0e7a9e56dc925e03c6afa23 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 16 Jun 2023 11:09:21 +0200 Subject: [PATCH] vkd3d-shader/hlsl: Make sample count optional for SM4.1+. Signed-off-by: Nikolay Sivov --- libs/vkd3d-shader/hlsl.y | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 07a47a7f..b098c2bc 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -827,6 +827,11 @@ static bool shader_is_sm_5_1(const struct hlsl_ctx *ctx) return ctx->profile->major_version == 5 && ctx->profile->minor_version >= 1; } +static bool shader_profile_version_ge(const struct hlsl_ctx *ctx, unsigned int major, unsigned int minor) +{ + return ctx->profile->major_version > major || (ctx->profile->major_version == major && ctx->profile->minor_version >= minor); +} + static bool gen_struct_fields(struct hlsl_ctx *ctx, struct parse_fields *fields, struct hlsl_type *type, unsigned int modifiers, struct list *defs) { @@ -5287,7 +5292,12 @@ type_no_void: { validate_texture_format_type(ctx, $3, &@3); - /* TODO: unspecified sample count is not allowed for all targets */ + if (!shader_profile_version_ge(ctx, 4, 1)) + { + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + "Multisampled texture object declaration needs sample count for profile %s.", ctx->profile->name); + } + $$ = hlsl_new_texture_type(ctx, $1, $3, 0); } | texture_ms_type '<' type ',' shift_expr '>'