diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs index dd2e7f86..91ea3a83 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.cs @@ -29,15 +29,17 @@ partial class D2DPixelShaderDescriptorGenerator /// The collection of produced instances. /// The input object currently in use. /// The for the shader type. + /// The shader interface type implemented by the shader type. /// The number of inputs for the shader. - /// The indicess of the simple shader inputs. - /// The indicess of the complex shader inputs. + /// The indices of the simple shader inputs. + /// The indices of the complex shader inputs. /// The used to cancel the operation, if needed. /// The HLSL source for the shader. public static string GetHlslSource( ImmutableArrayBuilder diagnostics, Compilation compilation, INamedTypeSymbol structDeclarationSymbol, + INamedTypeSymbol shaderInterfaceType, int inputCount, ImmutableArray inputSimpleIndices, ImmutableArray inputComplexIndices, @@ -46,6 +48,8 @@ partial class D2DPixelShaderDescriptorGenerator // Detect any invalid properties HlslDefinitionsSyntaxProcessor.DetectAndReportInvalidPropertyDeclarations(diagnostics, structDeclarationSymbol); + token.ThrowIfCancellationRequested(); + // We need to sets to track all discovered custom types and static methods HashSet discoveredTypes = new(SymbolEqualityComparer.Default); Dictionary staticMethods = new(SymbolEqualityComparer.Default); @@ -72,6 +76,7 @@ partial class D2DPixelShaderDescriptorGenerator (string entryPoint, ImmutableArray processedMethods) = GetProcessedMethods( diagnostics, structDeclarationSymbol, + shaderInterfaceType, semanticModelProvider, discoveredTypes, staticMethods, @@ -302,6 +307,7 @@ partial class D2DPixelShaderDescriptorGenerator /// /// The collection of produced instances. /// The type symbol for the shader type. + /// The shader interface type implemented by the shader type. /// The instance for the type to process. /// The collection of currently discovered types. /// The set of discovered and processed static methods. @@ -315,6 +321,7 @@ partial class D2DPixelShaderDescriptorGenerator private static (string EntryPoint, ImmutableArray Methods) GetProcessedMethods( ImmutableArrayBuilder diagnostics, INamedTypeSymbol structDeclarationSymbol, + INamedTypeSymbol shaderInterfaceType, SemanticModelProvider semanticModel, ICollection discoveredTypes, IDictionary staticMethods, @@ -327,6 +334,7 @@ partial class D2DPixelShaderDescriptorGenerator { using ImmutableArrayBuilder methods = new(); + IMethodSymbol entryPointInterfaceMethod = shaderInterfaceType.GetMethod("Execute")!; string? entryPoint = null; // By default, the scene position is not required. We will set this while @@ -341,16 +349,17 @@ partial class D2DPixelShaderDescriptorGenerator continue; } + // Ensure that we have accessible source information if (!methodSymbol.TryGetSyntaxNode(token, out MethodDeclarationSyntax? methodDeclaration)) { continue; } - bool isShaderEntryPoint = - methodSymbol.Name == "Execute" && - methodSymbol.ReturnType.HasFullyQualifiedMetadataName("ComputeSharp.Float4") && - methodSymbol.TypeParameters.Length == 0 && - methodSymbol.Parameters.Length == 0; + // Check whether the current method is the entry point (ie. it's implementing 'Execute'). + // This is the same logic as in the DX12 generator for compute shaders and pixel shaders. + bool isShaderEntryPoint = SymbolEqualityComparer.Default.Equals( + structDeclarationSymbol.FindImplementationForInterfaceMember(entryPointInterfaceMethod), + methodSymbol); // Except for the entry point, ignore explicit interface implementations if (!isShaderEntryPoint && !methodSymbol.ExplicitInterfaceImplementations.IsDefaultOrEmpty) @@ -460,8 +469,8 @@ partial class D2DPixelShaderDescriptorGenerator /// /// The body of the entry point of the shader. /// The number of shader inputs to declare. - /// The indicess of the simple shader inputs. - /// The indicess of the complex shader inputs. + /// The indices of the simple shader inputs. + /// The indices of the complex shader inputs. /// Whether the shader requires the scene position. /// The series of statements to build the HLSL source to compile to execute the current shader. private static string GetHlslSource( diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs index e3b47480..40f6ca7a 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs @@ -53,8 +53,10 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene return default; } + INamedTypeSymbol shaderInterfaceType = context.SemanticModel.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.ID2D1PixelShader")!; + // Check that the shader implements the ID2D1PixelShader interface - if (!typeSymbol.HasInterfaceWithType(context.SemanticModel.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.ID2D1PixelShader")!)) + if (!typeSymbol.HasInterfaceWithType(shaderInterfaceType)) { return default; } @@ -142,6 +144,7 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene diagnostics, context.SemanticModel.Compilation, typeSymbol, + shaderInterfaceType, inputCount, inputSimpleIndices, inputComplexIndices, diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index 685435fa..ba7b50ef 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -154,14 +154,23 @@ internal sealed partial class ShaderSourceRewriter( Diagnostics.Add(UnsafeModifierOnMethodOrFunction, node); } - if (updatedNode is not null) + // Add the tracked implicit declarations (at the start of the body). + // To optimize, we only do this if we do have any implicit variables. + if (this.implicitVariables.Count > 0) { BlockSyntax implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray()); - // Add the tracked implicit declarations (at the start of the body) updatedNode = updatedNode.WithBody(implicitBlock).AddBodyStatements([.. updatedNode.Body!.Statements]); } + // The entry point might be an explicit interface method implementation. In that case, + // the transpiled method will have the rewritten interface name as a prefix for the + // method name, which we don't want (it's invalid HLSL). So in that case, remove it. + if (this.isEntryPoint && updatedNode.ExplicitInterfaceSpecifier is not null) + { + updatedNode = updatedNode.WithExplicitInterfaceSpecifier(null); + } + return updatedNode; } diff --git a/src/ComputeSharp.SourceGeneration/Extensions/ITypeSymbolExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/ITypeSymbolExtensions.cs index 9eaf22f8..440a2503 100644 --- a/src/ComputeSharp.SourceGeneration/Extensions/ITypeSymbolExtensions.cs +++ b/src/ComputeSharp.SourceGeneration/Extensions/ITypeSymbolExtensions.cs @@ -9,6 +9,26 @@ namespace ComputeSharp.SourceGeneration.Extensions; /// internal static class ITypeSymbolExtensions { + /// + /// Gets the method of this symbol that have a particular name. + /// + /// The input instance to check. + /// The name of the method to find. + /// The target method, if present. + public static IMethodSymbol? GetMethod(this ITypeSymbol symbol, string name) + { + foreach (ISymbol memberSymbol in symbol.GetMembers(name)) + { + if (memberSymbol is IMethodSymbol methodSymbol && + memberSymbol.Name == name) + { + return methodSymbol; + } + } + + return null; + } + /// /// Checks whether or not a given type symbol has a specified fully qualified metadata name. /// @@ -28,7 +48,7 @@ internal static class ITypeSymbolExtensions /// Checks whether or not a given implements an interface of a specified type. /// /// The target instance to check. - /// The instane to check for inheritance from. + /// The instance to check for inheritance from. /// Whether or not has an interface of type . public static bool HasInterfaceWithType(this ITypeSymbol typeSymbol, ITypeSymbol interfaceSymbol) { diff --git a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.Helpers.cs b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.Helpers.cs index 2eb8d6a5..a16a9bf8 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.Helpers.cs +++ b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.Helpers.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace ComputeSharp.SourceGenerators; @@ -10,9 +11,14 @@ partial class ComputeShaderDescriptorGenerator /// /// The input instance to check. /// The instance currently in use. + /// The (constructed) shader interface type implemented by the shader type. /// Whether is a "pixel shader like" type. /// Whether is a compute shader type at all. - private static bool TryGetIsPixelShaderLike(INamedTypeSymbol typeSymbol, Compilation compilation, out bool isPixelShaderLike) + private static bool TryGetIsPixelShaderLike( + INamedTypeSymbol typeSymbol, + Compilation compilation, + [NotNullWhen(true)] out INamedTypeSymbol? shaderInterfaceType, + out bool isPixelShaderLike) { INamedTypeSymbol computeShaderSymbol = compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader")!; INamedTypeSymbol pixelShaderSymbol = compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader`1")!; @@ -21,18 +27,21 @@ partial class ComputeShaderDescriptorGenerator { if (SymbolEqualityComparer.Default.Equals(interfaceSymbol, computeShaderSymbol)) { + shaderInterfaceType = interfaceSymbol; isPixelShaderLike = false; return true; } else if (SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, pixelShaderSymbol)) { + shaderInterfaceType = interfaceSymbol; isPixelShaderLike = true; return true; } } + shaderInterfaceType = null; isPixelShaderLike = false; return false; diff --git a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs index a44e4464..1821dbdd 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs +++ b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.HlslSource.cs @@ -31,6 +31,8 @@ partial class ComputeShaderDescriptorGenerator /// The collection of produced instances. /// The input object currently in use. /// The for the shader type. + /// The shader interface type implemented by the shader type. + /// Whether is a "pixel shader like" type. /// The thread ids value for the X axis. /// The thread ids value for the Y axis. /// The thread ids value for the Z axis. @@ -42,6 +44,8 @@ partial class ComputeShaderDescriptorGenerator ImmutableArrayBuilder diagnostics, Compilation compilation, INamedTypeSymbol structDeclarationSymbol, + INamedTypeSymbol shaderInterfaceType, + bool isPixelShaderLike, int threadsX, int threadsY, int threadsZ, @@ -53,6 +57,8 @@ partial class ComputeShaderDescriptorGenerator // Detect any invalid properties HlslDefinitionsSyntaxProcessor.DetectAndReportInvalidPropertyDeclarations(diagnostics, structDeclarationSymbol); + token.ThrowIfCancellationRequested(); + // We need to sets to track all discovered custom types and static methods HashSet discoveredTypes = new(SymbolEqualityComparer.Default); Dictionary staticMethods = new(SymbolEqualityComparer.Default); @@ -62,9 +68,8 @@ partial class ComputeShaderDescriptorGenerator Dictionary staticFieldDefinitions = new(SymbolEqualityComparer.Default); // Setup the semantic model and basic properties - INamedTypeSymbol? pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: "IComputeShader" }); - bool isComputeShader = pixelShaderSymbol is null; - string? implicitTextureType = isComputeShader ? null : HlslKnownTypes.GetMappedNameForPixelShaderType(pixelShaderSymbol!); + bool isComputeShader = !isPixelShaderLike; + string? implicitTextureType = HlslKnownTypes.GetMappedNameForPixelShaderType(shaderInterfaceType); token.ThrowIfCancellationRequested(); @@ -90,6 +95,7 @@ partial class ComputeShaderDescriptorGenerator (string entryPoint, ImmutableArray processedMethods, isSamplerUsed) = GetProcessedMethods( diagnostics, structDeclarationSymbol, + shaderInterfaceType, semanticModelProvider, discoveredTypes, staticMethods, @@ -360,6 +366,7 @@ partial class ComputeShaderDescriptorGenerator /// /// The collection of produced instances. /// The type symbol for the shader type. + /// The shader interface type implemented by the shader type. /// The instance for the type to process. /// The collection of currently discovered types. /// The set of discovered and processed static methods. @@ -373,6 +380,7 @@ partial class ComputeShaderDescriptorGenerator private static (string EntryPoint, ImmutableArray Methods, bool IsSamplerUser) GetProcessedMethods( ImmutableArrayBuilder diagnostics, INamedTypeSymbol structDeclarationSymbol, + INamedTypeSymbol shaderInterfaceType, SemanticModelProvider semanticModel, ICollection discoveredTypes, IDictionary staticMethods, @@ -385,6 +393,7 @@ partial class ComputeShaderDescriptorGenerator { using ImmutableArrayBuilder methods = new(); + IMethodSymbol entryPointInterfaceMethod = shaderInterfaceType.GetMethod("Execute")!; string? entryPoint = null; bool isSamplerUsed = false; @@ -396,22 +405,17 @@ partial class ComputeShaderDescriptorGenerator continue; } + // Ensure that we have accessible source information if (!methodSymbol.TryGetSyntaxNode(token, out MethodDeclarationSyntax? methodDeclaration)) { continue; } - bool isShaderEntryPoint = - (isComputeShader && - methodSymbol.Name == "Execute" && - methodSymbol.ReturnsVoid && - methodSymbol.TypeParameters.Length == 0 && - methodSymbol.Parameters.Length == 0) || - (!isComputeShader && - methodSymbol.Name == "Execute" && - methodSymbol.ReturnType is not null && // TODO: match for pixel type - methodSymbol.TypeParameters.Length == 0 && - methodSymbol.Parameters.Length == 0); + // Check whether the current method is the entry point (ie. it's implementing 'Execute'). We use + // 'FindImplementationForInterfaceMember' to handle explicit interface implementations as well. + bool isShaderEntryPoint = SymbolEqualityComparer.Default.Equals( + structDeclarationSymbol.FindImplementationForInterfaceMember(entryPointInterfaceMethod), + methodSymbol); // Except for the entry point, ignore explicit interface implementations if (!isShaderEntryPoint && !methodSymbol.ExplicitInterfaceImplementations.IsDefaultOrEmpty) diff --git a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs index 9fbceeb7..1ed99940 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs @@ -54,7 +54,11 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener } // Check whether type is a compute shader, and if so, if it's pixel shader like - if (!TryGetIsPixelShaderLike(typeSymbol, context.SemanticModel.Compilation, out bool isPixelShaderLike)) + if (!TryGetIsPixelShaderLike( + typeSymbol, + context.SemanticModel.Compilation, + out INamedTypeSymbol? shaderInterfaceType, + out bool isPixelShaderLike)) { return default; } @@ -91,6 +95,8 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener diagnostics, context.SemanticModel.Compilation, typeSymbol, + shaderInterfaceType, + isPixelShaderLike, threadsX, threadsY, threadsZ, diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs index 0eb7cb21..a1b013c1 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -208,11 +208,18 @@ partial class HlslKnownTypes /// /// Gets the mapped HLSL-compatible type name for the output texture of a pixel shader. /// - /// The pixel shader type to map. + /// The shader type to map. /// The HLSL-compatible type name that can be used in an HLSL shader. - public static string GetMappedNameForPixelShaderType(INamedTypeSymbol typeSymbol) + public static string? GetMappedNameForPixelShaderType(INamedTypeSymbol typeSymbol) { - string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments.First()).GetFullyQualifiedMetadataName(); + // If the shader type is not a pixel shader type (ie. it has a type argument), stop here. + // At this point the input is guaranteed to either be 'IComputeShader' or 'IComputeShader'. + if (typeSymbol.TypeArguments is not [INamedTypeSymbol pixelShaderType]) + { + return null; + } + + string genericArgumentName = pixelShaderType.GetFullyQualifiedMetadataName(); // If the current type is a custom type, format it as needed if (!KnownHlslTypeMetadataNames.TryGetValue(genericArgumentName, out string? mappedElementType)) diff --git a/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs b/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs index b1fab05a..6cd13fdf 100644 --- a/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs @@ -208,4 +208,33 @@ public partial class ShaderRewriterTests return new float4(0.0f, 1.0f, 0.0f, 1.0f); } } + + // See https://github.com/Sergio0694/ComputeSharp/issues/855 + [TestMethod] + public void ExplicitEntryPointMethodPixelShader_IsRewrittenCorrectly() + { + D2D1ShaderInfo shaderInfo = D2D1ReflectionServices.GetShaderInfo(); + + Assert.AreEqual(""" + #define D2D_INPUT_COUNT 0 + + #include "d2d1effecthelpers.hlsli" + + D2D_PS_ENTRY(Execute) + { + return (float4)0; + } + """, shaderInfo.HlslSource); + } + + [D2DInputCount(0)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] + [D2DGeneratedPixelShaderDescriptor] + internal readonly partial struct ExplicitEntryPointMethodPixelShader : ID2D1PixelShader + { + float4 ID2D1PixelShader.Execute() + { + return default; + } + } } \ No newline at end of file diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs index 3052e820..9ee52faf 100644 --- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs @@ -315,6 +315,31 @@ namespace ComputeSharp.Tests Assert.AreEqual(info.TextureStoreInstructionCount, 1u); Assert.AreEqual(info.BoundResourceCount, 2u); + Assert.AreEqual(""" + #define __GroupSize__get_X 8 + #define __GroupSize__get_Y 8 + #define __GroupSize__get_Z 1 + + cbuffer _ : register(b0) + { + uint __x; + uint __y; + } + + RWTexture2D __outputTexture : register(u0); + + [NumThreads(__GroupSize__get_X, __GroupSize__get_Y, __GroupSize__get_Z)] + void Execute(uint3 ThreadIds : SV_DispatchThreadID) + { + if (ThreadIds.x < __x && ThreadIds.y < __y) + { + { + __outputTexture[ThreadIds.xy] = float4(1, 1, 1, 1); + return; + } + } + } + """, info.HlslSource); } [ThreadGroupSize(DefaultThreadGroupSizes.XY)] diff --git a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs index b2c55d23..6208a34d 100644 --- a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs +++ b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs @@ -1559,4 +1559,100 @@ public partial class ShaderRewriterTests buffer[3] = mask2x3_r_or.M11 ? 1 : 0; } } + + // See https://github.com/Sergio0694/ComputeSharp/issues/855 + [TestMethod] + public void CompileExplicitEntryPointMethodComputeShader() + { + ShaderInfo info = ReflectionServices.GetShaderInfo(); + + Assert.AreEqual( + """ + #define __GroupSize__get_X 64 + #define __GroupSize__get_Y 1 + #define __GroupSize__get_Z 1 + + cbuffer _ : register(b0) + { + uint __x; + uint __y; + uint __z; + } + + RWStructuredBuffer __reserved__buffer : register(u0); + + [NumThreads(__GroupSize__get_X, __GroupSize__get_Y, __GroupSize__get_Z)] + void Execute(uint3 ThreadIds : SV_DispatchThreadID) + { + if (ThreadIds.x < __x && ThreadIds.y < __y && ThreadIds.z < __z) + { + __reserved__buffer[0] = 42; + } + } + """, + info.HlslSource); + } + + [AutoConstructor] + [ThreadGroupSize(DefaultThreadGroupSizes.X)] + [GeneratedComputeShaderDescriptor] + public readonly partial struct ExplicitEntryPointMethodComputeShader : IComputeShader + { + public readonly ReadWriteBuffer buffer; + + void IComputeShader.Execute() + { + buffer[0] = 42; + } + } + + // See https://github.com/Sergio0694/ComputeSharp/issues/855 + [TestMethod] + public void CompileExplicitEntryPointMethodPixelShader() + { + ShaderInfo info = ReflectionServices.GetShaderInfo(); + + Assert.AreEqual( + """ + #define __GroupSize__get_X 64 + #define __GroupSize__get_Y 1 + #define __GroupSize__get_Z 1 + + cbuffer _ : register(b0) + { + uint __x; + uint __y; + } + + RWTexture2D __outputTexture : register(u0); + + RWStructuredBuffer __reserved__buffer : register(u1); + + [NumThreads(__GroupSize__get_X, __GroupSize__get_Y, __GroupSize__get_Z)] + void Execute(uint3 ThreadIds : SV_DispatchThreadID) + { + if (ThreadIds.x < __x && ThreadIds.y < __y) + { + { + __outputTexture[ThreadIds.xy] = __reserved__buffer[0]; + return; + } + } + } + """, + info.HlslSource); + } + + [AutoConstructor] + [ThreadGroupSize(DefaultThreadGroupSizes.X)] + [GeneratedComputeShaderDescriptor] + public readonly partial struct ExplicitEntryPointMethodPixelShader : IComputeShader + { + public readonly ReadWriteBuffer buffer; + + float4 IComputeShader.Execute() + { + return buffer[0]; + } + } } \ No newline at end of file