From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl.h | 3 +++ libs/vkd3d-shader/hlsl.y | 54 +++++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 8b0a7c21..fde556e7 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -438,6 +438,9 @@ struct hlsl_ir_var struct hlsl_technique { char *name; + /* Skips serialization of the technique its data. Used to control + exclude techniques with syntax that's not supported by target profile. */ + bool skip; };
struct hlsl_effect_group diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index e4c97d78..d30efdc0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1113,6 +1113,7 @@ static bool add_technique(struct hlsl_ctx *ctx, struct parse_technique_list *lis static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, const struct parse_technique_list *techniques) { struct hlsl_effect_group *group; + unsigned int i;
if (!(group = hlsl_alloc(ctx, sizeof(*group)))) return false; @@ -1125,19 +1126,56 @@ static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, const struc group->techniques = techniques->techniques; group->count = techniques->count;
+ /* Explicit groups are only used with fx_5_0, skip all contained techniques for older profiles. */ + if (ctx->profile->major_version < 5) + { + for (i = 0; i < group->count; ++i) + group->techniques[i]->skip = true; + } + list_add_tail(&ctx->effect_groups, &group->entry);
return true; }
+enum technique_type +{ + TECHNIQUE9, + TECHNIQUE10, + TECHNIQUE11, +}; + static struct hlsl_technique *create_technique(struct hlsl_ctx *ctx, const char *name, - const struct vkd3d_shader_location *loc) + enum technique_type technique_type, const struct vkd3d_shader_location *loc) { struct hlsl_technique *technique; struct hlsl_ir_var *var; + bool skip; + + if (technique_type == TECHNIQUE9) + { + skip = ctx->profile->major_version > 2; + } + else if (technique_type == TECHNIQUE10) + { + if (ctx->profile->type == VKD3D_SHADER_TYPE_EFFECT && ctx->profile->major_version == 2) + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, + "The 'technique10' keyword is invalid for this profile."); + + skip = ctx->profile->major_version == 2; + } + else if (technique_type == TECHNIQUE11) + { + if (ctx->profile->type == VKD3D_SHADER_TYPE_EFFECT && ctx->profile->major_version == 2) + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, + "The 'technique11' keyword is invalid for this profile."); + + skip = ctx->profile->major_version == 4; + }
if (!(technique = hlsl_alloc(ctx, sizeof(*technique)))) return NULL; + technique->skip = skip;
if (name) { @@ -5092,27 +5130,19 @@ pass_list: technique9: KW_TECHNIQUE technique_name '{' pass_list '}' { - $$ = create_technique(ctx, $2, &@2); + $$ = create_technique(ctx, $2, TECHNIQUE9, &@2); }
technique10: KW_TECHNIQUE10 technique_name '{' pass_list '}' { - if (ctx->profile->type == VKD3D_SHADER_TYPE_EFFECT && ctx->profile->major_version == 2) - hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, - "The 'technique10' keyword is invalid for this profile."); - - $$ = create_technique(ctx, $2, &@2); + $$ = create_technique(ctx, $2, TECHNIQUE10, &@2); }
technique11: KW_TECHNIQUE11 technique_name '{' pass_list '}' { - if (ctx->profile->type == VKD3D_SHADER_TYPE_EFFECT && ctx->profile->major_version == 2) - hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, - "The 'technique11' keyword is invalid for this profile."); - - $$ = create_technique(ctx, $2, &@2); + $$ = create_technique(ctx, $2, TECHNIQUE11, &@2); }
default_group_technique: