From: Nikolay Sivov nsivov@codeweavers.com
--- tests/hlsl/function.shader_test | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/tests/hlsl/function.shader_test b/tests/hlsl/function.shader_test index 4d4c2e2bb..9573d0a9c 100644 --- a/tests/hlsl/function.shader_test +++ b/tests/hlsl/function.shader_test @@ -295,3 +295,41 @@ float4 main() : sv_target [test] draw quad probe all rgba (2.0, 3.0, 6.0, 7.0) + +% Inline modifier + +[pixel shader todo] +inline float func(float a) +{ + return a + 1; +} + +float4 main() : sv_target +{ + float4 a = {func(1.0), func(2.0), func(5.0), func(6.0)}; + + return a; +} + +[test] +todo draw quad +todo probe all rgba (2.0, 3.0, 6.0, 7.0) + +% Inline modifier used on entry point + +[pixel shader todo] +float func(float a) +{ + return a + 1; +} + +inline float4 main() : sv_target +{ + float4 a = {func(1.0), func(2.0), func(5.0), func(6.0)}; + + return a; +} + +[test] +todo draw quad +todo probe all rgba (2.0, 3.0, 6.0, 7.0)
From: Nikolay Sivov nsivov@codeweavers.com
--- libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 7 +++++++ tests/hlsl/function.shader_test | 12 ++++++------ 3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e78602e8d..0c0920ab6 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -356,6 +356,7 @@ struct hlsl_attribute #define HLSL_MODIFIER_COLUMN_MAJOR 0x00000400 #define HLSL_STORAGE_IN 0x00000800 #define HLSL_STORAGE_OUT 0x00001000 +#define HLSL_MODIFIER_INLINE 0x00002000
#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.y b/libs/vkd3d-shader/hlsl.y index 0d9946731..8afcf4ca6 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5132,6 +5132,9 @@ func_prototype_no_attrs: struct hlsl_ir_var *var; struct hlsl_type *type;
+ /* Functions are unconditionally inlined. */ + modifiers &= ~HLSL_MODIFIER_INLINE; + if (modifiers & ~HLSL_MODIFIERS_MAJORITY_MASK) hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Only majority modifiers are allowed on functions."); @@ -5973,6 +5976,10 @@ var_modifiers: { $$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN | HLSL_STORAGE_OUT, &@1); } + | KW_INLINE var_modifiers + { + $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_INLINE, &@1); + }
complex_initializer: diff --git a/tests/hlsl/function.shader_test b/tests/hlsl/function.shader_test index 9573d0a9c..0db0477ed 100644 --- a/tests/hlsl/function.shader_test +++ b/tests/hlsl/function.shader_test @@ -298,7 +298,7 @@ probe all rgba (2.0, 3.0, 6.0, 7.0)
% Inline modifier
-[pixel shader todo] +[pixel shader] inline float func(float a) { return a + 1; @@ -312,12 +312,12 @@ float4 main() : sv_target }
[test] -todo draw quad -todo probe all rgba (2.0, 3.0, 6.0, 7.0) +draw quad +probe all rgba (2.0, 3.0, 6.0, 7.0)
% Inline modifier used on entry point
-[pixel shader todo] +[pixel shader] float func(float a) { return a + 1; @@ -331,5 +331,5 @@ inline float4 main() : sv_target }
[test] -todo draw quad -todo probe all rgba (2.0, 3.0, 6.0, 7.0) +draw quad +probe all rgba (2.0, 3.0, 6.0, 7.0)
Francisco Casas (@fcasas) commented about libs/vkd3d-shader/hlsl.y:
struct hlsl_ir_var *var; struct hlsl_type *type;
/* Functions are unconditionally inlined. */
modifiers &= ~HLSL_MODIFIER_INLINE;
if (modifiers & ~HLSL_MODIFIERS_MAJORITY_MASK) hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Only majority modifiers are allowed on functions.");
This error could be updated, since the "inline" modifier is also allowed. Still, as for now it doesn't seem to be a real reason to use it.
This merge request was approved by Francisco Casas.
This merge request was approved by Giovanni Mascellani.