Skip to content

Commit

Permalink
[ENH] DXGI: dxgidebug.h under Vortice.DXGI.Debug namespace.
Browse files Browse the repository at this point in the history
[ENH] Direct3D12: Improve Debug MessageID enum values names.
  • Loading branch information
amerkoleci committed Jun 21, 2021
1 parent 94ecf82 commit 0963d97
Show file tree
Hide file tree
Showing 19 changed files with 526 additions and 74 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using SharpGen.Runtime;

namespace Vortice.DXGI
namespace Vortice.DXGI.Debug
{
public partial class IDXGIInfoQueue
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Runtime.InteropServices;

namespace Vortice.DXGI
namespace Vortice.DXGI.Debug
{
public partial class InfoQueueFilter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Runtime.InteropServices;
using SharpGen.Runtime;

namespace Vortice.DXGI
namespace Vortice.DXGI.Debug
{
public partial class InfoQueueFilterDescription
{
Expand Down
29 changes: 29 additions & 0 deletions src/Vortice.DXGI/IDXGIDecodeSwapChain.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
17 changes: 13 additions & 4 deletions src/Vortice.DXGI/IDXGISurface2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@ namespace Vortice.DXGI
{
public partial class IDXGISurface2
{
public T? GetResource<T>(out int subresourceIndex) where T : ComObject
public T GetResource<T>(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<T>(nativePtr);
}

public Result GetResource<T>(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<T>(nativePtr);
parentResource = MarshallingHelpers.FromPointer<T>(nativePtr);
return result;
}
}
}
4 changes: 3 additions & 1 deletion src/Vortice.DXGI/Mappings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<sdk name="StdLib" />
<include-dir override="true">$(THIS_CONFIG_PATH)/../native/include/directx</include-dir>

<include file="dxgidebug.h" namespace="Vortice.DXGI" attach="true"/>
<include file="dxgidebug.h" namespace="Vortice.DXGI.Debug" attach="true" output="Debug" />

<include file="dxgi.h" namespace="Vortice.DXGI" attach="true"/>
<include file="dxgi1_2.h" namespace="Vortice.DXGI" attach="true"/>
Expand Down Expand Up @@ -112,6 +112,7 @@
<map field="DXGI_SWAP_CHAIN_DESC::Windowed" name="IsWindowed" />
<map field="DXGI_SWAP_CHAIN_DESC[12]?::BufferUsage" name="Usage" type="DXGI_USAGE_ENUM"/>
<map field="DXGI_SWAP_CHAIN_DESC[12]?::Flags" type="DXGI_SWAP_CHAIN_FLAG" />
<map field="DXGI_DECODE_SWAP_CHAIN_DESC::Flags" type="DXGI_SWAP_CHAIN_FLAG" />

<map struct="DXGI_PRESENT_PARAMETERS" native="true" marshal="true" marshalto="true"/>
<remove field="DXGI_PRESENT_PARAMETERS::.*"/>
Expand Down Expand Up @@ -213,6 +214,7 @@
<map param="IDXGIAdapter3::RegisterVideoMemoryBudgetChangeNotificationEvent::pdwCookie" return="true"/>

<!-- IDXGIDecodeSwapChain -->
<map method="IDXGIDecodeSwapChain::PresentBuffer" hresult="true" check="false"/>
<map param="IDXGIDecodeSwapChain::PresentBuffer::Flags" type="DXGI_PRESENT_FLAGS" />

<!-- IDXGIDevice -->
Expand Down
3 changes: 3 additions & 0 deletions src/Vortice.DXGI/Vortice.DXGI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
<ItemGroup>
<ProjectReference Include="..\Vortice.DirectX\Vortice.DirectX.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Debug\" />
</ItemGroup>

</Project>
118 changes: 107 additions & 11 deletions src/Vortice.Direct3D12/ID3D12Device4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Vortice.Direct3D12
{
public partial class ID3D12Device4
{
#region CreateCommandList1
public T CreateCommandList1<T>(CommandListType type, CommandListFlags commandListFlags = CommandListFlags.None) where T : ID3D12GraphicsCommandList1
{
CreateCommandList1(0, type, commandListFlags, typeof(T).GUID, out IntPtr nativePtr).CheckError();
Expand Down Expand Up @@ -37,14 +38,58 @@ public Result CreateCommandList1<T>(int nodeMask, CommandListType type, CommandL
commandList = MarshallingHelpers.FromPointer<T>(nativePtr);
return result;
}
#endregion

public T? CreateCommittedResource1<T>(
#region CreateCommittedResource1
public T CreateCommittedResource1<T>(
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<T>(nativePtr);
}

public Result CreateCommittedResource1<T>(
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<T>(nativePtr);
return result;
}

public Result CreateCommittedResource1<T>(
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,
Expand All @@ -53,45 +98,96 @@ public Result CreateCommandList1<T>(int nodeMask, CommandListType type, CommandL
protectedSession,
typeof(T).GUID, out IntPtr nativePtr);
if (result.Failure)
return default;
{
resource = default;
return result;
}

resource = MarshallingHelpers.FromPointer<T>(nativePtr);
return result;
}
#endregion

#region CreateHeap1
public T CreateHeap1<T>(HeapDescription description, ID3D12ProtectedResourceSession protectedSession) where T : ID3D12Heap1
{
CreateHeap1(ref description, protectedSession, typeof(T).GUID, out IntPtr nativePtr).CheckError();
return MarshallingHelpers.FromPointer<T>(nativePtr);
}

public T? CreateHeap1<T>(HeapDescription description, ID3D12ProtectedResourceSession protectedSession) where T : ID3D12Heap1
public Result CreateHeap1<T>(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<T>(nativePtr);
return result;
}
#endregion

#region CreateProtectedResourceSession
public T CreateProtectedResourceSession<T>(ProtectedResourceSessionDescription description) where T : ID3D12ProtectedResourceSession
{
CreateProtectedResourceSession(description, typeof(T).GUID, out IntPtr nativePtr).CheckError();
return MarshallingHelpers.FromPointer<T>(nativePtr);
}

public T? CreateProtectedResourceSession<T>(ProtectedResourceSessionDescription description) where T : ID3D12ProtectedResourceSession
public Result CreateProtectedResourceSession<T>(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<T>(nativePtr);
return result;
}
#endregion

#region CreateReservedResource1
public T CreateReservedResource1<T>(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<T>(nativePtr);
}

public T? CreateReservedResource1<T>(ResourceDescription description, ResourceStates initialState, ClearValue clearValue, ID3D12ProtectedResourceSession protectedResourceSession) where T : ID3D12Resource1
public Result CreateReservedResource1<T>(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<T>(nativePtr);
return result;
}

public T CreateReservedResource1<T>(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<T>(nativePtr);
}

public T? CreateReservedResource1<T>(ResourceDescription description, ResourceStates initialState, ID3D12ProtectedResourceSession protectedResourceSession) where T : ID3D12Resource1
public Result CreateReservedResource1<T>(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<T>(nativePtr);
resource = MarshallingHelpers.FromPointer<T>(nativePtr);
return result;
}
#endregion
}
}
Loading

0 comments on commit 0963d97

Please sign in to comment.