vkd3d-shader/hlsl: Allow 'export' modifier on functions.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-03-31 15:36:00 +02:00 committed by Alexandre Julliard
parent 636d8d3850
commit 4b0a328a2b
Notes: Alexandre Julliard 2024-04-03 23:35:25 +02:00
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/746
4 changed files with 21 additions and 2 deletions

View File

@ -375,6 +375,7 @@ struct hlsl_attribute
#define HLSL_STORAGE_NOPERSPECTIVE 0x00008000 #define HLSL_STORAGE_NOPERSPECTIVE 0x00008000
#define HLSL_STORAGE_LINEAR 0x00010000 #define HLSL_STORAGE_LINEAR 0x00010000
#define HLSL_MODIFIER_SINGLE 0x00020000 #define HLSL_MODIFIER_SINGLE 0x00020000
#define HLSL_MODIFIER_EXPORT 0x00040000
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \ #define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \
HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \ HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \

View File

@ -88,6 +88,7 @@ DomainShader {return KW_DOMAINSHADER; }
do {return KW_DO; } do {return KW_DO; }
double {return KW_DOUBLE; } double {return KW_DOUBLE; }
else {return KW_ELSE; } else {return KW_ELSE; }
export {return KW_EXPORT; }
extern {return KW_EXTERN; } extern {return KW_EXTERN; }
false {return KW_FALSE; } false {return KW_FALSE; }
for {return KW_FOR; } for {return KW_FOR; }

View File

@ -5341,6 +5341,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
%token KW_DOMAINSHADER %token KW_DOMAINSHADER
%token KW_DOUBLE %token KW_DOUBLE
%token KW_ELSE %token KW_ELSE
%token KW_EXPORT
%token KW_EXTERN %token KW_EXTERN
%token KW_FALSE %token KW_FALSE
%token KW_FOR %token KW_FOR
@ -5969,9 +5970,9 @@ func_prototype_no_attrs:
/* Functions are unconditionally inlined. */ /* Functions are unconditionally inlined. */
modifiers &= ~HLSL_MODIFIER_INLINE; 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, 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))) if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
YYABORT; YYABORT;
if ((var = hlsl_get_var(ctx->globals, $3))) if ((var = hlsl_get_var(ctx->globals, $3)))
@ -6868,6 +6869,10 @@ var_modifiers:
{ {
$$ = add_modifiers(ctx, $2, HLSL_MODIFIER_INLINE, &@1); $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_INLINE, &@1);
} }
| KW_EXPORT var_modifiers
{
$$ = add_modifiers(ctx, $2, HLSL_MODIFIER_EXPORT, &@1);
}
| var_identifier var_modifiers | var_identifier var_modifiers
{ {
if (!strcmp($1, "precise")) if (!strcmp($1, "precise"))

View File

@ -333,3 +333,15 @@ inline float4 main() : sv_target
[test] [test]
todo(glsl) draw quad todo(glsl) draw quad
probe all rgba (2.0, 3.0, 6.0, 7.0) 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)