diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs
index 5098a14e..58934467 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs
@@ -89,6 +89,16 @@ internal unsafe partial struct PixelShaderEffect
///
private static D2D1ChannelDepth channelDepth;
+ ///
+ /// The number of available resource texture descriptions.
+ ///
+ private static int resourceTextureDescriptionCount;
+
+ ///
+ /// The buffer with the available resource texture descriptions for the shader.
+ ///
+ private static D2D1ResourceTextureDescription* resourceTextureDescriptions;
+
///
/// The factory of instances to use for each created effect.
///
@@ -119,9 +129,6 @@ internal unsafe partial struct PixelShaderEffect
{
// Load all shader properties
Guid shaderId = typeof(T).GUID;
- ReadOnlyMemory bytecodeInfo = D2D1PixelShader.LoadBytecode();
- int bytecodeSize = bytecodeInfo.Length;
- byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), bytecodeSize);
D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision();
D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth();
D2D1PixelOptions pixelOptions = D2D1PixelShader.GetPixelOptions();
@@ -142,7 +149,18 @@ internal unsafe partial struct PixelShaderEffect
inputDescriptionsInfo.Span.CopyTo(new Span(inputDescriptions, inputDescriptionCount));
+ // Prepare the resource texture descriptions
+ ReadOnlyMemory resourceTextureDescriptionsInfo = D2D1PixelShader.GetResourceTextureDescriptions();
+ int resourceTextureDescriptionCount = resourceTextureDescriptionsInfo.Length;
+ D2D1ResourceTextureDescription* resourceTextureDescriptions = (D2D1ResourceTextureDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1ResourceTextureDescription) * resourceTextureDescriptionCount);
+
+ resourceTextureDescriptionsInfo.Span.CopyTo(new Span(resourceTextureDescriptions, resourceTextureDescriptionCount));
+
// Copy the bytecode to the target buffer
+ ReadOnlyMemory bytecodeInfo = D2D1PixelShader.LoadBytecode();
+ int bytecodeSize = bytecodeInfo.Length;
+ byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), bytecodeSize);
+
bytecodeInfo.Span.CopyTo(new Span(bytecode, bytecodeSize));
// Set the shared state and mark the type as initialized
@@ -156,6 +174,8 @@ internal unsafe partial struct PixelShaderEffect
For.bytecodeSize = bytecodeSize;
For.bufferPrecision = bufferPrecision;
For.channelDepth = channelDepth;
+ For.resourceTextureDescriptionCount = resourceTextureDescriptionCount;
+ For.resourceTextureDescriptions = resourceTextureDescriptions;
For.d2D1DrawTransformMapperFactory = d2D1DrawTransformMapperFactory;
isInitialized = true;
@@ -240,6 +260,8 @@ internal unsafe partial struct PixelShaderEffect
bytecodeSize,
bufferPrecision,
channelDepth,
+ resourceTextureDescriptionCount,
+ resourceTextureDescriptions,
d2D1TransformMapper,
effectImpl);
}
diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs
index 15564664..96b46719 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs
@@ -181,6 +181,19 @@ internal unsafe partial struct PixelShaderEffect
///
private D2D1ChannelDepth channelDepth;
+ ///
+ /// The number of available resource texture descriptions.
+ ///
+ private int resourceTextureDescriptionCount;
+
+ ///
+ /// The buffer with the available resource texture descriptions for the shader.
+ ///
+ ///
+ /// This buffer is also shared among effect instances, like .
+ ///
+ private D2D1ResourceTextureDescription* resourceTextureDescriptions;
+
///
/// The handle for the instance in use, if any.
///
@@ -209,6 +222,8 @@ internal unsafe partial struct PixelShaderEffect
/// The size of .
/// The buffer precision for the resulting output buffer.
/// The channel depth for the resulting output buffer.
+ /// The number of available resource texture descriptions.
+ /// The buffer with the available resource texture descriptions for the shader.
/// The instance to use for the effect.
/// The resulting effect instance.
/// This always returns 0.
@@ -223,6 +238,8 @@ internal unsafe partial struct PixelShaderEffect
int bytecodeSize,
D2D1BufferPrecision bufferPrecision,
D2D1ChannelDepth channelDepth,
+ int resourceTextureDescriptionCount,
+ D2D1ResourceTextureDescription* resourceTextureDescriptions,
D2D1TransformMapper? d2D1TransformMapper,
IUnknown** effectImpl)
{
@@ -254,6 +271,8 @@ internal unsafe partial struct PixelShaderEffect
@this->bytecodeSize = bytecodeSize;
@this->bufferPrecision = bufferPrecision;
@this->channelDepth = channelDepth;
+ @this->resourceTextureDescriptionCount = resourceTextureDescriptionCount;
+ @this->resourceTextureDescriptions = resourceTextureDescriptions;
@this->d2D1TransformMapperHandle = GCHandle.Alloc(d2D1TransformMapper);
@this->d2D1DrawInfo = null;
@this->d2D1EffectContext = null;