From cee79055998f65cedd41f19c56d6ffd123450b7a Mon Sep 17 00:00:00 2001 From: Amer Koleci Date: Mon, 21 Nov 2022 11:21:28 +0100 Subject: [PATCH] More D3D12 goodies. --- Directory.Build.props | 2 +- .../DescriptorRange.cs | 28 +++++++ .../DescriptorRange1.cs | 29 +++++++ .../RangeUInt64.cs | 15 ++++ .../RenderPassBeginningAccess.cs | 45 ++++++++++ ...enderPassBeginningAccessClearParameters.cs | 23 +++++ .../RenderPassDepthStencilDescription.cs | 51 ++++++++++++ .../RenderPassEndingAccess.cs | 45 ++++++++++ ...RenderPassEndingAccessResolveParameters.cs | 61 ++++++++++++++ .../RenderPassRenderTargetDescription.cs | 39 +++++++++ .../ResourceBarrier.cs | 43 ++++++++++ .../SubresourceRangeUInt64.cs | 20 +++++ .../VersionedRootSignatureDescription.cs | 83 +++++++++++++++++++ src/samples/01-ClearScreen/Program.cs | 2 +- 14 files changed, 484 insertions(+), 2 deletions(-) create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange1.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/RangeUInt64.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccess.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccessClearParameters.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/RenderPassDepthStencilDescription.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccess.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccessResolveParameters.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/RenderPassRenderTargetDescription.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/ResourceBarrier.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/SubresourceRangeUInt64.cs create mode 100644 src/Vortice.Win32.Graphics.Direct3D12/VersionedRootSignatureDescription.cs diff --git a/Directory.Build.props b/Directory.Build.props index d07a72b..0720798 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,7 +15,7 @@ true $(MSBuildThisFileDirectory)NuGet.config - 1.8.7 + 1.8.8 true diff --git a/src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange.cs b/src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange.cs new file mode 100644 index 0000000..c427612 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange.cs @@ -0,0 +1,28 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct DescriptorRange +{ + public DescriptorRange(DescriptorRangeType rangeType, uint numDescriptors, uint baseShaderRegister, uint registerSpace = 0, uint offsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + { + Init(out this, rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); + } + + public void Init(DescriptorRangeType rangeType, uint numDescriptors, uint baseShaderRegister, uint registerSpace = 0, uint offsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + { + Init(out this, rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); + } + + public static void Init(out DescriptorRange range, DescriptorRangeType rangeType, uint numDescriptors, uint baseShaderRegister, uint registerSpace = 0, uint offsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + { + range.RangeType = rangeType; + range.NumDescriptors = numDescriptors; + range.BaseShaderRegister = baseShaderRegister; + range.RegisterSpace = registerSpace; + range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange1.cs b/src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange1.cs new file mode 100644 index 0000000..503b75b --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/DescriptorRange1.cs @@ -0,0 +1,29 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct DescriptorRange1 +{ + public DescriptorRange1(DescriptorRangeType rangeType, uint numDescriptors, uint baseShaderRegister, uint registerSpace = 0, DescriptorRangeFlags flags = DescriptorRangeFlags.None, uint offsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + { + Init(out this, rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); + } + + public void Init(DescriptorRangeType rangeType, uint numDescriptors, uint baseShaderRegister, uint registerSpace = 0, DescriptorRangeFlags flags = DescriptorRangeFlags.None, uint offsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + { + Init(out this, rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); + } + + public static void Init(out DescriptorRange1 range, DescriptorRangeType rangeType, uint numDescriptors, uint baseShaderRegister, uint registerSpace = 0, DescriptorRangeFlags flags = DescriptorRangeFlags.None, uint offsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + { + range.RangeType = rangeType; + range.NumDescriptors = numDescriptors; + range.BaseShaderRegister = baseShaderRegister; + range.RegisterSpace = registerSpace; + range.Flags = flags; + range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/RangeUInt64.cs b/src/Vortice.Win32.Graphics.Direct3D12/RangeUInt64.cs new file mode 100644 index 0000000..49f775e --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/RangeUInt64.cs @@ -0,0 +1,15 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public partial struct RangeUInt64 +{ + public RangeUInt64(ulong begin, ulong end) + { + Begin = begin; + End = end; + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccess.cs b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccess.cs new file mode 100644 index 0000000..cfff16e --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccess.cs @@ -0,0 +1,45 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public partial struct RenderPassBeginningAccess : IEquatable +{ + public static bool operator ==(in RenderPassBeginningAccess left, in RenderPassBeginningAccess right) + { + if (left.Type != right.Type) + { + return false; + } + + if (left.Type == RenderPassBeginningAccessType.Clear && !(left.Anonymous.Clear == right.Anonymous.Clear)) + { + return false; + } + + return true; + } + + public static bool operator !=(in RenderPassBeginningAccess left, in RenderPassBeginningAccess right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is RenderPassBeginningAccess other) && Equals(other); + + public bool Equals(RenderPassBeginningAccess other) => this == other; + + public override int GetHashCode() + { + var hashCode = new HashCode(); + { + hashCode.Add(Type); + + if (Type == RenderPassBeginningAccessType.Clear) + { + hashCode.Add(Anonymous.Clear); + } + } + return hashCode.ToHashCode(); + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccessClearParameters.cs b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccessClearParameters.cs new file mode 100644 index 0000000..c17b8a7 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassBeginningAccessClearParameters.cs @@ -0,0 +1,23 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public partial struct RenderPassBeginningAccessClearParameters : IEquatable +{ + public static bool operator ==(in RenderPassBeginningAccessClearParameters left, in RenderPassBeginningAccessClearParameters right) + { + return left.ClearValue == right.ClearValue; + } + + public static bool operator !=(in RenderPassBeginningAccessClearParameters left, in RenderPassBeginningAccessClearParameters right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is RenderPassBeginningAccessClearParameters other) && Equals(other); + + public bool Equals(RenderPassBeginningAccessClearParameters other) => this == other; + + public override int GetHashCode() => ClearValue.GetHashCode(); +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/RenderPassDepthStencilDescription.cs b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassDepthStencilDescription.cs new file mode 100644 index 0000000..a16882f --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassDepthStencilDescription.cs @@ -0,0 +1,51 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public partial struct RenderPassDepthStencilDescription : IEquatable +{ + public static bool operator ==(in RenderPassDepthStencilDescription left, in RenderPassDepthStencilDescription right) + { + if (left.cpuDescriptor.ptr != right.cpuDescriptor.ptr) + { + return false; + } + + if (!(left.DepthBeginningAccess == right.DepthBeginningAccess)) + { + return false; + } + + if (!(left.StencilBeginningAccess == right.StencilBeginningAccess)) + { + return false; + } + + if (!(left.DepthEndingAccess == right.DepthEndingAccess)) + { + return false; + } + + if (!(left.StencilEndingAccess == right.StencilEndingAccess)) + { + return false; + } + + return true; + } + + public static bool operator !=(in RenderPassDepthStencilDescription left, in RenderPassDepthStencilDescription right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is RenderPassDepthStencilDescription other) && Equals(other); + + public bool Equals(RenderPassDepthStencilDescription other) => this == other; + + public override int GetHashCode() + { + return HashCode.Combine(cpuDescriptor, DepthBeginningAccess, StencilBeginningAccess, DepthEndingAccess, StencilEndingAccess); + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccess.cs b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccess.cs new file mode 100644 index 0000000..9bd7720 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccess.cs @@ -0,0 +1,45 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public partial struct RenderPassEndingAccess : IEquatable +{ + public static bool operator ==(in RenderPassEndingAccess left, in RenderPassEndingAccess right) + { + if (left.Type != right.Type) + { + return false; + } + + if (left.Type == RenderPassEndingAccessType.Resolve && !(left.Anonymous.Resolve == right.Anonymous.Resolve)) + { + return false; + } + + return true; + } + + public static bool operator !=(in RenderPassEndingAccess left, in RenderPassEndingAccess right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is RenderPassEndingAccess other) && Equals(other); + + public bool Equals(RenderPassEndingAccess other) => this == other; + + public override int GetHashCode() + { + var hashCode = new HashCode(); + { + hashCode.Add(Type); + + if (Type == RenderPassEndingAccessType.Resolve) + { + hashCode.Add(Anonymous.Resolve); + } + } + return hashCode.ToHashCode(); + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccessResolveParameters.cs b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccessResolveParameters.cs new file mode 100644 index 0000000..e49c3d7 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassEndingAccessResolveParameters.cs @@ -0,0 +1,61 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RenderPassEndingAccessResolveParameters : IEquatable +{ + public static bool operator ==(in RenderPassEndingAccessResolveParameters left, in RenderPassEndingAccessResolveParameters right) + { + if (left.pSrcResource != right.pSrcResource) + { + return false; + } + + if (left.pDstResource != right.pDstResource) + { + return false; + } + + if (left.SubresourceCount != right.SubresourceCount) + { + return false; + } + + if (left.Format != right.Format) + { + return false; + } + + if (left.ResolveMode != right.ResolveMode) + { + return false; + } + + if (left.PreserveResolveSource != right.PreserveResolveSource) + { + return false; + } + + return true; + } + + public static bool operator !=(in RenderPassEndingAccessResolveParameters left, in RenderPassEndingAccessResolveParameters right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is RenderPassEndingAccessResolveParameters other) && Equals(other); + + public bool Equals(RenderPassEndingAccessResolveParameters other) => this == other; + + public override int GetHashCode() + { + return HashCode.Combine( + (nuint)pSrcResource, + (nuint)pDstResource, + SubresourceCount, + (nuint)pSubresourceParameters, + Format, + ResolveMode, + PreserveResolveSource); + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/RenderPassRenderTargetDescription.cs b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassRenderTargetDescription.cs new file mode 100644 index 0000000..47e2991 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/RenderPassRenderTargetDescription.cs @@ -0,0 +1,39 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RenderPassRenderTargetDescription : IEquatable +{ + public static bool operator ==(in RenderPassRenderTargetDescription left, in RenderPassRenderTargetDescription right) + { + if (left.cpuDescriptor.ptr != right.cpuDescriptor.ptr) + { + return false; + } + + if (!(left.BeginningAccess == right.BeginningAccess)) + { + return false; + } + + if (!(left.EndingAccess == right.EndingAccess)) + { + return false; + } + + return true; + } + + public static bool operator !=(in RenderPassRenderTargetDescription left, in RenderPassRenderTargetDescription right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is RenderPassRenderTargetDescription other) && Equals(other); + + public bool Equals(RenderPassRenderTargetDescription other) => this == other; + + public override int GetHashCode() + { + return HashCode.Combine(cpuDescriptor, BeginningAccess, EndingAccess); + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/ResourceBarrier.cs b/src/Vortice.Win32.Graphics.Direct3D12/ResourceBarrier.cs new file mode 100644 index 0000000..323ed50 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/ResourceBarrier.cs @@ -0,0 +1,43 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct ResourceBarrier +{ + public static ResourceBarrier InitTransition( + ID3D12Resource* pResource, + ResourceStates stateBefore, + ResourceStates stateAfter, + uint subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, + ResourceBarrierFlags flags = ResourceBarrierFlags.None) + { + ResourceBarrier result = default; + result.Type = ResourceBarrierType.Transition; + result.Flags = flags; + result.Anonymous.Transition.pResource = pResource; + result.Anonymous.Transition.StateBefore = stateBefore; + result.Anonymous.Transition.StateAfter = stateAfter; + result.Anonymous.Transition.Subresource = subresource; + return result; + } + + public static ResourceBarrier InitAliasing(ID3D12Resource* pResourceBefore, ID3D12Resource* pResourceAfter) + { + ResourceBarrier result = default; + result.Type = ResourceBarrierType.Aliasing; + result.Anonymous.Aliasing.pResourceBefore = pResourceBefore; + result.Anonymous.Aliasing.pResourceAfter = pResourceAfter; + return result; + } + + public static ResourceBarrier InitUAV(ID3D12Resource* pResource) + { + ResourceBarrier result = default; + result.Type = ResourceBarrierType.Uav; + result.Anonymous.UAV.pResource = pResource; + return result; + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/SubresourceRangeUInt64.cs b/src/Vortice.Win32.Graphics.Direct3D12/SubresourceRangeUInt64.cs new file mode 100644 index 0000000..64e93b6 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/SubresourceRangeUInt64.cs @@ -0,0 +1,20 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct SubresourceRangeUInt64 +{ + public SubresourceRangeUInt64(uint subresource, RangeUInt64* range) + { + Subresource = subresource; + Range = *range; + } + + public SubresourceRangeUInt64(uint subresource, ulong begin, ulong end) + { + Subresource = subresource; + Range.Begin = begin; + Range.End = end; + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/VersionedRootSignatureDescription.cs b/src/Vortice.Win32.Graphics.Direct3D12/VersionedRootSignatureDescription.cs new file mode 100644 index 0000000..bca596e --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/VersionedRootSignatureDescription.cs @@ -0,0 +1,83 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct VersionedRootSignatureDescription +{ + public VersionedRootSignatureDescription(in RootSignatureDescription other) + { + Unsafe.SkipInit(out this); + + Version = RootSignatureVersion.V1_0; + Anonymous.Desc_1_0 = other; + } + + public VersionedRootSignatureDescription(in RootSignatureDescription1 other) + { + Unsafe.SkipInit(out this); + + Version = RootSignatureVersion.V1_1; + Anonymous.Desc_1_1 = other; + } + + public VersionedRootSignatureDescription(uint numParameters, RootParameter* _pParameters, uint numStaticSamplers = 0, StaticSamplerDescription* _pStaticSamplers = null, RootSignatureFlags flags = RootSignatureFlags.None) + { + Init_1_0(out this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); + } + + public VersionedRootSignatureDescription(uint numParameters, RootParameter1* _pParameters, uint numStaticSamplers = 0, StaticSamplerDescription* _pStaticSamplers = null, RootSignatureFlags flags = RootSignatureFlags.None) + { + Init_1_1(out this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); + } + + public void Init_1_0( + uint numParameters, RootParameter* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + Init_1_0(out this, numParameters, parameters, numStaticSamplers, staticSamplers, flags); + } + + public static void Init_1_0(out VersionedRootSignatureDescription desc, + uint numParameters, RootParameter* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + desc = default; + + desc.Version = RootSignatureVersion.V1_0; + desc.Anonymous.Desc_1_0.NumParameters = numParameters; + desc.Anonymous.Desc_1_0.pParameters = parameters; + desc.Anonymous.Desc_1_0.NumStaticSamplers = numStaticSamplers; + desc.Anonymous.Desc_1_0.pStaticSamplers = staticSamplers; + desc.Anonymous.Desc_1_0.Flags = flags; + } + + public void Init_1_1( + uint numParameters, RootParameter1* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + Init_1_1(out this, numParameters, parameters, numStaticSamplers, staticSamplers, flags); + } + + public static void Init_1_1( + out VersionedRootSignatureDescription desc, + uint numParameters, RootParameter1* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + desc = default; + + desc.Version = RootSignatureVersion.V1_1; + desc.Anonymous.Desc_1_1.NumParameters = numParameters; + desc.Anonymous.Desc_1_1.pParameters = parameters; + desc.Anonymous.Desc_1_1.NumStaticSamplers = numStaticSamplers; + desc.Anonymous.Desc_1_1.pStaticSamplers = staticSamplers; + desc.Anonymous.Desc_1_1.Flags = flags; + } +} diff --git a/src/samples/01-ClearScreen/Program.cs b/src/samples/01-ClearScreen/Program.cs index c688b0c..8fd6297 100644 --- a/src/samples/01-ClearScreen/Program.cs +++ b/src/samples/01-ClearScreen/Program.cs @@ -93,7 +93,7 @@ public static unsafe class Program d2d1Factory2.GetVoidAddressOf()).ThrowIfFailed(); using ComPtr dwriteFactory = default; - DWriteCreateFactory(DWriteFactoryType.Shared, __uuidof(), dwriteFactory.GetIUnknownAddressOf()).ThrowIfFailed(); + DWriteCreateFactory(DWriteFactoryType.Shared, __uuidof(), dwriteFactory.GetVoidAddressOf()).ThrowIfFailed(); using ComPtr textFormat = dwriteFactory.Get()->CreateTextFormat(