From ac66eb78275d1df7b2bd66efc79064ac6ddc72bd Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 17 Dec 2023 02:41:14 +0100 Subject: [PATCH] Add RequiresDoublePrecisionSupportAttribute --- .../RequiresDoublePrecisionSupportAttribute.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/ComputeSharp/Attributes/RequiresDoublePrecisionSupportAttribute.cs diff --git a/src/ComputeSharp/Attributes/RequiresDoublePrecisionSupportAttribute.cs b/src/ComputeSharp/Attributes/RequiresDoublePrecisionSupportAttribute.cs new file mode 100644 index 00000000..baf75a5e --- /dev/null +++ b/src/ComputeSharp/Attributes/RequiresDoublePrecisionSupportAttribute.cs @@ -0,0 +1,16 @@ +using System; + +namespace ComputeSharp; + +/// +/// An attribute for a compute shader indicating that the shader requires support for double precision operations. +/// +/// +/// This attribute does not map to any HLSL feature or compile option directly, but it is needed to make using double +/// precision operations opt-in. It is easy to accidentally introduce them in a shader when that is not intented, and +/// doing so can make the shader run slower and not being compatible with some GPUs (eg. many arm64 GPUs lack support +/// for double precision operations). To avoid this, support is disabled by default, and it is necessary to add this +/// attribute over a shader type to explicitly allow using these operations. +/// +[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)] +public sealed class RequiresDoublePrecisionSupportAttribute : Attribute; \ No newline at end of file