diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs index d9adec9c..0555ba2a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs @@ -18,6 +18,19 @@ namespace ComputeSharp.D2D1.Interop; /// public static unsafe class D2D1PixelShaderEffect { + /// + /// Gets the effect id of the D2D effect using this shader. + /// + /// The type of D2D1 pixel shader to get the effect id for. + /// The effect id of the D2D effect using shaders. + public static ref readonly Guid GetEffectId() + where T : unmanaged, ID2D1PixelShader + { + Unsafe.SkipInit(out T shader); + + return ref shader.EffectId; + } + /// /// Registers an effect from an input D2D1 pixel shader, by calling ID2D1Factory1::RegisterEffectFromString. /// @@ -26,7 +39,10 @@ public static unsafe class D2D1PixelShaderEffect /// The of the registered effect, which can be used to call ID2D1DeviceContext::CreateEffect. /// Thrown if is . /// Thrown if an effect is registered multiple times with different properties. - /// For more info, see . + /// + /// The returned value is the same as that returned by . + /// For more info, see . + /// public static void RegisterForD2D1Factory1(void* d2D1Factory1, out Guid effectId) where T : unmanaged, ID2D1PixelShader { @@ -261,9 +277,8 @@ public static unsafe class D2D1PixelShaderEffect /// To make the deserialization easier, the type can be used to read and validate the returned blob. /// The leading blob id will determine what subtype should be used to deserialize the blob (eg. ). /// - /// - /// For more info, see . - /// + /// The returned value is the same as that returned by . + /// For more info, see . /// public static ReadOnlyMemory GetRegistrationBlob(out Guid effectId) where T : unmanaged, ID2D1PixelShader 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 37204600..52eb31d9 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs @@ -165,7 +165,7 @@ internal unsafe partial struct PixelShaderEffect private static For CreateInstance() { // Load all shader properties - Guid shaderId = typeof(T).GUID; + Guid shaderId = D2D1PixelShaderEffect.GetEffectId(); int constantBufferSize = D2D1PixelShader.GetConstantBufferSize(); D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision(); D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth();