summaryrefslogtreecommitdiff
path: root/source/slang/core.meta.slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/core.meta.slang')
-rw-r--r--source/slang/core.meta.slang37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index afcff8e65..476279ab8 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -285,6 +285,13 @@ interface IDifferentiable
static Differential dmul(T, Differential);
};
+__magic_type(DifferentiablePtrType)
+interface IDifferentiablePtrType
+{
+ __builtin_requirement($( (int)BuiltinRequirementKind::DifferentialPtrType) )
+ associatedtype Differential : IDifferentiablePtrType;
+};
+
/// Pair type that serves to wrap the primal and
/// differential types of an arbitrary type T.
@@ -357,6 +364,36 @@ struct DifferentialPair : IDifferentiable
}
};
+__generic<T : IDifferentiablePtrType>
+__magic_type(DifferentialPtrPairType)
+__intrinsic_type($(kIROp_DifferentialPtrPairType))
+struct DifferentialPtrPair : IDifferentiablePtrType
+{
+ typedef DifferentialPtrPair<T.Differential> Differential;
+ typedef T.Differential DifferentialElementType;
+
+ __intrinsic_op($(kIROp_MakeDifferentialPtrPair))
+ __init(T _primal, T.Differential _differential);
+
+ property p : T
+ {
+ __intrinsic_op($(kIROp_DifferentialPtrPairGetPrimal))
+ get;
+ }
+
+ property v : T
+ {
+ __intrinsic_op($(kIROp_DifferentialPtrPairGetPrimal))
+ get;
+ }
+
+ property d : T.Differential
+ {
+ __intrinsic_op($(kIROp_DifferentialPtrPairGetDifferential))
+ get;
+ }
+};
+
/// A type that uses a floating-point representation
[sealed]