diff --git a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs index eb601f4e..58471658 100644 --- a/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs +++ b/src/ComputeSharp.D3D12MemoryAllocator/Interop/ID3D12MemoryAllocatorImpl.cs @@ -2,7 +2,6 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; -using ComputeSharp.Core.Extensions; using ComputeSharp.Interop.Allocation; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; @@ -199,7 +198,7 @@ internal unsafe struct ID3D12MemoryAllocatorImpl pOptimizedClearValue: null, ppAllocation: d3D12MA_allocation.GetAddressOf(), riidResource: Windows.__uuidof(), - ppvResource: d3D12Resource.GetVoidAddressOf()); + ppvResource: (void**)d3D12Resource.GetAddressOf()); if (!Windows.SUCCEEDED(hresult)) { diff --git a/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs b/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs index 250ba163..8b8e0ced 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs @@ -115,7 +115,7 @@ public static class ReflectionServices DirectX.DxcCreateInstance( (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in CLSID.CLSID_DxcLibrary)), Windows.__uuidof(), - dxcUtils.GetVoidAddressOf()).Assert(); + (void**)dxcUtils.GetAddressOf()).Assert(); using ComPtr d3D12ShaderReflection = default; @@ -126,7 +126,7 @@ public static class ReflectionServices dxcUtils.Get()->CreateReflection( &dxcBuffer, Windows.__uuidof(), - d3D12ShaderReflection.GetVoidAddressOf()).Assert(); + (void**)d3D12ShaderReflection.GetAddressOf()).Assert(); D3D12_SHADER_DESC d3D12ShaderDescription; diff --git a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs index 7eac1c94..ff33ffde 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs @@ -46,12 +46,12 @@ internal sealed unsafe partial class ShaderCompiler DirectX.DxcCreateInstance( (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in CLSID.CLSID_DxcCompiler)), Windows.__uuidof(), - dxcCompiler.GetVoidAddressOf()).Assert(); + (void**)dxcCompiler.GetAddressOf()).Assert(); DirectX.DxcCreateInstance( (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in CLSID.CLSID_DxcLibrary)), Windows.__uuidof(), - dxcLibrary.GetVoidAddressOf()).Assert(); + (void**)dxcLibrary.GetAddressOf()).Assert(); dxcLibrary.Get()->CreateIncludeHandler(dxcIncludeHandler.GetAddressOf()).Assert(); diff --git a/src/ComputeSharp.WinUI/Extensions/IDXGIAdapterExtensions.cs b/src/ComputeSharp.WinUI/Extensions/IDXGIAdapterExtensions.cs index 1d581f8a..5349e613 100644 --- a/src/ComputeSharp.WinUI/Extensions/IDXGIAdapterExtensions.cs +++ b/src/ComputeSharp.WinUI/Extensions/IDXGIAdapterExtensions.cs @@ -22,7 +22,7 @@ internal static unsafe class IDXGIAdapterExtensions { using ComPtr dxgiAdapter1 = default; - dxgiAdapter.QueryInterface(Win32.__uuidof(), dxgiAdapter1.GetVoidAddressOf()).Assert(); + dxgiAdapter.QueryInterface(Win32.__uuidof(), (void**)dxgiAdapter1.GetAddressOf()).Assert(); using ComPtr dxgiOutput = default; diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs index 7909fd04..916fa9c5 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs @@ -29,24 +29,6 @@ internal static class ComPtrExtensions return ref Unsafe.As, ComPtr>(ref Unsafe.AsRef(in ptr)); } - /// - /// Gets the address of the current instance as a raw double pointer. - /// - /// The type to wrap in the current instance. - /// The input instance to get the address for. - /// The raw pointer to the input instance. - /// This method is only valid when the current instance is on the stack or pinned. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void** GetVoidAddressOf(this in ComPtr ptr) -#if NET6_0_OR_GREATER - where T : unmanaged, IUnknown.Interface -#else - where T : unmanaged -#endif - { - return (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in ptr)); - } - /// /// Moves the current instance and resets it without releasing the reference. /// diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs index c77fd2a2..cb9a7742 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs @@ -80,7 +80,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12ResourceStates, null, Windows.__uuidof(), - d3D12Resource.GetVoidAddressOf()).Assert(); + (void**)d3D12Resource.GetAddressOf()).Assert(); return d3D12Resource.Move(); } @@ -140,7 +140,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12ResourceStates, null, Windows.__uuidof(), - d3D12Resource.GetVoidAddressOf()).Assert(); + (void**)d3D12Resource.GetAddressOf()).Assert(); return d3D12Resource.Move(); } @@ -202,7 +202,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12ResourceStates, null, Windows.__uuidof(), - d3D12Resource.GetVoidAddressOf()).Assert(); + (void**)d3D12Resource.GetAddressOf()).Assert(); return d3D12Resource.Move(); } @@ -266,7 +266,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12ResourceStates, null, Windows.__uuidof(), - d3D12Resource.GetVoidAddressOf()).Assert(); + (void**)d3D12Resource.GetAddressOf()).Assert(); return d3D12Resource.Move(); } @@ -281,7 +281,7 @@ internal static unsafe class ID3D12DeviceExtensions { ComPtr d3D12InfoQueue = default; - d3D12Device.QueryInterface(Windows.__uuidof(), d3D12InfoQueue.GetVoidAddressOf()).Assert(); + d3D12Device.QueryInterface(Windows.__uuidof(), (void**)d3D12InfoQueue.GetAddressOf()).Assert(); D3D12_MESSAGE_ID* d3D12MessageIds = stackalloc D3D12_MESSAGE_ID[3] { @@ -332,7 +332,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateCommandQueue( &d3D12CommandQueueDesc, Windows.__uuidof(), - d3D12CommandQueue.GetVoidAddressOf()).Assert(); + (void**)d3D12CommandQueue.GetAddressOf()).Assert(); return d3D12CommandQueue.Move(); } @@ -351,7 +351,7 @@ internal static unsafe class ID3D12DeviceExtensions 0, D3D12_FENCE_FLAG_NONE, Windows.__uuidof(), - d3D12Fence.GetVoidAddressOf()).Assert(); + (void**)d3D12Fence.GetAddressOf()).Assert(); return d3D12Fence.Move(); } @@ -377,7 +377,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateDescriptorHeap( &d3D12DescriptorHeapDesc, Windows.__uuidof(), - d3D12DescriptorHeap.GetVoidAddressOf()).Assert(); + (void**)d3D12DescriptorHeap.GetAddressOf()).Assert(); return d3D12DescriptorHeap.Move(); } @@ -545,7 +545,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateCommandAllocator( d3D12CommandListType, Windows.__uuidof(), - d3D12CommandAllocator.GetVoidAddressOf()).Assert(); + (void**)d3D12CommandAllocator.GetAddressOf()).Assert(); return d3D12CommandAllocator.Move(); } @@ -573,7 +573,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12CommandAllocator, d3D12PipelineState, Windows.__uuidof(), - d3D12GraphicsCommandList.GetVoidAddressOf()).Assert(); + (void**)d3D12GraphicsCommandList.GetAddressOf()).Assert(); return d3D12GraphicsCommandList.Move(); } diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs index 8e336831..df41949f 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs @@ -126,11 +126,11 @@ partial class DeviceHelper this.index, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, Windows.__uuidof(), - dxgiAdapter1.GetVoidAddressOf()); + (void**)dxgiAdapter1.GetAddressOf()); if (enumAdapters1Result == DXGI.DXGI_ERROR_NOT_FOUND) { - this.dxgiFactory6.Get()->EnumWarpAdapter(Windows.__uuidof(), dxgiAdapter1.GetVoidAddressOf()).Assert(); + this.dxgiFactory6.Get()->EnumWarpAdapter(Windows.__uuidof(), (void**)dxgiAdapter1.GetAddressOf()).Assert(); DXGI_ADAPTER_DESC1 dxgiDescription1; @@ -151,7 +151,7 @@ partial class DeviceHelper dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, Windows.__uuidof(), - d3D12Device.GetVoidAddressOf()).Assert(); + (void**)d3D12Device.GetAddressOf()).Assert(); this.graphicsDevice = GetOrCreateDevice(d3D12Device.Get(), (IDXGIAdapter*)dxgiAdapter1.Get(), &dxgiDescription1); this.isCompleted = true; @@ -192,7 +192,7 @@ partial class DeviceHelper dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, Windows.__uuidof(), - d3D12Device.GetVoidAddressOf()).Assert(); + (void**)d3D12Device.GetAddressOf()).Assert(); if (d3D12Device.Get()->IsShaderModelSupported(D3D_SHADER_MODEL_6_0)) { diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs index 6d51f371..0c190ede 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs @@ -3,7 +3,6 @@ using System.ComponentModel; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; -using ComputeSharp.Core.Extensions; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using static TerraFX.Interop.DirectX.D3D12_MESSAGE_ID; @@ -105,7 +104,7 @@ partial class DeviceHelper // Get the DRED data int hresult = device.D3D12Device->QueryInterface( riid: Windows.__uuidof(), - ppvObject: d3D12DeviceRemovedExtendedData.GetVoidAddressOf()); + ppvObject: (void**)d3D12DeviceRemovedExtendedData.GetAddressOf()); default(Win32Exception).ThrowIfFailed(hresult); diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs index 71813ff1..4d8bf14d 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs @@ -44,7 +44,7 @@ partial class DeviceHelper using ComPtr dxgiFactory4 = default; - DirectX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof(), dxgiFactory4.GetVoidAddressOf()).Assert(); + DirectX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof(), (void**)dxgiFactory4.GetAddressOf()).Assert(); HRESULT result = dxgiFactory4.CopyTo(dxgiFactory6); @@ -73,7 +73,7 @@ partial class DeviceHelper using ComPtr d3D12Debug = default; using ComPtr d3D12Debug1 = default; - DirectX.D3D12GetDebugInterface(Windows.__uuidof(), d3D12Debug.GetVoidAddressOf()).Assert(); + DirectX.D3D12GetDebugInterface(Windows.__uuidof(), (void**)d3D12Debug.GetAddressOf()).Assert(); d3D12Debug.Get()->EnableDebugLayer(); @@ -93,7 +93,7 @@ partial class DeviceHelper DirectX.D3D12GetDebugInterface( riid: Windows.__uuidof(), - ppvDebug: d3D12DeviceRemovedExtendedDataSettings.GetVoidAddressOf()).Assert(); + ppvDebug: (void**)d3D12DeviceRemovedExtendedDataSettings.GetAddressOf()).Assert(); // Enable the auto-breadcrumbs and page faults reporting d3D12DeviceRemovedExtendedDataSettings.Get()->SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT.D3D12_DRED_ENABLEMENT_FORCED_ON); diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs index 5e008830..2bd3540e 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs @@ -71,7 +71,7 @@ internal static partial class DeviceHelper i++, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, Windows.__uuidof(), - dxgiAdapter1.GetVoidAddressOf()); + (void**)dxgiAdapter1.GetAddressOf()); if (enumAdapters1Result == DXGI.DXGI_ERROR_NOT_FOUND) { @@ -101,7 +101,7 @@ internal static partial class DeviceHelper dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, Windows.__uuidof(), - d3D12DeviceCandidate.GetVoidAddressOf()); + (void**)d3D12DeviceCandidate.GetAddressOf()); // Check and throw if the device is a device lost state and not disposed properly default(InvalidOperationException).ThrowIf(createDeviceResult.IsDeviceLostReason()); @@ -135,7 +135,7 @@ internal static partial class DeviceHelper using ComPtr dxgiAdapter1 = default; - dxgiFactory6.Get()->EnumWarpAdapter(Windows.__uuidof(), dxgiAdapter1.GetVoidAddressOf()).Assert(); + dxgiFactory6.Get()->EnumWarpAdapter(Windows.__uuidof(), (void**)dxgiAdapter1.GetAddressOf()).Assert(); dxgiAdapter1.Get()->GetDesc1(dxgiDescription1).Assert(); @@ -145,7 +145,7 @@ internal static partial class DeviceHelper dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, Windows.__uuidof(), - d3D12DeviceCandidate.GetVoidAddressOf()); + (void**)d3D12DeviceCandidate.GetAddressOf()); default(InvalidOperationException).ThrowIf(createDeviceResult.IsDeviceLostReason()); diff --git a/src/ComputeSharp/Graphics/Helpers/WICHelper.cs b/src/ComputeSharp/Graphics/Helpers/WICHelper.cs index c1fde3b6..2fdca628 100644 --- a/src/ComputeSharp/Graphics/Helpers/WICHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/WICHelper.cs @@ -30,7 +30,7 @@ internal sealed unsafe class WICHelper null, (uint)CLSCTX.CLSCTX_INPROC_SERVER, Windows.__uuidof(), - wicImagingFactory2.GetVoidAddressOf()).Assert(); + (void**)wicImagingFactory2.GetAddressOf()).Assert(); this.wicImagingFactory2 = wicImagingFactory2.Move(); } diff --git a/src/ComputeSharp/Shaders/Extensions/Interop/ID3D12DeviceExtensions.cs b/src/ComputeSharp/Shaders/Extensions/Interop/ID3D12DeviceExtensions.cs index e93441c7..3cb499f6 100644 --- a/src/ComputeSharp/Shaders/Extensions/Interop/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp/Shaders/Extensions/Interop/ID3D12DeviceExtensions.cs @@ -83,7 +83,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D3Blob.Get()->GetBufferPointer(), d3D3Blob.Get()->GetBufferSize(), Windows.__uuidof(), - d3D12RootSignature.GetVoidAddressOf()).Assert(); + (void**)d3D12RootSignature.GetAddressOf()).Assert(); return d3D12RootSignature.Move(); } @@ -113,7 +113,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateComputePipelineState( &d3D12ComputePipelineStateDescription, Windows.__uuidof(), - d3D12PipelineState.GetVoidAddressOf()).Assert(); + (void**)d3D12PipelineState.GetAddressOf()).Assert(); return d3D12PipelineState.Move(); }