diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 16ddbf3c..f5a38a29 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 600e2cf2..88b917ef 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 9135fb7a..e02e0c54 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5341,6 +5341,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 @@ -5969,9 +5970,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))) @@ -6868,6 +6869,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 dbe9d3a3..7743ee1f 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)