Module: vkd3d Branch: master Commit: 9ccf2919718862641f5b80298e48bf2bf040cbc6 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/9ccf2919718862641f5b80298e48bf...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Fri Jun 16 11:21:09 2023 +0200
vkd3d-shader/hlsl: Use profile version testing helpers in more places.
---
libs/vkd3d-shader/hlsl.y | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index b098c2bc..22e52b9f 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -832,6 +832,11 @@ static bool shader_profile_version_ge(const struct hlsl_ctx *ctx, unsigned int m return ctx->profile->major_version > major || (ctx->profile->major_version == major && ctx->profile->minor_version >= minor); }
+static bool shader_profile_version_lt(const struct hlsl_ctx *ctx, unsigned int major, unsigned int minor) +{ + return !shader_profile_version_ge(ctx, major, minor); +} + static bool gen_struct_fields(struct hlsl_ctx *ctx, struct parse_fields *fields, struct hlsl_type *type, unsigned int modifiers, struct list *defs) { @@ -1022,7 +1027,7 @@ static struct hlsl_reg_reservation parse_packoffset(struct hlsl_ctx *ctx, const struct hlsl_reg_reservation reservation = {0}; char *endptr;
- if (ctx->profile->major_version < 4) + if (shader_profile_version_lt(ctx, 4, 0)) return reservation;
reservation.offset_index = strtoul(reg_string + 1, &endptr, 10); @@ -3488,7 +3493,7 @@ static bool intrinsic_d3dcolor_to_ubyte4(struct hlsl_ctx *ctx, if (!(ret = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, arg, c, loc))) return false;
- if (ctx->profile->major_version >= 4) + if (shader_profile_version_ge(ctx, 4, 0)) return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_TRUNC, ret, loc);
return true; @@ -5292,7 +5297,7 @@ type_no_void: { validate_texture_format_type(ctx, $3, &@3);
- if (!shader_profile_version_ge(ctx, 4, 1)) + if (shader_profile_version_lt(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); @@ -5361,7 +5366,7 @@ type_no_void: $$ = hlsl_get_type(ctx->cur_scope, $1, true, true); if ($$->is_minimum_precision) { - if (ctx->profile->major_version < 4) + if (shader_profile_version_lt(ctx, 4, 0)) { hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Target profile doesn't support minimum-precision types.");