From 0d786ebe662c98ffca4ffefb9e663585df5dde78 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 18 Oct 2023 02:08:50 +0200 Subject: [PATCH] Update namespaces in ComputeSharp.D3D12MemoryAllocator --- .../D3D12MemoryAllocatorFactory.cs | 2 +- .../Extensions/AllocatorExtensions.cs | 20 ++++++++-------- .../Extensions/ID3D12DeviceExtensions.cs | 16 +++++++------ .../Interop/ID3D12AllocationImpl.cs | 4 ++-- .../ID3D12MemoryAllocatorFactoryImpl.cs | 7 +++--- .../Interop/ID3D12MemoryAllocatorImpl.cs | 23 +++++++++++-------- 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/ComputeSharp.D3D12MemoryAllocator/D3D12MemoryAllocatorFactory.cs b/src/ComputeSharp.D3D12MemoryAllocator/D3D12MemoryAllocatorFactory.cs index 24343f83..57add46a 100644 --- a/src/ComputeSharp.D3D12MemoryAllocator/D3D12MemoryAllocatorFactory.cs +++ b/src/ComputeSharp.D3D12MemoryAllocator/D3D12MemoryAllocatorFactory.cs @@ -2,7 +2,7 @@ using System; using System.Runtime.InteropServices; using ComputeSharp.Core.Extensions; using ComputeSharp.D3D12MemoryAllocator.Interop; -using TerraFX.Interop.Windows; +using ComputeSharp.Win32; namespace ComputeSharp.D3D12MemoryAllocator; diff --git a/src/ComputeSharp.D3D12MemoryAllocator/Extensions/AllocatorExtensions.cs b/src/ComputeSharp.D3D12MemoryAllocator/Extensions/AllocatorExtensions.cs index 7d5156f3..e15b9bf3 100644 --- a/src/ComputeSharp.D3D12MemoryAllocator/Extensions/AllocatorExtensions.cs +++ b/src/ComputeSharp.D3D12MemoryAllocator/Extensions/AllocatorExtensions.cs @@ -1,9 +1,11 @@ using ComputeSharp.Core.Extensions; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; -using static TerraFX.Interop.DirectX.D3D12_CPU_PAGE_PROPERTY; -using static TerraFX.Interop.DirectX.D3D12_HEAP_TYPE; -using static TerraFX.Interop.DirectX.D3D12_MEMORY_POOL; +using ComputeSharp.Win32; +using static ComputeSharp.Win32.D3D12_CPU_PAGE_PROPERTY; +using static ComputeSharp.Win32.D3D12_HEAP_TYPE; +using static ComputeSharp.Win32.D3D12_MEMORY_POOL; +using D3D12MA_Allocator = TerraFX.Interop.DirectX.D3D12MA_Allocator; +using D3D12MA_Pool = TerraFX.Interop.DirectX.D3D12MA_Pool; +using D3D12MA_POOL_DESC = TerraFX.Interop.DirectX.D3D12MA_POOL_DESC; namespace ComputeSharp.D3D12MemoryAllocator.Extensions; @@ -24,11 +26,11 @@ internal static unsafe class AllocatorExtensions D3D12MA_POOL_DESC poolDesc = default; poolDesc.HeapProperties.CreationNodeMask = 1; poolDesc.HeapProperties.VisibleNodeMask = 1; - poolDesc.HeapProperties.Type = D3D12_HEAP_TYPE_CUSTOM; - poolDesc.HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK; - poolDesc.HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0; + poolDesc.HeapProperties.Type = (TerraFX.Interop.DirectX.D3D12_HEAP_TYPE)D3D12_HEAP_TYPE_CUSTOM; + poolDesc.HeapProperties.CPUPageProperty = (TerraFX.Interop.DirectX.D3D12_CPU_PAGE_PROPERTY)D3D12_CPU_PAGE_PROPERTY_WRITE_BACK; + poolDesc.HeapProperties.MemoryPoolPreference = (TerraFX.Interop.DirectX.D3D12_MEMORY_POOL)D3D12_MEMORY_POOL_L0; - allocator.CreatePool(&poolDesc, pool.GetAddressOf()).Assert(); + ((HRESULT)(int)allocator.CreatePool(&poolDesc, pool.GetAddressOf())).Assert(); return pool.Move(); } diff --git a/src/ComputeSharp.D3D12MemoryAllocator/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp.D3D12MemoryAllocator/Extensions/ID3D12DeviceExtensions.cs index d6e79ace..8facda9f 100644 --- a/src/ComputeSharp.D3D12MemoryAllocator/Extensions/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp.D3D12MemoryAllocator/Extensions/ID3D12DeviceExtensions.cs @@ -1,9 +1,11 @@ -using ComputeSharp.Core.Extensions; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; using System.Runtime.CompilerServices; +using ComputeSharp.Core.Extensions; +using ComputeSharp.Win32; +using D3D12MA_Allocator = TerraFX.Interop.DirectX.D3D12MA_Allocator; +using D3D12MA_ALLOCATOR_DESC = TerraFX.Interop.DirectX.D3D12MA_ALLOCATOR_DESC; +using D3D12MemAlloc = TerraFX.Interop.DirectX.D3D12MemAlloc; -namespace ComputeSharp.Graphics.Extensions; +namespace ComputeSharp.D3D12MemoryAllocator.Extensions; /// /// A with extensions for the type. @@ -21,10 +23,10 @@ internal static unsafe class ID3D12DeviceExtensions using ComPtr allocator = default; D3D12MA_ALLOCATOR_DESC allocatorDesc = default; - allocatorDesc.pDevice = (ID3D12Device*)Unsafe.AsPointer(ref d3D12Device); - allocatorDesc.pAdapter = dxgiAdapter; + allocatorDesc.pDevice = (TerraFX.Interop.DirectX.ID3D12Device*)Unsafe.AsPointer(ref d3D12Device); + allocatorDesc.pAdapter = (TerraFX.Interop.DirectX.IDXGIAdapter*)dxgiAdapter; - D3D12MemAlloc.D3D12MA_CreateAllocator(&allocatorDesc, allocator.GetAddressOf()).Assert(); + ((HRESULT)(int)D3D12MemAlloc.D3D12MA_CreateAllocator(&allocatorDesc, allocator.GetAddressOf())).Assert(); return allocator.Move(); } diff --git a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12AllocationImpl.cs b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12AllocationImpl.cs index f8d20d4b..65018e87 100644 --- a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12AllocationImpl.cs +++ b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12AllocationImpl.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; using ComputeSharp.Interop.Allocation; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; +using ComputeSharp.Win32; +using D3D12MA_Allocation = TerraFX.Interop.DirectX.D3D12MA_Allocation; namespace ComputeSharp.D3D12MemoryAllocator.Interop; diff --git a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorFactoryImpl.cs b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorFactoryImpl.cs index 35aa47dc..39c35a28 100644 --- a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorFactoryImpl.cs +++ b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorFactoryImpl.cs @@ -5,9 +5,10 @@ using System.Threading; using ComputeSharp.D3D12MemoryAllocator.Extensions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Interop.Allocation; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; -using static TerraFX.Interop.DirectX.D3D12_FEATURE; +using ComputeSharp.Win32; +using static ComputeSharp.Win32.D3D12_FEATURE; +using D3D12MA_Allocator = TerraFX.Interop.DirectX.D3D12MA_Allocator; +using D3D12MA_Pool = TerraFX.Interop.DirectX.D3D12MA_Pool; namespace ComputeSharp.D3D12MemoryAllocator.Interop; diff --git a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs index 58471658..ea7c3d0a 100644 --- a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs +++ b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs @@ -3,9 +3,12 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; using ComputeSharp.Interop.Allocation; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; -using static TerraFX.Interop.DirectX.D3D12MA_ALLOCATION_FLAGS; +using ComputeSharp.Win32; +using D3D12MA_Allocation = TerraFX.Interop.DirectX.D3D12MA_Allocation; +using D3D12MA_ALLOCATION_DESC = TerraFX.Interop.DirectX.D3D12MA_ALLOCATION_DESC; +using D3D12MA_ALLOCATION_FLAGS = TerraFX.Interop.DirectX.D3D12MA_ALLOCATION_FLAGS; +using D3D12MA_Allocator = TerraFX.Interop.DirectX.D3D12MA_Allocator; +using D3D12MA_Pool = TerraFX.Interop.DirectX.D3D12MA_Pool; namespace ComputeSharp.D3D12MemoryAllocator.Interop; @@ -180,10 +183,12 @@ internal unsafe struct ID3D12MemoryAllocatorImpl BOOL clearAllocation, ID3D12Allocation** allocation) { - D3D12MA_ALLOCATION_FLAGS allocationFlags = clearAllocation ? D3D12MA_ALLOCATION_FLAG_COMMITTED : D3D12MA_ALLOCATION_FLAG_NONE; + D3D12MA_ALLOCATION_FLAGS allocationFlags = clearAllocation ? + D3D12MA_ALLOCATION_FLAGS.D3D12MA_ALLOCATION_FLAG_COMMITTED : + D3D12MA_ALLOCATION_FLAGS.D3D12MA_ALLOCATION_FLAG_NONE; D3D12MA_ALLOCATION_DESC allocationDesc = default; - allocationDesc.HeapType = heapType; + allocationDesc.HeapType = (TerraFX.Interop.DirectX.D3D12_HEAP_TYPE)heapType; allocationDesc.Flags = allocationFlags; allocationDesc.CustomPool = @this->pool; @@ -191,16 +196,16 @@ internal unsafe struct ID3D12MemoryAllocatorImpl using ComPtr d3D12Resource = default; // Invoke D3D12MA and create an allocation and resource - HRESULT hresult = @this->allocator->CreateResource( + TerraFX.Interop.Windows.HRESULT hresult = @this->allocator->CreateResource( pAllocDesc: &allocationDesc, - pResourceDesc: resourceDescription, - InitialResourceState: resourceStates, + pResourceDesc: (TerraFX.Interop.DirectX.D3D12_RESOURCE_DESC*)resourceDescription, + InitialResourceState: (TerraFX.Interop.DirectX.D3D12_RESOURCE_STATES)resourceStates, pOptimizedClearValue: null, ppAllocation: d3D12MA_allocation.GetAddressOf(), riidResource: Windows.__uuidof(), ppvResource: (void**)d3D12Resource.GetAddressOf()); - if (!Windows.SUCCEEDED(hresult)) + if (!TerraFX.Interop.Windows.Windows.SUCCEEDED(hresult)) { return hresult; }