diff --git a/src/ComputeSharp.D2D1Interop/Shaders/Interop/D2D1InteropServices.cs b/src/ComputeSharp.D2D1Interop/Shaders/Interop/D2D1InteropServices.cs
index 6b7e1374..54cb44e9 100644
--- a/src/ComputeSharp.D2D1Interop/Shaders/Interop/D2D1InteropServices.cs
+++ b/src/ComputeSharp.D2D1Interop/Shaders/Interop/D2D1InteropServices.cs
@@ -19,32 +19,32 @@ public static unsafe class D2D1InteropServices
/// Loads the bytecode from an input D2D1 pixel shader.
///
/// The type of D2D1 pixel shader to load the bytecode for.
- /// A instance with the resulting shader bytecode.
+ /// A instance with the resulting shader bytecode.
/// Thrown if the input shader has not been precompiled.
///
/// This method will only run correctly if the input shader has been precompiled, or it will throw an exception.
- /// The returned will wrap a pinned memory buffer (from the PE section).
+ /// The returned instance will wrap a pinned memory buffer (from the PE section).
///
- public static void LoadShaderBytecode(out ReadOnlyMemory bytecode)
+ public static ReadOnlyMemory LoadShaderBytecode()
where T : unmanaged, ID2D1PixelShader
{
- LoadOrCompileShaderBytecode(null, out bytecode);
+ return LoadOrCompileShaderBytecode(null);
}
///
/// Loads the bytecode from an input D2D1 pixel shader.
///
/// The type of D2D1 pixel shader to load the bytecode for.
- /// A instance with the resulting shader bytecode.
/// The shader profile to use to get the shader bytecode.
+ /// A instance with the resulting shader bytecode.
///
- /// If the input shader was precompiled, will wrap a pinned memory buffer (from the PE section).
- /// If the shader was compiled at runtime, will wrap a array with the bytecode.
+ /// If the input shader was precompiled, the returned instance will wrap a pinned memory buffer (from the PE section).
+ /// If the shader was compiled at runtime, the returned instance will wrap a array with the bytecode.
///
- public static void LoadShaderBytecode(D2D1ShaderProfile shaderProfile, out ReadOnlyMemory bytecode)
+ public static ReadOnlyMemory LoadShaderBytecode(D2D1ShaderProfile shaderProfile)
where T : unmanaged, ID2D1PixelShader
{
- LoadOrCompileShaderBytecode(shaderProfile, out bytecode);
+ return LoadOrCompileShaderBytecode(shaderProfile);
}
///
@@ -52,9 +52,9 @@ public static unsafe class D2D1InteropServices
///
/// The type of D2D1 pixel shader to load the bytecode for.
/// The shader profile to use to get the shader bytecode.
- /// A instance with the resulting shader bytecode.
+ /// A instance with the resulting shader bytecode.
/// Thrown if the input shader has not been precompiled.
- private static void LoadOrCompileShaderBytecode(D2D1ShaderProfile? shaderProfile, out ReadOnlyMemory bytecode)
+ private static ReadOnlyMemory LoadOrCompileShaderBytecode(D2D1ShaderProfile? shaderProfile)
where T : unmanaged, ID2D1PixelShader
{
D2D1ShaderBytecodeLoader bytecodeLoader = default;
@@ -66,14 +66,14 @@ public static unsafe class D2D1InteropServices
// If a precompiled shader is available, return it
if (!precompiledBytecode.IsEmpty)
{
- bytecode = new PinnedBufferMemoryManager(precompiledBytecode).Memory;
+ return new PinnedBufferMemoryManager(precompiledBytecode).Memory;
}
// Otherwise, return the dynamic shader instead
byte* bytecodePtr = (byte*)dynamicBytecode.Get()->GetBufferPointer();
int bytecodeSize = (int)dynamicBytecode.Get()->GetBufferSize();
- bytecode = new ReadOnlySpan(bytecodePtr, bytecodeSize).ToArray();
+ return new ReadOnlySpan(bytecodePtr, bytecodeSize).ToArray();
}
///
@@ -81,18 +81,18 @@ public static unsafe class D2D1InteropServices
///
/// The type of D2D1 pixel shader to retrieve info for.
/// The input D2D1 pixel shader to retrieve info for.
- /// A instance with the pixel shader constant buffer.
+ /// A instance with the pixel shader constant buffer.
///
/// This method will allocate a buffer every time it is invoked.
/// For a zero-allocation alternative, use .
- public static void GetPixelShaderConstantBufferForD2D1DrawInfo(in T shader, out ReadOnlyMemory buffer)
+ public static ReadOnlyMemory GetPixelShaderConstantBufferForD2D1DrawInfo(in T shader)
where T : unmanaged, ID2D1PixelShader
{
D2D1ByteArrayDispatchDataLoader dataLoader = default;
Unsafe.AsRef(in shader).LoadDispatchData(ref dataLoader);
- buffer = dataLoader.GetResultingDispatchData();
+ return dataLoader.GetResultingDispatchData();
}
///