From 51ad07d1fbffd41c758eba172aa77ebba3204924 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 23 Feb 2025 10:31:05 -0800 Subject: Improve performance when compiling small shaders. (#6396) Improve performance when compiling small shaders. Avoid copying witness table entries that are not getting used during linking. Avoid copying auto-diff related decorations and derivative functions during linking, if the user modules doesn't use autodiff. Cache operator overload resolution results on global session, so each new Session doesn't need to repetitively run through overload resolution from scratch. --- source/slang/core.meta.slang | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/slang/core.meta.slang') diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 267f7b2d4..da1b47e13 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -603,6 +603,7 @@ void static_assert(constexpr bool condition, NativeString errorMessage); /// /// __magic_type(DifferentiableType) +[KnownBuiltin("IDifferentiable")] interface IDifferentiable { // Note: the compiler implementation requires the `Differential` associated type to be defined @@ -645,6 +646,7 @@ interface IDifferentiable /// @remarks Support for this interface is still experimental and subject to change. /// __magic_type(DifferentiablePtrType) +[KnownBuiltin("IDifferentiablePtr")] interface IDifferentiablePtrType { __builtin_requirement($( (int)BuiltinRequirementKind::DifferentialPtrType) ) @@ -2598,20 +2600,20 @@ for(auto fixity : kIncDecFixities) $(fixity.qual) __generic [__unsafeForceInlineEarly] -T operator$(op.name)(in out T value) -{$(fixity.bodyPrefix) value = value $(op.binOp) T(1); return $(fixity.returnVal); } +T operator$(op.name)( in out T value) +{ $(fixity.bodyPrefix) value = value $(op.binOp) __builtin_cast(1); return $(fixity.returnVal); } $(fixity.qual) __generic [__unsafeForceInlineEarly] vector operator$(op.name)(in out vector value) -{$(fixity.bodyPrefix) value = value $(op.binOp) T(1); return $(fixity.returnVal); } +{$(fixity.bodyPrefix) value = value $(op.binOp) __builtin_cast(1); return $(fixity.returnVal); } $(fixity.qual) __generic [__unsafeForceInlineEarly] matrix operator$(op.name)(in out matrix value) -{$(fixity.bodyPrefix) value = value $(op.binOp) T(1); return $(fixity.returnVal); } +{$(fixity.bodyPrefix) value = value $(op.binOp) __builtin_cast(1); return $(fixity.returnVal); } $(fixity.qual) __generic -- cgit v1.2.3