diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 75a1e6e4..8bc72a8a 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 2fd8ceb9..43ea4b4d 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 9573d0a9..0db0477e 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)