Minor code refactoring, centralize effect id management
このコミットが含まれているのは:
1 親
d509db265a
コミット
5899a6667a
2ファイル変更
+14
-5
検索条件に一致するファイルはありません
@@ -109,17 +109,15 @@ unsafe partial class D2D1InteropServices
|
||||
(void*)Marshal.GetFunctionPointerForDelegate(PixelShaderEffect.SetConstantBufferWrapper);
|
||||
#endif
|
||||
|
||||
Guid shaderId = typeof(T).GUID;
|
||||
|
||||
// Register the effect
|
||||
((ID2D1Factory1*)d2D1Factory1)->RegisterEffectFromString(
|
||||
classId: &shaderId,
|
||||
classId: PixelShaderEffect.For<T>.Id,
|
||||
propertyXml: (ushort*)pXml,
|
||||
bindings: &d2D1PropertyBinding,
|
||||
bindingsCount: 1,
|
||||
effectFactory: PixelShaderEffect.For<T>.Factory).Assert();
|
||||
|
||||
effectId = shaderId;
|
||||
effectId = *PixelShaderEffect.For<T>.Id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// <summary>
|
||||
/// The <see cref="Guid"/> for the shader.
|
||||
/// </summary>
|
||||
[FixedAddressValueType]
|
||||
private static Guid shaderId;
|
||||
|
||||
/// <summary>
|
||||
@@ -125,7 +126,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
else
|
||||
{
|
||||
// Load all shader properties
|
||||
Guid guid = Guid.NewGuid();
|
||||
Guid guid = typeof(T).GUID;
|
||||
int inputCount = ((D2DInputCountAttribute[])typeof(T).GetCustomAttributes(typeof(D2DInputCountAttribute), false))[0].Count;
|
||||
ReadOnlyMemory<byte> buffer = D2D1InteropServices.LoadShaderBytecode<T>();
|
||||
byte* typeAssociatedMemory = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), buffer.Length);
|
||||
@@ -145,11 +146,21 @@ internal unsafe partial struct PixelShaderEffect
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pointer to the id of the effect.
|
||||
/// </summary>
|
||||
public static Guid* Id
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => (Guid*)Unsafe.AsPointer(ref shaderId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the factory for the current effect.
|
||||
/// </summary>
|
||||
public static delegate* unmanaged[Stdcall]<IUnknown**, HRESULT> Factory
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => (delegate* unmanaged[Stdcall]<IUnknown**, HRESULT>)Marshal.GetFunctionPointerForDelegate(EffectFactory);
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする