From 0963d9784caef62198e90b235806c598d383c553 Mon Sep 17 00:00:00 2001 From: Amer Koleci Date: Mon, 21 Jun 2021 11:56:25 +0200 Subject: [PATCH] [ENH] DXGI: dxgidebug.h under Vortice.DXGI.Debug namespace. [ENH] Direct3D12: Improve Debug MessageID enum values names. --- CHANGELOG.md | 2 + .../{ => Debug}/IDXGIInfoQueue.cs | 2 +- .../{ => Debug}/InfoQueueFilter.cs | 2 +- .../{ => Debug}/InfoQueueFilterDescription.cs | 2 +- src/Vortice.DXGI/IDXGIDecodeSwapChain.cs | 29 ++++ src/Vortice.DXGI/IDXGISurface2.cs | 17 +- src/Vortice.DXGI/Mappings.xml | 4 +- src/Vortice.DXGI/Vortice.DXGI.csproj | 3 + src/Vortice.Direct3D12/ID3D12Device4.cs | 118 ++++++++++++-- src/Vortice.Direct3D12/ID3D12Device5.cs | 118 ++++++++++++-- src/Vortice.Direct3D12/ID3D12Device7.cs | 30 +++- src/Vortice.Direct3D12/ID3D12Device8.cs | 79 ++++++++- src/Vortice.Direct3D12/ID3D12Device9.cs | 14 +- src/Vortice.Direct3D12/Mappings.xml | 151 +++++++++++++++++- .../Vortice.Direct3D12.csproj | 1 + .../HelloDirect3D11/D3D11GraphicsDevice.cs | 1 + .../HelloDirect3D12/D3D12GraphicsDevice.cs | 1 + .../D3D12GraphicsDevice.cs | 24 ++- .../HelloDirect3D12Raytracing/Program.cs | 2 +- 19 files changed, 526 insertions(+), 74 deletions(-) rename src/Vortice.DXGI/{ => Debug}/IDXGIInfoQueue.cs (98%) rename src/Vortice.DXGI/{ => Debug}/InfoQueueFilter.cs (98%) rename src/Vortice.DXGI/{ => Debug}/InfoQueueFilterDescription.cs (99%) create mode 100644 src/Vortice.DXGI/IDXGIDecodeSwapChain.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 608a082f..ee7f6e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Current Stable Release: 1.9.80 (May 2021) Release: 1.9.XX (June 2021) ----------------------------------------------- - [ENH] Direct3D11: Rename Usage to ResourceUsage and improve CreateBuffer, improve Create shaders with Blob directly. +- [ENH] DXGI: dxgidebug.h under Vortice.DXGI.Debug namespace. +- [ENH] Direct3D12: Improve Debug MessageID enum values names. ----------------------------------------------- Release: 1.9.80 (May 2021) diff --git a/src/Vortice.DXGI/IDXGIInfoQueue.cs b/src/Vortice.DXGI/Debug/IDXGIInfoQueue.cs similarity index 98% rename from src/Vortice.DXGI/IDXGIInfoQueue.cs rename to src/Vortice.DXGI/Debug/IDXGIInfoQueue.cs index 20492fce..5b7a0b03 100644 --- a/src/Vortice.DXGI/IDXGIInfoQueue.cs +++ b/src/Vortice.DXGI/Debug/IDXGIInfoQueue.cs @@ -4,7 +4,7 @@ using System; using SharpGen.Runtime; -namespace Vortice.DXGI +namespace Vortice.DXGI.Debug { public partial class IDXGIInfoQueue { diff --git a/src/Vortice.DXGI/InfoQueueFilter.cs b/src/Vortice.DXGI/Debug/InfoQueueFilter.cs similarity index 98% rename from src/Vortice.DXGI/InfoQueueFilter.cs rename to src/Vortice.DXGI/Debug/InfoQueueFilter.cs index 265cfbfd..247d14ec 100644 --- a/src/Vortice.DXGI/InfoQueueFilter.cs +++ b/src/Vortice.DXGI/Debug/InfoQueueFilter.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; -namespace Vortice.DXGI +namespace Vortice.DXGI.Debug { public partial class InfoQueueFilter { diff --git a/src/Vortice.DXGI/InfoQueueFilterDescription.cs b/src/Vortice.DXGI/Debug/InfoQueueFilterDescription.cs similarity index 99% rename from src/Vortice.DXGI/InfoQueueFilterDescription.cs rename to src/Vortice.DXGI/Debug/InfoQueueFilterDescription.cs index 03b919e3..ffcd65ea 100644 --- a/src/Vortice.DXGI/InfoQueueFilterDescription.cs +++ b/src/Vortice.DXGI/Debug/InfoQueueFilterDescription.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using SharpGen.Runtime; -namespace Vortice.DXGI +namespace Vortice.DXGI.Debug { public partial class InfoQueueFilterDescription { diff --git a/src/Vortice.DXGI/IDXGIDecodeSwapChain.cs b/src/Vortice.DXGI/IDXGIDecodeSwapChain.cs new file mode 100644 index 00000000..de48449c --- /dev/null +++ b/src/Vortice.DXGI/IDXGIDecodeSwapChain.cs @@ -0,0 +1,29 @@ +// Copyright (c) Amer Koleci and contributors. +// Distributed under the MIT license. See the LICENSE file in the project root for more information. + +using System.Drawing; +using SharpGen.Runtime; + +namespace Vortice.DXGI +{ + public partial class IDXGIDecodeSwapChain + { + public Size DestSize + { + get + { + GetDestSize(out int width, out int height); + return new Size(width, height); + } + set + { + SetDestSize(value.Width, value.Height); + } + } + + public Result PresentBuffer(int bufferToPresent, int syncInterval) + { + return PresentBuffer(bufferToPresent, syncInterval, PresentFlags.None); + } + } +} diff --git a/src/Vortice.DXGI/IDXGISurface2.cs b/src/Vortice.DXGI/IDXGISurface2.cs index 8cb7da04..119d36d3 100644 --- a/src/Vortice.DXGI/IDXGISurface2.cs +++ b/src/Vortice.DXGI/IDXGISurface2.cs @@ -8,14 +8,23 @@ namespace Vortice.DXGI { public partial class IDXGISurface2 { - public T? GetResource(out int subresourceIndex) where T : ComObject + public T GetResource(out int subresourceIndex) where T : ComObject { - if (GetResource(typeof(T).GUID, out IntPtr nativePtr, out subresourceIndex).Failure) + GetResource(typeof(T).GUID, out IntPtr nativePtr, out subresourceIndex).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + public Result GetResource(out int subresourceIndex, out T? parentResource) where T : ComObject + { + Result result = GetResource(typeof(T).GUID, out IntPtr nativePtr, out subresourceIndex); + if (result.Failure) { - return default; + parentResource = default; + return result; } - return MarshallingHelpers.FromPointer(nativePtr); + parentResource = MarshallingHelpers.FromPointer(nativePtr); + return result; } } } diff --git a/src/Vortice.DXGI/Mappings.xml b/src/Vortice.DXGI/Mappings.xml index 727ffc3b..a0c36add 100644 --- a/src/Vortice.DXGI/Mappings.xml +++ b/src/Vortice.DXGI/Mappings.xml @@ -8,7 +8,7 @@ $(THIS_CONFIG_PATH)/../native/include/directx - + @@ -112,6 +112,7 @@ + @@ -213,6 +214,7 @@ + diff --git a/src/Vortice.DXGI/Vortice.DXGI.csproj b/src/Vortice.DXGI/Vortice.DXGI.csproj index 8807d2c4..1d699042 100644 --- a/src/Vortice.DXGI/Vortice.DXGI.csproj +++ b/src/Vortice.DXGI/Vortice.DXGI.csproj @@ -13,5 +13,8 @@ + + + diff --git a/src/Vortice.Direct3D12/ID3D12Device4.cs b/src/Vortice.Direct3D12/ID3D12Device4.cs index 9aa9aec8..460b86cf 100644 --- a/src/Vortice.Direct3D12/ID3D12Device4.cs +++ b/src/Vortice.Direct3D12/ID3D12Device4.cs @@ -8,6 +8,7 @@ namespace Vortice.Direct3D12 { public partial class ID3D12Device4 { + #region CreateCommandList1 public T CreateCommandList1(CommandListType type, CommandListFlags commandListFlags = CommandListFlags.None) where T : ID3D12GraphicsCommandList1 { CreateCommandList1(0, type, commandListFlags, typeof(T).GUID, out IntPtr nativePtr).CheckError(); @@ -37,14 +38,58 @@ public Result CreateCommandList1(int nodeMask, CommandListType type, CommandL commandList = MarshallingHelpers.FromPointer(nativePtr); return result; } + #endregion - public T? CreateCommittedResource1( + #region CreateCommittedResource1 + public T CreateCommittedResource1( HeapProperties heapProperties, HeapFlags heapFlags, ResourceDescription description, ResourceStates initialResourceState, ID3D12ProtectedResourceSession protectedSession, ClearValue? optimizedClearValue = null) where T : ID3D12Resource1 + { + CreateCommittedResource1(ref heapProperties, heapFlags, + ref description, + initialResourceState, + optimizedClearValue, + protectedSession, + typeof(T).GUID, out IntPtr nativePtr).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + public Result CreateCommittedResource1( + HeapProperties heapProperties, + HeapFlags heapFlags, + ResourceDescription description, + ResourceStates initialResourceState, + ID3D12ProtectedResourceSession protectedSession, + out T? resource) where T : ID3D12Resource1 + { + Result result = CreateCommittedResource1(ref heapProperties, heapFlags, + ref description, + initialResourceState, + null, + protectedSession, + typeof(T).GUID, out IntPtr nativePtr); + if (result.Failure) + { + resource = default; + return result; + } + + resource = MarshallingHelpers.FromPointer(nativePtr); + return result; + } + + public Result CreateCommittedResource1( + HeapProperties heapProperties, + HeapFlags heapFlags, + ResourceDescription description, + ResourceStates initialResourceState, + ID3D12ProtectedResourceSession protectedSession, + ClearValue optimizedClearValue, + out T? resource) where T : ID3D12Resource1 { Result result = CreateCommittedResource1(ref heapProperties, heapFlags, ref description, @@ -53,45 +98,96 @@ public Result CreateCommandList1(int nodeMask, CommandListType type, CommandL protectedSession, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + resource = default; + return result; + } + + resource = MarshallingHelpers.FromPointer(nativePtr); + return result; + } + #endregion + #region CreateHeap1 + public T CreateHeap1(HeapDescription description, ID3D12ProtectedResourceSession protectedSession) where T : ID3D12Heap1 + { + CreateHeap1(ref description, protectedSession, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return MarshallingHelpers.FromPointer(nativePtr); } - public T? CreateHeap1(HeapDescription description, ID3D12ProtectedResourceSession protectedSession) where T : ID3D12Heap1 + public Result CreateHeap1(HeapDescription description, ID3D12ProtectedResourceSession protectedSession, out T? heap) where T : ID3D12Heap1 { Result result = CreateHeap1(ref description, protectedSession, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + heap = default; + return result; + } + + heap = MarshallingHelpers.FromPointer(nativePtr); + return result; + } + #endregion + #region CreateProtectedResourceSession + public T CreateProtectedResourceSession(ProtectedResourceSessionDescription description) where T : ID3D12ProtectedResourceSession + { + CreateProtectedResourceSession(description, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return MarshallingHelpers.FromPointer(nativePtr); } - public T? CreateProtectedResourceSession(ProtectedResourceSessionDescription description) where T : ID3D12ProtectedResourceSession + public Result CreateProtectedResourceSession(ProtectedResourceSessionDescription description, out T? resource) where T : ID3D12ProtectedResourceSession { Result result = CreateProtectedResourceSession(description, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + resource = default; + return result; + } + resource = MarshallingHelpers.FromPointer(nativePtr); + return result; + } + #endregion + + #region CreateReservedResource1 + public T CreateReservedResource1(ResourceDescription description, ResourceStates initialState, ClearValue clearValue, ID3D12ProtectedResourceSession protectedResourceSession) where T : ID3D12Resource1 + { + CreateReservedResource1(ref description, initialState, clearValue, protectedResourceSession, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return MarshallingHelpers.FromPointer(nativePtr); } - public T? CreateReservedResource1(ResourceDescription description, ResourceStates initialState, ClearValue clearValue, ID3D12ProtectedResourceSession protectedResourceSession) where T : ID3D12Resource1 + public Result CreateReservedResource1(ResourceDescription description, ResourceStates initialState, ClearValue clearValue, ID3D12ProtectedResourceSession protectedResourceSession, out T? resource) where T : ID3D12Resource1 { Result result = CreateReservedResource1(ref description, initialState, clearValue, protectedResourceSession, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + resource = default; + return result; + } + + resource = MarshallingHelpers.FromPointer(nativePtr); + return result; + } + public T CreateReservedResource1(ResourceDescription description, ResourceStates initialState, ID3D12ProtectedResourceSession protectedResourceSession) where T : ID3D12Resource1 + { + CreateReservedResource1(ref description, initialState, null, protectedResourceSession, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return MarshallingHelpers.FromPointer(nativePtr); } - public T? CreateReservedResource1(ResourceDescription description, ResourceStates initialState, ID3D12ProtectedResourceSession protectedResourceSession) where T : ID3D12Resource1 + public Result CreateReservedResource1(ResourceDescription description, ResourceStates initialState, ID3D12ProtectedResourceSession protectedResourceSession, out T? resource) where T : ID3D12Resource1 { Result result = CreateReservedResource1(ref description, initialState, null, protectedResourceSession, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + resource = default; + return result; + } - return MarshallingHelpers.FromPointer(nativePtr); + resource = MarshallingHelpers.FromPointer(nativePtr); + return result; } + #endregion } } diff --git a/src/Vortice.Direct3D12/ID3D12Device5.cs b/src/Vortice.Direct3D12/ID3D12Device5.cs index 21fc81a5..55945090 100644 --- a/src/Vortice.Direct3D12/ID3D12Device5.cs +++ b/src/Vortice.Direct3D12/ID3D12Device5.cs @@ -14,13 +14,29 @@ public partial class ID3D12Device5 /// /// A of the meta command that you wish to instantiate. /// An instance of . - public T? CreateMetaCommand(Guid commandId) where T : ID3D12MetaCommand + public T CreateMetaCommand(Guid commandId) where T : ID3D12MetaCommand + { + CreateMetaCommand(commandId, 0, IntPtr.Zero, 0, typeof(T).GUID, out IntPtr nativePtr).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + /// + /// Creates an instance of the specified meta command. + /// + /// A of the meta command that you wish to instantiate. + /// An instance of . + /// The result of operation. + public Result CreateMetaCommand(Guid commandId, out T? metaCommand) where T : ID3D12MetaCommand { Result result = CreateMetaCommand(commandId, 0, IntPtr.Zero, 0, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + metaCommand = default; + return result; + } - return MarshallingHelpers.FromPointer(nativePtr); + metaCommand = MarshallingHelpers.FromPointer(nativePtr); + return result; } /// @@ -30,13 +46,31 @@ public partial class ID3D12Device5 /// For single-adapter operation, set this to zero. If there are multiple adapter nodes, set a bit to identify the node (one of the device's physical adapters) to which the meta command applies. /// Each bit in the mask corresponds to a single node. Only one bit must be set. /// An instance of . - public T? CreateMetaCommand(Guid commandId, int nodeMask) where T : ID3D12MetaCommand + public T CreateMetaCommand(Guid commandId, int nodeMask) where T : ID3D12MetaCommand + { + CreateMetaCommand(commandId, nodeMask, IntPtr.Zero, 0, typeof(T).GUID, out IntPtr nativePtr).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + /// + /// Creates an instance of the specified meta command. + /// + /// A of the meta command that you wish to instantiate. + /// For single-adapter operation, set this to zero. If there are multiple adapter nodes, set a bit to identify the node (one of the device's physical adapters) to which the meta command applies. + /// Each bit in the mask corresponds to a single node. Only one bit must be set. + /// An instance of . + /// The result of operation. + public Result CreateMetaCommand(Guid commandId, int nodeMask, out T? metaCommand) where T : ID3D12MetaCommand { Result result = CreateMetaCommand(commandId, nodeMask, IntPtr.Zero, 0, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + metaCommand = default; + return result; + } - return MarshallingHelpers.FromPointer(nativePtr); + metaCommand = MarshallingHelpers.FromPointer(nativePtr); + return result; } /// @@ -45,13 +79,30 @@ public partial class ID3D12Device5 /// A of the meta command that you wish to instantiate. /// Blob containing the values of the parameters for creating the meta command. /// An instance of . - public T? CreateMetaCommand(Guid commandId, Blob blob) where T : ID3D12MetaCommand + public T CreateMetaCommand(Guid commandId, Blob blob) where T : ID3D12MetaCommand + { + CreateMetaCommand(commandId, 0, blob.BufferPointer, blob.BufferSize, typeof(T).GUID, out IntPtr nativePtr).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + /// + /// Creates an instance of the specified meta command. + /// + /// A of the meta command that you wish to instantiate. + /// Blob containing the values of the parameters for creating the meta command. + /// An instance of . + /// The result of operation + public Result CreateMetaCommand(Guid commandId, Blob blob, out T? metaCommand) where T : ID3D12MetaCommand { Result result = CreateMetaCommand(commandId, 0, blob.BufferPointer, blob.BufferSize, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + metaCommand = default; + return result; + } - return MarshallingHelpers.FromPointer(nativePtr); + metaCommand = MarshallingHelpers.FromPointer(nativePtr); + return result; } /// @@ -62,27 +113,64 @@ public partial class ID3D12Device5 /// Each bit in the mask corresponds to a single node. Only one bit must be set. /// Blob containing the values of the parameters for creating the meta command. /// An instance of . - public T? CreateMetaCommand(Guid commandId, int nodeMask, Blob blob) where T : ID3D12MetaCommand + public T CreateMetaCommand(Guid commandId, int nodeMask, Blob blob) where T : ID3D12MetaCommand + { + CreateMetaCommand(commandId, nodeMask, blob.BufferPointer, blob.BufferSize, typeof(T).GUID, out IntPtr nativePtr).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + /// + /// Creates an instance of the specified meta command. + /// + /// A of the meta command that you wish to instantiate. + /// For single-adapter operation, set this to zero. If there are multiple adapter nodes, set a bit to identify the node (one of the device's physical adapters) to which the meta command applies. + /// Each bit in the mask corresponds to a single node. Only one bit must be set. + /// Blob containing the values of the parameters for creating the meta command. + /// An instance of . + /// The result of the operation. + public Result CreateMetaCommand(Guid commandId, int nodeMask, Blob blob, out T? metaCommand) where T : ID3D12MetaCommand { Result result = CreateMetaCommand(commandId, nodeMask, blob.BufferPointer, blob.BufferSize, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + metaCommand = default; + return result; + } - return MarshallingHelpers.FromPointer(nativePtr); + metaCommand = MarshallingHelpers.FromPointer(nativePtr); + return result; } + #region CreateStateObject /// /// Creates a . /// /// The description of the state object to create. /// An instance of . - public T? CreateStateObject(StateObjectDescription description) where T : ID3D12StateObject + public T CreateStateObject(StateObjectDescription description) where T : ID3D12StateObject + { + CreateStateObject(description, typeof(T).GUID, out IntPtr nativePtr).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + /// + /// Creates a . + /// + /// The description of the state object to create. + /// An instance of . + /// The result of operation. + public Result CreateStateObject(StateObjectDescription description, out T? stateObject) where T : ID3D12StateObject { Result result = CreateStateObject(description, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + stateObject = default; + return result; + } - return MarshallingHelpers.FromPointer(nativePtr); + stateObject = MarshallingHelpers.FromPointer(nativePtr); + return result; } + #endregion } } diff --git a/src/Vortice.Direct3D12/ID3D12Device7.cs b/src/Vortice.Direct3D12/ID3D12Device7.cs index 0e805a13..77bac953 100644 --- a/src/Vortice.Direct3D12/ID3D12Device7.cs +++ b/src/Vortice.Direct3D12/ID3D12Device7.cs @@ -8,22 +8,42 @@ namespace Vortice.Direct3D12 { public partial class ID3D12Device7 { - public T? AddToStateObject(StateObjectDescription addition, ID3D12StateObject stateObjectToGrowFrom) where T : ID3D12StateObject + public T AddToStateObject(StateObjectDescription addition, ID3D12StateObject stateObjectToGrowFrom) where T : ID3D12StateObject + { + AddToStateObject(addition, stateObjectToGrowFrom, typeof(T).GUID, out IntPtr nativePtr).CheckError(); + return MarshallingHelpers.FromPointer(nativePtr); + } + + public Result AddToStateObject(StateObjectDescription addition, ID3D12StateObject stateObjectToGrowFrom, out T? newStateObject) where T : ID3D12StateObject { Result result = AddToStateObject(addition, stateObjectToGrowFrom, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + newStateObject = default; + return result; + } + newStateObject = MarshallingHelpers.FromPointer(nativePtr); + return result; + } + + public T CreateProtectedResourceSession1(ProtectedResourceSessionDescription1 description) where T : ID3D12ProtectedResourceSession1 + { + CreateProtectedResourceSession1(ref description, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return MarshallingHelpers.FromPointer(nativePtr); } - public T? CreateProtectedResourceSession1(ProtectedResourceSessionDescription1 description) where T : ID3D12ProtectedResourceSession1 + public Result CreateProtectedResourceSession1(ProtectedResourceSessionDescription1 description, out T? session) where T : ID3D12ProtectedResourceSession1 { Result result = CreateProtectedResourceSession1(ref description, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) - return default; + { + session = default; + return result; + } - return MarshallingHelpers.FromPointer(nativePtr); + session = MarshallingHelpers.FromPointer(nativePtr); + return result; } } } diff --git a/src/Vortice.Direct3D12/ID3D12Device8.cs b/src/Vortice.Direct3D12/ID3D12Device8.cs index 6cdc1750..d24d3088 100644 --- a/src/Vortice.Direct3D12/ID3D12Device8.cs +++ b/src/Vortice.Direct3D12/ID3D12Device8.cs @@ -8,21 +8,53 @@ namespace Vortice.Direct3D12 { public partial class ID3D12Device8 { - public T? CreateCommittedResource2( + public T CreateCommittedResource2( HeapProperties heapProperties, HeapFlags heapFlags, ResourceDescription1 description, ResourceStates initialResourceState, - ClearValue? optimizedClearValue, ID3D12ProtectedResourceSession protectedSession) where T : ID3D12Resource { - Result result = CreateCommittedResource2( + CreateCommittedResource2( + ref heapProperties, + heapFlags, + ref description, + initialResourceState, + null, + protectedSession, + typeof(T).GUID, out IntPtr nativePtr).CheckError(); + + return MarshallingHelpers.FromPointer(nativePtr); + } + + public T CreateCommittedResource2( + HeapProperties heapProperties, + HeapFlags heapFlags, + ResourceDescription1 description, + ResourceStates initialResourceState, + ClearValue optimizedClearValue, + ID3D12ProtectedResourceSession protectedSession) where T : ID3D12Resource + { + CreateCommittedResource2( ref heapProperties, heapFlags, ref description, initialResourceState, optimizedClearValue, protectedSession, + typeof(T).GUID, out IntPtr nativePtr).CheckError(); + + return MarshallingHelpers.FromPointer(nativePtr); + } + + public T? CreatePlacedResource1(ID3D12Heap heap, ulong heapOffset, ResourceDescription1 description, ResourceStates initialState, ClearValue? optimizedClearValue = null) where T : ID3D12Resource + { + Result result = CreatePlacedResource1( + heap, + heapOffset, + ref description, + initialState, + optimizedClearValue, typeof(T).GUID, out IntPtr nativePtr); if (result.Success) @@ -33,7 +65,38 @@ public partial class ID3D12Device8 return default; } - public T? CreatePlacedResource1(ID3D12Heap heap, ulong heapOffset, ResourceDescription1 description, ResourceStates initialState, ClearValue? optimizedClearValue = null) where T : ID3D12Resource + public Result CreatePlacedResource1( + ID3D12Heap heap, + ulong heapOffset, + ResourceDescription1 description, + ResourceStates initialState, + out T? resource) where T : ID3D12Resource + { + Result result = CreatePlacedResource1( + heap, + heapOffset, + ref description, + initialState, + null, + typeof(T).GUID, out IntPtr nativePtr); + + if (result.Failure) + { + resource = default; + return result; + } + + resource = MarshallingHelpers.FromPointer(nativePtr); + return result; + } + + public Result CreatePlacedResource1( + ID3D12Heap heap, + ulong heapOffset, + ResourceDescription1 description, + ResourceStates initialState, + ClearValue optimizedClearValue, + out T? resource) where T : ID3D12Resource { Result result = CreatePlacedResource1( heap, @@ -43,12 +106,14 @@ public partial class ID3D12Device8 optimizedClearValue, typeof(T).GUID, out IntPtr nativePtr); - if (result.Success) + if (result.Failure) { - return MarshallingHelpers.FromPointer(nativePtr); + resource = default; + return result; } - return default; + resource = MarshallingHelpers.FromPointer(nativePtr); + return result; } } } diff --git a/src/Vortice.Direct3D12/ID3D12Device9.cs b/src/Vortice.Direct3D12/ID3D12Device9.cs index e203eed8..04d5c1c6 100644 --- a/src/Vortice.Direct3D12/ID3D12Device9.cs +++ b/src/Vortice.Direct3D12/ID3D12Device9.cs @@ -8,12 +8,9 @@ namespace Vortice.Direct3D12 { public partial class ID3D12Device9 { - public T? CreateCommandQueue1(in CommandQueueDescription description, Guid creatorID) where T : ID3D12CommandQueue + public T CreateCommandQueue1(in CommandQueueDescription description, Guid creatorID) where T : ID3D12CommandQueue { - Result result = CreateCommandQueue1(description, creatorID, typeof(T).GUID, out IntPtr nativePtr); - if (result.Failure) - return default; - + CreateCommandQueue1(description, creatorID, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return MarshallingHelpers.FromPointer(nativePtr); } @@ -30,12 +27,9 @@ public Result CreateCommandQueue1(in CommandQueueDescription description, Gui return result; } - public T? CreateShaderCacheSession(ShaderCacheSessionDescription description) where T : ID3D12ShaderCacheSession + public T CreateShaderCacheSession(ShaderCacheSessionDescription description) where T : ID3D12ShaderCacheSession { - Result result = CreateShaderCacheSession(ref description, typeof(T).GUID, out IntPtr nativePtr); - if (result.Failure) - return default; - + CreateShaderCacheSession(ref description, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return MarshallingHelpers.FromPointer(nativePtr); } diff --git a/src/Vortice.Direct3D12/Mappings.xml b/src/Vortice.Direct3D12/Mappings.xml index 0f0348fd..6e934a3c 100644 --- a/src/Vortice.Direct3D12/Mappings.xml +++ b/src/Vortice.Direct3D12/Mappings.xml @@ -96,6 +96,18 @@ Inverse Invalid + CreateShaderResourceView + UnrecognizedFormat + InvalidVideoPlaneSlice + CreateRenderTargetView + CreateUnorderedAccessView + CreateCommandList + CreateVertexShader + ExecuteCommandLists + WrongSwapChainBufferReference + SetRenderTargets + InvalidNumRenderTargets + CreateSharedResource AtomicCopyBuffer AcquireHandleForCapture InvalidArray @@ -255,7 +267,7 @@ CreateDomainShader InvalidShaderType CreateGeometryShader - CreateGeometryShaderWithStreamOutput + CreateGeometryShaderWithStreamOutput CreateGraphicsPipelineState DepthStencilView CreateHeap @@ -314,6 +326,137 @@ VertexShader SubObject WriteBufferImmediate + GetPrivateData + MoreData + MissingElement + InvalidNumEntries + InvalidPlaneSlice + OutputOutputStreamStrideUnused + OutputSlot0Expected + InvalidOutputSlot + InvalidComponentCount + OnlyOneElementPerSlot + InvalidCullMode + InvalidSlopeScaledDepthBias + InvalidDepthBiasClamp + GetCopyableFootprints + VideoEncoderHeap + VideoEncoder + InvalidDepthWriteMask + BlendOpAlpha + BlendOp + ShaderCacheSession + AlreadyPresent + StoreValue + HashCollision + InvalidGapDefinition + InvalidStartComponentAndComponentCount + InvalidOutputStreamStride + RepeatedOutput + MissingSemantic + CantHaveOnlyGaps + MaskMismatch + DeclTooComplex + MissingOutputSignature + InvalidFillMode + InvalidFrontFaceStencilFailOp + InvalidFrontFaceStencilZFailOp + InvalidFrontFaceStencilPassOp + InvalidFrontFaceStencilFunc + InvalidBackFaceStencilFailOp + InvalidBackFaceStencilZFailOp + InvalidBackFaceStencilPassOp + InvalidBackFaceStencilFunc + UnexpectedEntries + UnexpectedStrides + InvalidNumStrides + DoubleFloatOpsNotSupported + InvalidForcedSampleCount + DoubleExtensionsNotSupported + NotSupported + EmptyRect + ClearView + UpdateTileMappings + RootSignature + QueryHeap + CommandQueue + InvalidMiscFlags + UnrecognizedMiscFlags + UnrecognizedHeapType + UnrecognizedCpuPageProperties + UnrecognizedMemoryPool + CreateResourceAndHeap + NullHeapProperties + UnrecognizedHeapMiscFlags + GetCustomHeapProperties + RegisterIndex + ComponentType + RegisterMask + SystemValue + NeverWritten + AlwaysReads + MinPrecision + SemanticName + VertexShader + PixelShader + ComputeShader + HullShader + DomainShader + NullResourceProperties + NullHeap + GetResourceAllocationInfo + InvalidRDescs + CreateResource + UnrecognizedDimensionality + UnrecognizedLayout + InvalidMipLevels + InvalidSampleDesc + InvalidClearValue + UnrecognizedClearValueFormat + ClearValueDenormFlush + GetGpuVirtualAddress + BundleNotSupported + OpenCommandList + FailedCommandList + FormatMismatch + ResolveSubresource + CachedBlobAdapterMismatch + CachedBlobDriverVersionMismatch + CachedBlobDescMismatch + CachedBlobIgnored + GetHeapProperties + CreatePipelineLibrary + InvalidLibraryBlob + DriverVersionMismatch + PipelineLibrary + AdapterVersionMismatch + LoadPipeline + NameNotFound + SetEventOnMultipleFenceCompletion + VideoDecodeCommandList + VideoDecodeStream + VideoDecoder + SetDepthBounds + VideoDecodeCommandQueue + VideoProcessCommandList + VideoProcessCommandQueue + VideoProcessor + VideoProcessStream + RSSetShading + NonZero + CreateMeshShader + CreateMeshShaderWithStreamOutput + OutputExceedsMaxSize + GroupSharedExceedsMaxSize + MismatchedAmplificationShaderMeshShaderPayloadSize + CreateAmplificationShader + CreateShaderCacheSession + ShaderCacheControl + DeveloperMode + StateAlreadySet + IgnoredFlag + FindValue + NotFound @@ -757,7 +900,7 @@ - + @@ -769,7 +912,7 @@ - + @@ -786,7 +929,7 @@ - + diff --git a/src/Vortice.Direct3D12/Vortice.Direct3D12.csproj b/src/Vortice.Direct3D12/Vortice.Direct3D12.csproj index 486ac4a2..2b281756 100644 --- a/src/Vortice.Direct3D12/Vortice.Direct3D12.csproj +++ b/src/Vortice.Direct3D12/Vortice.Direct3D12.csproj @@ -7,6 +7,7 @@ true Direct3D12 bindings. + diff --git a/src/samples/HelloDirect3D11/D3D11GraphicsDevice.cs b/src/samples/HelloDirect3D11/D3D11GraphicsDevice.cs index 3a3b141f..9104f9d5 100644 --- a/src/samples/HelloDirect3D11/D3D11GraphicsDevice.cs +++ b/src/samples/HelloDirect3D11/D3D11GraphicsDevice.cs @@ -9,6 +9,7 @@ using Vortice.Direct3D; using Vortice.Direct3D11; using Vortice.DXGI; +using Vortice.DXGI.Debug; using Vortice.Mathematics; using static Vortice.Direct3D11.D3D11; using static Vortice.DXGI.DXGI; diff --git a/src/samples/HelloDirect3D12/D3D12GraphicsDevice.cs b/src/samples/HelloDirect3D12/D3D12GraphicsDevice.cs index 1cd01c76..58797309 100644 --- a/src/samples/HelloDirect3D12/D3D12GraphicsDevice.cs +++ b/src/samples/HelloDirect3D12/D3D12GraphicsDevice.cs @@ -18,6 +18,7 @@ using Vortice; using System.IO; using System.Drawing; +using Vortice.DXGI.Debug; namespace HelloDirect3D12 { diff --git a/src/samples/HelloDirect3D12Raytracing/D3D12GraphicsDevice.cs b/src/samples/HelloDirect3D12Raytracing/D3D12GraphicsDevice.cs index d9aff662..48c4b1b6 100644 --- a/src/samples/HelloDirect3D12Raytracing/D3D12GraphicsDevice.cs +++ b/src/samples/HelloDirect3D12Raytracing/D3D12GraphicsDevice.cs @@ -20,6 +20,7 @@ using Vortice; using ShaderResourceViewDimension = Vortice.Direct3D12.ShaderResourceViewDimension; using System.IO; +using Vortice.DXGI.Debug; namespace HelloDirect3D12Raytracing { @@ -38,7 +39,7 @@ public sealed class D3D12GraphicsDevice : IGraphicsDevice public readonly Window Window; public readonly IDXGIFactory4 DXGIFactory; - private readonly ID3D12Device5 _d3d12Device; + private readonly ID3D12Device5? _d3d12Device; private readonly ID3D12InfoQueue? _infoQueue; private readonly ID3D12Resource[] _renderTargets; private readonly ID3D12DescriptorHeap _rtvHeap; @@ -72,7 +73,7 @@ public sealed class D3D12GraphicsDevice : IGraphicsDevice private ulong _frameIndex; private int _backbufferIndex; - public ID3D12Device2 D3D12Device => _d3d12Device; + public ID3D12Device2 D3D12Device => _d3d12Device!; public ID3D12CommandQueue GraphicsQueue { get; } public IDXGISwapChain3 SwapChain { get; } @@ -89,20 +90,17 @@ public unsafe D3D12GraphicsDevice(bool validation, Window window) Window = window; { - if (validation && D3D12GetDebugInterface(out ID3D12Debug debug).Success) + if (validation && D3D12GetDebugInterface(out ID3D12Debug? debug).Success) { - debug.EnableDebugLayer(); - debug.Dispose(); + debug!.EnableDebugLayer(); + debug!.Dispose(); } else { validation = false; } - if (CreateDXGIFactory2(validation, out DXGIFactory).Failure) - { - throw new InvalidOperationException("Cannot create IDXGIFactory4"); - } + DXGIFactory = CreateDXGIFactory2(validation); using (IDXGIFactory6? factory6 = DXGIFactory.QueryInterfaceOrNull()) { @@ -110,10 +108,10 @@ public unsafe D3D12GraphicsDevice(bool validation, Window window) { for (int adapterIndex = 0; _d3d12Device == null && factory6.EnumAdapterByGpuPreference(adapterIndex, GpuPreference.HighPerformance, - out IDXGIAdapter1 adapter).Success; + out IDXGIAdapter1? adapter).Success; adapterIndex++) { - AdapterDescription1 desc = adapter.Description1; + AdapterDescription1 desc = adapter!.Description1; // Don't select the Basic Render Driver adapter. if ((desc.Flags & AdapterFlags.Software) != AdapterFlags.None) @@ -323,7 +321,7 @@ public unsafe D3D12GraphicsDevice(bool validation, Window window) globalRootSignatureStateObject, }; - _raytracingStateObject = _d3d12Device.CreateStateObject(new StateObjectDescription(StateObjectType.RaytracingPipeline, stateSubObjects)); + _raytracingStateObject = _d3d12Device!.CreateStateObject(new StateObjectDescription(StateObjectType.RaytracingPipeline, stateSubObjects)); } // Create the vertex buffer @@ -571,7 +569,7 @@ public void Dispose() SwapChain.Dispose(); _frameFence.Dispose(); GraphicsQueue.Dispose(); - _d3d12Device.Dispose(); + _d3d12Device!.Dispose(); _infoQueue?.Dispose(); DXGIFactory.Dispose(); diff --git a/src/samples/HelloDirect3D12Raytracing/Program.cs b/src/samples/HelloDirect3D12Raytracing/Program.cs index 3f6a8fb9..c4fa8a48 100644 --- a/src/samples/HelloDirect3D12Raytracing/Program.cs +++ b/src/samples/HelloDirect3D12Raytracing/Program.cs @@ -19,7 +19,7 @@ protected override void InitializeBeforeRun() validation = true; #endif - _graphicsDevice = new D3D12GraphicsDevice(validation, MainWindow); + _graphicsDevice = new D3D12GraphicsDevice(validation, MainWindow!); } }