extern alias Core; extern alias D2D1; using System; using System.Collections.Generic; using System.Collections.Immutable; using System.IO; using System.Linq; using System.Threading.Tasks; using Basic.Reference.Assemblies; using ComputeSharp.D2D1.SourceGenerators; using ComputeSharp.Tests.SourceGenerators.Helpers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace ComputeSharp.D2D1.Tests.SourceGenerators; [TestClass] public class Test_D2DPixelShaderSourceGenerator { [TestMethod] public async Task SimpleShader() { const string source = """ using ComputeSharp; using ComputeSharp.D2D1; using int2 = global::ComputeSharp.Int2; using float2 = global::ComputeSharp.Float2; using float3 = global::ComputeSharp.Float3; using float4 = global::ComputeSharp.Float4; namespace MyNamespace; [D2DInputCount(0)] [D2DRequiresScenePosition] [D2DGeneratedPixelShaderDescriptor] internal readonly partial struct MyShader : ID2D1PixelShader { private readonly float time; private readonly int2 dispatchSize; public float4 Execute() { int2 xy = (int2)D2D.GetScenePosition().XY; float2 uv = xy / (float2)this.dispatchSize; float3 col = 0.5f + (0.5f * Hlsl.Cos(this.time + new float3(uv, uv.X) + new float3(0, 2, 4))); return new(col, 1f); } } """; const string result = """" // #pragma warning disable namespace MyNamespace { /// partial struct MyShader : global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor { /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ref readonly global::System.Guid global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectId { [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] get { global::System.ReadOnlySpan bytes = [ 0xF4, 0xE8, 0x90, 0x26, 0x36, 0xE8, 0x71, 0x89, 0x25, 0x1F, 0x69, 0xE1, 0x5F, 0x27, 0x60, 0xBE ]; return ref global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(bytes)); } } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDisplayName => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDescription => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectCategory => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectAuthor => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ConstantBufferSize => 12; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputTypes => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.PixelOptions => global::ComputeSharp.D2D1.D2D1PixelOptions.None; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.BufferPrecision => global::ComputeSharp.D2D1.D2D1BufferPrecision.Unknown; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ChannelDepth => global::ComputeSharp.D2D1.D2D1ChannelDepth.Default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.PixelShader50; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CompileOptions => global::ComputeSharp.D2D1.D2D1CompileOptions.Default | global::ComputeSharp.D2D1.D2D1CompileOptions.EnableLinking; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslSource => """ // ================================================ // AUTO GENERATED // ================================================ // This shader was created by ComputeSharp. // See: https://github.com/Sergio0694/ComputeSharp. #define D2D_INPUT_COUNT 0 #define D2D_REQUIRES_SCENE_POSITION #include "d2d1effecthelpers.hlsli" float time; int2 dispatchSize; D2D_PS_ENTRY(Execute) { int2 xy = (int2)D2DGetScenePosition().xy; float2 uv = xy / (float2)dispatchSize; float3 col = 0.5 + (0.5 * cos(time + float3(uv, uv.x) + float3(0, 2, 4))); return float4(col, 1.0); } """; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslBytecode => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe MyShader global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CreateFromConstantBuffer(global::System.ReadOnlySpan data) { ref readonly global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer = ref global::System.Runtime.InteropServices.MemoryMarshal.AsRef(data); return global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.ToManaged(in buffer); } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe void global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.LoadConstantBuffer(in MyShader shader, ref TLoader loader) { global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.FromManaged(in shader, out global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer); loader.LoadConstantBuffer(new global::System.ReadOnlySpan(&buffer, sizeof(global::ComputeSharp.D2D1.Generated.ConstantBuffer))); } } } namespace ComputeSharp.D2D1.Generated { using global::System.CodeDom.Compiler; using global::System.Diagnostics; using global::System.Diagnostics.CodeAnalysis; using global::System.Runtime.CompilerServices; using global::System.Runtime.InteropServices; /// /// A type representing the constant buffer native layout for . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] [StructLayout(LayoutKind.Explicit, Size = 12)] file struct ConstantBuffer { /// [FieldOffset(0)] public float time; /// [FieldOffset(4)] public int2 dispatchSize; } /// /// A type containing marshalling logic for the constant buffer in shaders of type . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] file static class ConstantBufferMarshaller { /// /// Marshals managed instances to native constant buffer data. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static void FromManaged(in global::MyNamespace.MyShader shader, out ConstantBuffer buffer) { buffer.time = shader.time(); buffer.dispatchSize = shader.dispatchSize(); } /// /// Marshals native constant buffer data to managed instances. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static global::MyNamespace.MyShader ToManaged(in ConstantBuffer buffer) { Unsafe.SkipInit(out global::MyNamespace.MyShader shader); shader.time() = buffer.time; shader.dispatchSize() = buffer.dispatchSize; return shader; } /// /// The input value. /// A mutable reference to . [UnsafeAccessor(UnsafeAccessorKind.Field)] private static extern ref float time(this ref readonly global::MyNamespace.MyShader value); /// /// The input value. /// A mutable reference to . [UnsafeAccessor(UnsafeAccessorKind.Field)] private static extern ref int2 dispatchSize(this ref readonly global::MyNamespace.MyShader value); } } """"; await VerifyGeneratedDiagnosticsAsync(source, ("MyNamespace.MyShader.g.cs", result)); } [TestMethod] public async Task SimpleShader_WithCompiledHlslBytecode() { const string source = """ using ComputeSharp; using ComputeSharp.D2D1; using int2 = global::ComputeSharp.Int2; using float2 = global::ComputeSharp.Float2; using float3 = global::ComputeSharp.Float3; using float4 = global::ComputeSharp.Float4; namespace MyNamespace; [D2DInputCount(0)] [D2DRequiresScenePosition] [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] [D2DGeneratedPixelShaderDescriptor] internal readonly partial struct MyShader : ID2D1PixelShader { private readonly float time; private readonly int2 dispatchSize; public float4 Execute() { int2 xy = (int2)D2D.GetScenePosition().XY; float2 uv = xy / (float2)this.dispatchSize; float3 col = 0.5f + (0.5f * Hlsl.Cos(this.time + new float3(uv, uv.X) + new float3(0, 2, 4))); return new(col, 1f); } } """; const string result = """" // #pragma warning disable namespace MyNamespace { /// partial struct MyShader : global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor { /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ref readonly global::System.Guid global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectId { [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] get { global::System.ReadOnlySpan bytes = [ 0xF4, 0xE8, 0x90, 0x26, 0x36, 0xE8, 0x71, 0x89, 0x25, 0x1F, 0x69, 0xE1, 0x5F, 0x27, 0x60, 0xBE ]; return ref global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(bytes)); } } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDisplayName => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDescription => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectCategory => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectAuthor => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ConstantBufferSize => 12; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputTypes => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.PixelOptions => global::ComputeSharp.D2D1.D2D1PixelOptions.None; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.BufferPrecision => global::ComputeSharp.D2D1.D2D1BufferPrecision.Unknown; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ChannelDepth => global::ComputeSharp.D2D1.D2D1ChannelDepth.Default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.PixelShader50; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CompileOptions => global::ComputeSharp.D2D1.D2D1CompileOptions.Default | global::ComputeSharp.D2D1.D2D1CompileOptions.EnableLinking; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslSource => """ // ================================================ // AUTO GENERATED // ================================================ // This shader was created by ComputeSharp. // See: https://github.com/Sergio0694/ComputeSharp. #define D2D_INPUT_COUNT 0 #define D2D_REQUIRES_SCENE_POSITION #include "d2d1effecthelpers.hlsli" float time; int2 dispatchSize; D2D_PS_ENTRY(Execute) { int2 xy = (int2)D2DGetScenePosition().xy; float2 uv = xy / (float2)dispatchSize; float3 col = 0.5 + (0.5 * cos(time + float3(uv, uv.x) + float3(0, 2, 4))); return float4(col, 1.0); } """; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslBytecode => global::ComputeSharp.D2D1.Generated.HlslBytecodeMemoryManager.Instance.Memory; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe MyShader global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CreateFromConstantBuffer(global::System.ReadOnlySpan data) { ref readonly global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer = ref global::System.Runtime.InteropServices.MemoryMarshal.AsRef(data); return global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.ToManaged(in buffer); } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe void global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.LoadConstantBuffer(in MyShader shader, ref TLoader loader) { global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.FromManaged(in shader, out global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer); loader.LoadConstantBuffer(new global::System.ReadOnlySpan(&buffer, sizeof(global::ComputeSharp.D2D1.Generated.ConstantBuffer))); } } } namespace ComputeSharp.D2D1.Generated { using global::System; using global::System.Buffers; using global::System.CodeDom.Compiler; using global::System.Diagnostics; using global::System.Diagnostics.CodeAnalysis; using global::System.Runtime.CompilerServices; using global::System.Runtime.InteropServices; /// /// A type representing the constant buffer native layout for . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] [StructLayout(LayoutKind.Explicit, Size = 12)] file struct ConstantBuffer { /// [FieldOffset(0)] public float time; /// [FieldOffset(4)] public int2 dispatchSize; } /// /// A type containing marshalling logic for the constant buffer in shaders of type . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] file static class ConstantBufferMarshaller { /// /// Marshals managed instances to native constant buffer data. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static void FromManaged(in global::MyNamespace.MyShader shader, out ConstantBuffer buffer) { buffer.time = shader.time(); buffer.dispatchSize = shader.dispatchSize(); } /// /// Marshals native constant buffer data to managed instances. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static global::MyNamespace.MyShader ToManaged(in ConstantBuffer buffer) { Unsafe.SkipInit(out global::MyNamespace.MyShader shader); shader.time() = buffer.time; shader.dispatchSize() = buffer.dispatchSize; return shader; } /// /// The input value. /// A mutable reference to . [UnsafeAccessor(UnsafeAccessorKind.Field)] private static extern ref float time(this ref readonly global::MyNamespace.MyShader value); /// /// The input value. /// A mutable reference to . [UnsafeAccessor(UnsafeAccessorKind.Field)] private static extern ref int2 dispatchSize(this ref readonly global::MyNamespace.MyShader value); } /// /// implementation to get the HLSL bytecode. /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] file sealed class HlslBytecodeMemoryManager : MemoryManager { /// The singleton instance to use. public static readonly HlslBytecodeMemoryManager Instance = new(); /// The RVA data with the HLSL bytecode. private static ReadOnlySpan Data => [0x44, 0x58, 0x42, 0x43, 0x00, 0x7E, 0x4F, 0xA0, 0xD0, 0x90, 0x42, 0x20, 0xBA, 0x51, 0xF0, 0x59, 0x1A, 0x83, 0x95, 0x27, 0x01, 0x00, 0x00, 0x00, 0xB7, 0x08, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xA0, 0x01, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x00, 0x30, 0x02, 0x00, 0x00, 0x70, 0x03, 0x00, 0x00, 0x0C, 0x04, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x60, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0x08, 0x81, 0x04, 0x00, 0x38, 0x01, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x00, 0xAB, 0xAB, 0xAB, 0x5C, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6D, 0x65, 0x00, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x00, 0xAB, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5, 0x00, 0x00, 0x00, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x53, 0x69, 0x7A, 0x65, 0x00, 0x69, 0x6E, 0x74, 0x32, 0x00, 0xAB, 0xAB, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x01, 0x00, 0x00, 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4C, 0x53, 0x4C, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x69, 0x6C, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2E, 0x31, 0x00, 0x49, 0x53, 0x47, 0x4E, 0x54, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5F, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x4F, 0x4E, 0x00, 0x53, 0x43, 0x45, 0x4E, 0x45, 0x5F, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x4F, 0x4E, 0x00, 0xAB, 0x4F, 0x53, 0x47, 0x4E, 0x2C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5F, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xAB, 0xAB, 0x53, 0x48, 0x45, 0x58, 0x38, 0x01, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x00, 0x00, 0x6A, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x05, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x06, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x85, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x00, 0x06, 0x00, 0xD0, 0x00, 0x00, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0F, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x3E, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x52, 0x49, 0x56, 0xA3, 0x04, 0x00, 0x00, 0x44, 0x58, 0x42, 0x43, 0x77, 0xD5, 0x53, 0x7B, 0x34, 0xFD, 0x69, 0xC9, 0x7D, 0xA1, 0x85, 0x94, 0xB1, 0x52, 0x5A, 0xD7, 0x01, 0x00, 0x00, 0x00, 0xA3, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x48, 0x04, 0x00, 0x00, 0x4C, 0x49, 0x42, 0x46, 0x18, 0x04, 0x00, 0x00, 0x44, 0x58, 0x42, 0x43, 0x03, 0xE1, 0xA2, 0x41, 0x4F, 0x11, 0x4D, 0xCB, 0x79, 0x2A, 0xB6, 0x76, 0xCD, 0xD1, 0x6C, 0xF7, 0x01, 0x00, 0x00, 0x00, 0x18, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x98, 0x01, 0x00, 0x00, 0x3C, 0x02, 0x00, 0x00, 0x7C, 0x03, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x60, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x05, 0x46, 0x4C, 0x08, 0x81, 0x04, 0x00, 0x38, 0x01, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x00, 0xAB, 0xAB, 0xAB, 0x5C, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6D, 0x65, 0x00, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x00, 0xAB, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5, 0x00, 0x00, 0x00, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x53, 0x69, 0x7A, 0x65, 0x00, 0x69, 0x6E, 0x74, 0x32, 0x00, 0xAB, 0xAB, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x01, 0x00, 0x00, 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4C, 0x53, 0x4C, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x69, 0x6C, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2E, 0x31, 0x00, 0x4C, 0x46, 0x53, 0x30, 0x9C, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x8B, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x44, 0x32, 0x44, 0x5F, 0x66, 0x75, 0x6E, 0x63, 0x5F, 0x65, 0x6E, 0x74, 0x72, 0x79, 0x00, 0x5F, 0x5F, 0x64, 0x32, 0x64, 0x69, 0x6E, 0x70, 0x75, 0x74, 0x5F, 0x73, 0x63, 0x65, 0x6E, 0x65, 0x50, 0x6F, 0x73, 0x00, 0x53, 0x43, 0x45, 0x4E, 0x45, 0x5F, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x4F, 0x4E, 0x00, 0xAB, 0xAB, 0x53, 0x48, 0x45, 0x58, 0x38, 0x01, 0x00, 0x00, 0x50, 0x00, 0xF0, 0xFF, 0x4E, 0x00, 0x00, 0x00, 0x6A, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x05, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x06, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x85, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x00, 0x06, 0x00, 0xD0, 0x00, 0x00, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0F, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x3E, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x42, 0x48, 0x53, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4C, 0x53, 0x4C, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x69, 0x6C, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2E, 0x31, 0x00, 0x44, 0x32, 0x44, 0x5F, 0x66, 0x75, 0x6E, 0x63, 0x5F, 0x65, 0x6E, 0x74, 0x72, 0x79, 0x00]; /// public override unsafe Span GetSpan() { return new(Unsafe.AsPointer(ref MemoryMarshal.GetReference(Data)), Data.Length); } /// public override Memory Memory { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => CreateMemory(Data.Length); } /// public override unsafe MemoryHandle Pin(int elementIndex) { return new(Unsafe.AsPointer(ref Unsafe.AsRef(in Data[elementIndex])), pinnable: this); } /// public override void Unpin() { } /// protected override void Dispose(bool disposing) { } } } """"; await VerifyGeneratedDiagnosticsAsync(source, ("MyNamespace.MyShader.g.cs", result)); } [TestMethod] public async Task SimpleShader_WithEffectMetadata() { const string source = """ using ComputeSharp; using ComputeSharp.D2D1; using int2 = global::ComputeSharp.Int2; using float2 = global::ComputeSharp.Float2; using float3 = global::ComputeSharp.Float3; using float4 = global::ComputeSharp.Float4; namespace MyNamespace; [D2DEffectId("B30E1384-DEE1-4200-9312-321521DF3B00")] [D2DEffectDisplayName(nameof(MyShader))] [D2DEffectDescription("A hello world effect that displays a color gradient.")] [D2DEffectCategory("Render")] [D2DEffectAuthor("ComputeSharp.D2D1")] [D2DInputCount(0)] [D2DRequiresScenePosition] [D2DGeneratedPixelShaderDescriptor] internal readonly partial struct MyShader : ID2D1PixelShader { private readonly float time; private readonly int2 dispatchSize; public float4 Execute() { int2 xy = (int2)D2D.GetScenePosition().XY; float2 uv = xy / (float2)this.dispatchSize; float3 col = 0.5f + (0.5f * Hlsl.Cos(this.time + new float3(uv, uv.X) + new float3(0, 2, 4))); return new(col, 1f); } } """; const string result = """" // #pragma warning disable namespace MyNamespace { /// partial struct MyShader : global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor { /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ref readonly global::System.Guid global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectId { [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] get { global::System.ReadOnlySpan bytes = [ 0x84, 0x13, 0x0E, 0xB3, 0xE1, 0xDE, 0x00, 0x42, 0x93, 0x12, 0x32, 0x15, 0x21, 0xDF, 0x3B, 0x00 ]; return ref global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(bytes)); } } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDisplayName => "MyShader"; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDescription => "A hello world effect that displays a color gradient."; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectCategory => "Render"; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectAuthor => "ComputeSharp.D2D1"; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ConstantBufferSize => 12; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputTypes => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.PixelOptions => global::ComputeSharp.D2D1.D2D1PixelOptions.None; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.BufferPrecision => global::ComputeSharp.D2D1.D2D1BufferPrecision.Unknown; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ChannelDepth => global::ComputeSharp.D2D1.D2D1ChannelDepth.Default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.PixelShader50; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CompileOptions => global::ComputeSharp.D2D1.D2D1CompileOptions.Default | global::ComputeSharp.D2D1.D2D1CompileOptions.EnableLinking; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslSource => """ // ================================================ // AUTO GENERATED // ================================================ // This shader was created by ComputeSharp. // See: https://github.com/Sergio0694/ComputeSharp. #define D2D_INPUT_COUNT 0 #define D2D_REQUIRES_SCENE_POSITION #include "d2d1effecthelpers.hlsli" float time; int2 dispatchSize; D2D_PS_ENTRY(Execute) { int2 xy = (int2)D2DGetScenePosition().xy; float2 uv = xy / (float2)dispatchSize; float3 col = 0.5 + (0.5 * cos(time + float3(uv, uv.x) + float3(0, 2, 4))); return float4(col, 1.0); } """; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslBytecode => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe MyShader global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CreateFromConstantBuffer(global::System.ReadOnlySpan data) { ref readonly global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer = ref global::System.Runtime.InteropServices.MemoryMarshal.AsRef(data); return global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.ToManaged(in buffer); } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe void global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.LoadConstantBuffer(in MyShader shader, ref TLoader loader) { global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.FromManaged(in shader, out global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer); loader.LoadConstantBuffer(new global::System.ReadOnlySpan(&buffer, sizeof(global::ComputeSharp.D2D1.Generated.ConstantBuffer))); } } } namespace ComputeSharp.D2D1.Generated { using global::System.CodeDom.Compiler; using global::System.Diagnostics; using global::System.Diagnostics.CodeAnalysis; using global::System.Runtime.CompilerServices; using global::System.Runtime.InteropServices; /// /// A type representing the constant buffer native layout for . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] [StructLayout(LayoutKind.Explicit, Size = 12)] file struct ConstantBuffer { /// [FieldOffset(0)] public float time; /// [FieldOffset(4)] public int2 dispatchSize; } /// /// A type containing marshalling logic for the constant buffer in shaders of type . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] file static class ConstantBufferMarshaller { /// /// Marshals managed instances to native constant buffer data. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static void FromManaged(in global::MyNamespace.MyShader shader, out ConstantBuffer buffer) { buffer.time = shader.time(); buffer.dispatchSize = shader.dispatchSize(); } /// /// Marshals native constant buffer data to managed instances. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static global::MyNamespace.MyShader ToManaged(in ConstantBuffer buffer) { Unsafe.SkipInit(out global::MyNamespace.MyShader shader); shader.time() = buffer.time; shader.dispatchSize() = buffer.dispatchSize; return shader; } /// /// The input value. /// A mutable reference to . [UnsafeAccessor(UnsafeAccessorKind.Field)] private static extern ref float time(this ref readonly global::MyNamespace.MyShader value); /// /// The input value. /// A mutable reference to . [UnsafeAccessor(UnsafeAccessorKind.Field)] private static extern ref int2 dispatchSize(this ref readonly global::MyNamespace.MyShader value); } } """"; await VerifyGeneratedDiagnosticsAsync(source, ("MyNamespace.MyShader.g.cs", result)); } [TestMethod] public async Task SimpleShader_WithPrimaryConstructorParameters() { const string source = """ using ComputeSharp; using ComputeSharp.D2D1; using int2 = global::ComputeSharp.Int2; using float2 = global::ComputeSharp.Float2; using float3 = global::ComputeSharp.Float3; using float4 = global::ComputeSharp.Float4; namespace MyNamespace; [D2DInputCount(0)] [D2DRequiresScenePosition] [D2DGeneratedPixelShaderDescriptor] internal readonly partial struct MyShader(float time, int2 dispatchSize) : ID2D1PixelShader { public float4 Execute() { int2 xy = (int2)D2D.GetScenePosition().XY; float2 uv = xy / (float2)dispatchSize; float3 col = 0.5f + (0.5f * Hlsl.Cos(time + new float3(uv, uv.X) + new float3(0, 2, 4))); return new(col, 1f); } } """; const string result = """" // #pragma warning disable namespace MyNamespace { /// partial struct MyShader : global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor { /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ref readonly global::System.Guid global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectId { [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] get { global::System.ReadOnlySpan bytes = [ 0xF4, 0xE8, 0x90, 0x26, 0x36, 0xE8, 0x71, 0x89, 0x25, 0x1F, 0x69, 0xE1, 0x5F, 0x27, 0x60, 0xBE ]; return ref global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(bytes)); } } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDisplayName => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectDescription => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectCategory => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.EffectAuthor => null; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ConstantBufferSize => 12; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureCount => 0; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputTypes => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.InputDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ResourceTextureDescriptions => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.PixelOptions => global::ComputeSharp.D2D1.D2D1PixelOptions.None; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.BufferPrecision => global::ComputeSharp.D2D1.D2D1BufferPrecision.Unknown; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ChannelDepth => global::ComputeSharp.D2D1.D2D1ChannelDepth.Default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.PixelShader50; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CompileOptions => global::ComputeSharp.D2D1.D2D1CompileOptions.Default | global::ComputeSharp.D2D1.D2D1CompileOptions.EnableLinking; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static string global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslSource => """ // ================================================ // AUTO GENERATED // ================================================ // This shader was created by ComputeSharp. // See: https://github.com/Sergio0694/ComputeSharp. #define D2D_INPUT_COUNT 0 #define D2D_REQUIRES_SCENE_POSITION #include "d2d1effecthelpers.hlsli" float time; int2 dispatchSize; D2D_PS_ENTRY(Execute) { int2 xy = (int2)D2DGetScenePosition().xy; float2 uv = xy / (float2)dispatchSize; float3 col = 0.5 + (0.5 * cos(time + float3(uv, uv.x) + float3(0, 2, 4))); return float4(col, 1.0); } """; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.HlslBytecode => default; /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe MyShader global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.CreateFromConstantBuffer(global::System.ReadOnlySpan data) { ref readonly global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer = ref global::System.Runtime.InteropServices.MemoryMarshal.AsRef(data); return global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.ToManaged(in buffer); } /// [global::System.CodeDom.Compiler.GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [global::System.Runtime.CompilerServices.SkipLocalsInit] static unsafe void global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor.LoadConstantBuffer(in MyShader shader, ref TLoader loader) { global::ComputeSharp.D2D1.Generated.ConstantBufferMarshaller.FromManaged(in shader, out global::ComputeSharp.D2D1.Generated.ConstantBuffer buffer); loader.LoadConstantBuffer(new global::System.ReadOnlySpan(&buffer, sizeof(global::ComputeSharp.D2D1.Generated.ConstantBuffer))); } } } namespace ComputeSharp.D2D1.Generated { using global::System.CodeDom.Compiler; using global::System.Diagnostics; using global::System.Diagnostics.CodeAnalysis; using global::System.Runtime.CompilerServices; using global::System.Runtime.InteropServices; /// /// A type representing the constant buffer native layout for . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] [StructLayout(LayoutKind.Explicit, Size = 12)] file struct ConstantBuffer { /// The unspeakable field "time" of . [FieldOffset(0)] public float time; /// The unspeakable field "dispatchSize" of . [FieldOffset(4)] public int2 dispatchSize; } /// /// A type containing marshalling logic for the constant buffer in shaders of type . /// [GeneratedCode("ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator", )] [DebuggerNonUserCode] [ExcludeFromCodeCoverage] file static class ConstantBufferMarshaller { /// /// Marshals managed instances to native constant buffer data. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static void FromManaged(in global::MyNamespace.MyShader shader, out ConstantBuffer buffer) { buffer.time = shader.time(); buffer.dispatchSize = shader.dispatchSize(); } /// /// Marshals native constant buffer data to managed instances. /// /// The input native constant buffer. /// The marshalled instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] [SkipLocalsInit] public static global::MyNamespace.MyShader ToManaged(in ConstantBuffer buffer) { Unsafe.SkipInit(out global::MyNamespace.MyShader shader); shader.time() = buffer.time; shader.dispatchSize() = buffer.dispatchSize; return shader; } /// Gets a reference to the unspeakable field "time" of type . /// The input value. /// A mutable reference to the unspeakable field "time". [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "