-- v2: vkd3d-shader/hlsl: Ignore 'inline' modifier for functions. tests: Add some 'inline' function modifier tests.
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: 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
Signed-off-by: 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 75a1e6e4c..8bc72a8a2 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 2fd8ceb95..43ea4b4d0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5129,6 +5129,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."); @@ -5970,6 +5973,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)
Anything I should improve here?
This merge request was approved by Zebediah Figura.
Anything I should improve here?
No, I'm sorry, it just got overlooked.
This merge request was approved by Henri Verbeet.