From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.l | 1 + libs/vkd3d-shader/hlsl.y | 9 +++++++-- tests/hlsl/function.shader_test | 12 ++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 64111f3fc..5e21c398f 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -375,6 +375,7 @@ struct hlsl_attribute #define HLSL_STORAGE_NOPERSPECTIVE 0x00008000 #define HLSL_STORAGE_LINEAR 0x00010000 #define HLSL_MODIFIER_SINGLE 0x00020000 +#define HLSL_MODIFIER_EXPORT 0x00040000
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \ HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \ diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 600e2cf2c..88b917eff 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -88,6 +88,7 @@ DomainShader {return KW_DOMAINSHADER; } do {return KW_DO; } double {return KW_DOUBLE; } else {return KW_ELSE; } +export {return KW_EXPORT; } extern {return KW_EXTERN; } false {return KW_FALSE; } for {return KW_FOR; } diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 52c217654..f85c3b157 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5349,6 +5349,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, %token KW_DOMAINSHADER %token KW_DOUBLE %token KW_ELSE +%token KW_EXPORT %token KW_EXTERN %token KW_FALSE %token KW_FOR @@ -5977,9 +5978,9 @@ func_prototype_no_attrs: /* Functions are unconditionally inlined. */ modifiers &= ~HLSL_MODIFIER_INLINE;
- if (modifiers & ~HLSL_MODIFIERS_MAJORITY_MASK) + if (modifiers & ~(HLSL_MODIFIERS_MAJORITY_MASK | HLSL_MODIFIER_EXPORT)) hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, - "Only majority modifiers are allowed on functions."); + "Unexpected modifier used on a function."); if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1))) YYABORT; if ((var = hlsl_get_var(ctx->globals, $3))) @@ -6876,6 +6877,10 @@ var_modifiers: { $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_INLINE, &@1); } + | KW_EXPORT var_modifiers + { + $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_EXPORT, &@1); + } | var_identifier var_modifiers { if (!strcmp($1, "precise")) diff --git a/tests/hlsl/function.shader_test b/tests/hlsl/function.shader_test index dbe9d3a33..7743ee1f1 100644 --- a/tests/hlsl/function.shader_test +++ b/tests/hlsl/function.shader_test @@ -333,3 +333,15 @@ inline float4 main() : sv_target [test] todo(glsl) draw quad probe all rgba (2.0, 3.0, 6.0, 7.0) + +% Export modifier + +[pixel shader] +export float4 main() : sv_target +{ + return float4(1.0, 2.0, 3.0, 4.0); +} + +[test] +todo(glsl) draw quad +probe all rgba (1.0, 2.0, 3.0, 4.0)
This merge request was approved by Zebediah Figura.
This merge request was approved by Henri Verbeet.