diff --git a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs index 26ddb260..ea816a6e 100644 --- a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs +++ b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs @@ -1,7 +1,6 @@ using System; using ComputeSharp.Interop; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; namespace ComputeSharp.SwapChain.Backend; @@ -88,7 +87,7 @@ internal sealed class SwapChainApplication : Win32Application // Get the underlying ID3D12Device in use fixed (ID3D12Device** d3D12Device = this.d3D12Device) { - _ = InteropServices.TryGetID3D12Device(Gpu.Default, FX.__uuidof(), (void**)d3D12Device); + _ = InteropServices.TryGetID3D12Device(Gpu.Default, Windows.__uuidof(), (void**)d3D12Device); } // Create the direct command queue to use @@ -102,7 +101,7 @@ internal sealed class SwapChainApplication : Win32Application _ = d3D12Device.Get()->CreateCommandQueue( &d3D12CommandQueueDesc, - FX.__uuidof(), + Windows.__uuidof(), (void**)d3D12CommandQueue); } @@ -112,7 +111,7 @@ internal sealed class SwapChainApplication : Win32Application _ = this.d3D12Device.Get()->CreateFence( 0, D3D12_FENCE_FLAGS.D3D12_FENCE_FLAG_NONE, - FX.__uuidof(), + Windows.__uuidof(), (void**)d3D12Fence); } @@ -121,7 +120,7 @@ internal sealed class SwapChainApplication : Win32Application { using ComPtr dxgiFactory2 = default; - _ = FX.CreateDXGIFactory2(FX.DXGI_CREATE_FACTORY_DEBUG, FX.__uuidof(), (void**)dxgiFactory2.GetAddressOf()); + _ = Windows.CreateDXGIFactory2(Windows.DXGI_CREATE_FACTORY_DEBUG, Windows.__uuidof(), (void**)dxgiFactory2.GetAddressOf()); DXGI_SWAP_CHAIN_DESC1 dxgiSwapChainDesc1 = default; dxgiSwapChainDesc1.AlphaMode = DXGI_ALPHA_MODE.DXGI_ALPHA_MODE_IGNORE; @@ -149,7 +148,7 @@ internal sealed class SwapChainApplication : Win32Application { this.d3D12Device.Get()->CreateCommandAllocator( D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT, - FX.__uuidof(), + Windows.__uuidof(), (void**)d3D12CommandAllocator); } @@ -161,7 +160,7 @@ internal sealed class SwapChainApplication : Win32Application D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT, d3D12CommandAllocator, null, - FX.__uuidof(), + Windows.__uuidof(), (void**)d3D12GraphicsCommandList); } @@ -206,8 +205,8 @@ internal sealed class SwapChainApplication : Win32Application fixed (ID3D12Resource** d3D12Resource0 = this.d3D12Resource0) fixed (ID3D12Resource** d3D12Resource1 = this.d3D12Resource1) { - _ = dxgiSwapChain1.Get()->GetBuffer(0, FX.__uuidof(), (void**)d3D12Resource0); - _ = dxgiSwapChain1.Get()->GetBuffer(1, FX.__uuidof(), (void**)d3D12Resource1); + _ = dxgiSwapChain1.Get()->GetBuffer(0, Windows.__uuidof(), (void**)d3D12Resource0); + _ = dxgiSwapChain1.Get()->GetBuffer(1, Windows.__uuidof(), (void**)d3D12Resource1); } this.texture?.Dispose(); @@ -236,7 +235,7 @@ internal sealed class SwapChainApplication : Win32Application using ComPtr d3D12Resource = default; // Get the underlying ID3D12Resource pointer for the texture - _ = InteropServices.TryGetID3D12Resource(this.texture!, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + _ = InteropServices.TryGetID3D12Resource(this.texture!, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); // Get the target back buffer to update ID3D12Resource* d3D12ResourceBackBuffer = this.currentBufferIndex switch diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs index 3b002576..72cac2fe 100644 --- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs +++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs @@ -5,7 +5,6 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; namespace ComputeSharp.SwapChain.Backend; @@ -52,7 +51,7 @@ internal unsafe static class Win32ApplicationRunner { Win32ApplicationRunner.application = application; - IntPtr hInstance = FX.GetModuleHandleW(null); + IntPtr hInstance = Windows.GetModuleHandleW(null); fixed (char* name = Assembly.GetExecutingAssembly().FullName) fixed (char* windowTitle = application.GetType().ToString()) @@ -61,33 +60,33 @@ internal unsafe static class Win32ApplicationRunner WNDCLASSEXW windowClassEx = new() { cbSize = (uint)sizeof(WNDCLASSEXW), - style = FX.CS_HREDRAW | FX.CS_VREDRAW, + style = Windows.CS_HREDRAW | Windows.CS_VREDRAW, lpfnWndProc = &WindowProc, hInstance = hInstance, - hCursor = FX.LoadCursorW(IntPtr.Zero, FX.MAKEINTRESOURCE(32512)), + hCursor = Windows.LoadCursorW(IntPtr.Zero, Windows.MAKEINTRESOURCE(32512)), lpszClassName = (ushort*)name }; // Register the window class - _ = FX.RegisterClassExW(&windowClassEx); + _ = Windows.RegisterClassExW(&windowClassEx); Rectangle windowRect = new(0, 0, 1280, 720); // Set the target window size - _ = FX.AdjustWindowRect((RECT*)&windowRect, FX.WS_OVERLAPPEDWINDOW, FX.FALSE); + _ = Windows.AdjustWindowRect((RECT*)&windowRect, Windows.WS_OVERLAPPEDWINDOW, Windows.FALSE); uint height = (uint)(windowRect.Bottom - windowRect.Top), width = (uint)(windowRect.Right - windowRect.Left); // Create the window and store a handle to it - hwnd = FX.CreateWindowExW( + hwnd = Windows.CreateWindowExW( 0, windowClassEx.lpszClassName, (ushort*)windowTitle, - FX.WS_OVERLAPPEDWINDOW, - FX.CW_USEDEFAULT, - FX.CW_USEDEFAULT, + Windows.WS_OVERLAPPEDWINDOW, + Windows.CW_USEDEFAULT, + Windows.CW_USEDEFAULT, (int)width, (int)height, HWND.NULL, @@ -102,14 +101,14 @@ internal unsafe static class Win32ApplicationRunner margins.cyTopHeight = -1; margins.cyBottomHeight = -1; - _ = FX.DwmExtendFrameIntoClientArea(hwnd, &margins); + _ = Windows.DwmExtendFrameIntoClientArea(hwnd, &margins); } // Initialize the application application.OnInitialize(hwnd); // Display the window - _ = FX.ShowWindow(hwnd, FX.SW_SHOWDEFAULT); + _ = Windows.ShowWindow(hwnd, Windows.SW_SHOWDEFAULT); MSG msg = default; @@ -140,12 +139,12 @@ internal unsafe static class Win32ApplicationRunner renderThread.Start((application, tokenSource.Token)); // Process any messages in the queue - while (msg.message != FX.WM_QUIT) + while (msg.message != Windows.WM_QUIT) { - if (FX.PeekMessageW(&msg, HWND.NULL, 0, 0, FX.PM_REMOVE) != 0) + if (Windows.PeekMessageW(&msg, HWND.NULL, 0, 0, Windows.PM_REMOVE) != 0) { - _ = FX.TranslateMessage(&msg); - _ = FX.DispatchMessageW(&msg); + _ = Windows.TranslateMessage(&msg); + _ = Windows.DispatchMessageW(&msg); } else if (isPaused) { @@ -175,9 +174,9 @@ internal unsafe static class Win32ApplicationRunner switch (uMsg) { // Change the paused state on window activation - case FX.WM_ACTIVATE: + case Windows.WM_ACTIVATE: { - if (FX.LOWORD(wParam) == FX.WA_INACTIVE) + if (Windows.LOWORD(wParam) == Windows.WA_INACTIVE) { isPaused = true; } @@ -189,18 +188,18 @@ internal unsafe static class Win32ApplicationRunner } // Change the paused state when ESC is pressed - case FX.WM_KEYDOWN: + case Windows.WM_KEYDOWN: { if ((ConsoleKey)wParam == ConsoleKey.Escape) { if (isPaused) { - FX.SetCapture(hwnd); + Windows.SetCapture(hwnd); } else { - FX.ReleaseCapture(); + Windows.ReleaseCapture(); } isPaused = !isPaused; @@ -210,7 +209,7 @@ internal unsafe static class Win32ApplicationRunner } // Window resize started - case FX.WM_ENTERSIZEMOVE: + case Windows.WM_ENTERSIZEMOVE: { isResizing = true; @@ -218,7 +217,7 @@ internal unsafe static class Win32ApplicationRunner } // Window resize completed - case FX.WM_EXITSIZEMOVE: + case Windows.WM_EXITSIZEMOVE: { isResizing = false; application.OnResize(); @@ -227,9 +226,9 @@ internal unsafe static class Win32ApplicationRunner } // Size update - case FX.WM_SIZE: + case Windows.WM_SIZE: { - if (!isResizing && wParam != FX.SIZE_MINIMIZED) + if (!isResizing && wParam != Windows.SIZE_MINIMIZED) { application.OnResize(); } @@ -238,19 +237,19 @@ internal unsafe static class Win32ApplicationRunner } // Size and position of the window (needed to enable the borderless mode) - case FX.WM_NCCALCSIZE: + case Windows.WM_NCCALCSIZE: { return 0; } // Enable dragging the window - case FX.WM_NCHITTEST: + case Windows.WM_NCHITTEST: { POINT point; RECT rect; - _ = FX.GetCursorPos(&point); - _ = FX.GetWindowRect(hwnd, &rect); + _ = Windows.GetCursorPos(&point); + _ = Windows.GetWindowRect(hwnd, &rect); bool isAtTop = Math.Abs(point.y - rect.top) < 12, @@ -260,37 +259,37 @@ internal unsafe static class Win32ApplicationRunner if (isAtTop) { - if (isAtRight) return FX.HTTOPRIGHT; - if (isAtLeft) return FX.HTTOPLEFT; - return FX.HTTOP; + if (isAtRight) return Windows.HTTOPRIGHT; + if (isAtLeft) return Windows.HTTOPLEFT; + return Windows.HTTOP; } if (isAtRight) { - if (isAtTop) return FX.HTTOPRIGHT; - if (isAtBottom) return FX.HTBOTTOMRIGHT; - return FX.HTRIGHT; + if (isAtTop) return Windows.HTTOPRIGHT; + if (isAtBottom) return Windows.HTBOTTOMRIGHT; + return Windows.HTRIGHT; } if (isAtBottom) { - if (isAtRight) return FX.HTBOTTOMRIGHT; - if (isAtLeft) return FX.HTBOTTOMLEFT; - return FX.HTBOTTOM; + if (isAtRight) return Windows.HTBOTTOMRIGHT; + if (isAtLeft) return Windows.HTBOTTOMLEFT; + return Windows.HTBOTTOM; } if (isAtLeft) { - if (isAtTop) return FX.HTTOPLEFT; - if (isAtBottom) return FX.HTBOTTOMLEFT; - return FX.HTLEFT; + if (isAtTop) return Windows.HTTOPLEFT; + if (isAtBottom) return Windows.HTBOTTOMLEFT; + return Windows.HTLEFT; } - return FX.HTCAPTION; + return Windows.HTCAPTION; } // Restore the drop shadow - case FX.WM_DWMCOMPOSITIONCHANGED: + case Windows.WM_DWMCOMPOSITIONCHANGED: { MARGINS margins = default; margins.cxLeftWidth = -1; @@ -298,19 +297,19 @@ internal unsafe static class Win32ApplicationRunner margins.cyTopHeight = -1; margins.cyBottomHeight = -1; - _ = FX.DwmExtendFrameIntoClientArea(hwnd, &margins); + _ = Windows.DwmExtendFrameIntoClientArea(hwnd, &margins); return 0; } // Shutdown - case FX.WM_DESTROY: + case Windows.WM_DESTROY: { - FX.PostQuitMessage(0); + Windows.PostQuitMessage(0); return 0; } } - return FX.DefWindowProcW(hwnd, uMsg, wParam, lParam); + return Windows.DefWindowProcW(hwnd, uMsg, wParam, lParam); } } diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs index dbeb2c9d..97866a6d 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12DeviceExtensions.cs @@ -13,7 +13,6 @@ using static TerraFX.Interop.D3D12_FENCE_FLAGS; using static TerraFX.Interop.D3D12_MESSAGE_ID; using static TerraFX.Interop.D3D12_SRV_DIMENSION; using static TerraFX.Interop.D3D12_UAV_DIMENSION; -using FX = TerraFX.Interop.Windows; namespace ComputeSharp.Graphics.Extensions; @@ -51,7 +50,7 @@ internal static unsafe class ID3D12DeviceExtensions { ComPtr d3D12InfoQueue = default; - d3D12Device.QueryInterface(FX.__uuidof(), d3D12InfoQueue.GetVoidAddressOf()).Assert(); + d3D12Device.QueryInterface(Windows.__uuidof(), d3D12InfoQueue.GetVoidAddressOf()).Assert(); D3D12_MESSAGE_ID* d3D12MessageIds = stackalloc D3D12_MESSAGE_ID[3] { @@ -88,7 +87,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateCommandQueue( &d3D12CommandQueueDesc, - FX.__uuidof(), + Windows.__uuidof(), d3D12CommandQueue.GetVoidAddressOf()).Assert(); return d3D12CommandQueue.Move(); @@ -107,7 +106,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateFence( 0, D3D12_FENCE_FLAG_NONE, - FX.__uuidof(), + Windows.__uuidof(), d3D12Fence.GetVoidAddressOf()).Assert(); return d3D12Fence.Move(); @@ -132,7 +131,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateDescriptorHeap( &d3D12DescriptorHeapDesc, - FX.__uuidof(), + Windows.__uuidof(), d3D12DescriptorHeap.GetVoidAddressOf()).Assert(); return d3D12DescriptorHeap.Move(); @@ -177,7 +176,7 @@ internal static unsafe class ID3D12DeviceExtensions { D3D12_SHADER_RESOURCE_VIEW_DESC d3D12ShaderResourceViewDescription = default; d3D12ShaderResourceViewDescription.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - d3D12ShaderResourceViewDescription.Shader4ComponentMapping = FX.D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + d3D12ShaderResourceViewDescription.Shader4ComponentMapping = Windows.D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; d3D12ShaderResourceViewDescription.Buffer.NumElements = bufferSize; d3D12ShaderResourceViewDescription.Buffer.StructureByteStride = elementSize; @@ -202,7 +201,7 @@ internal static unsafe class ID3D12DeviceExtensions D3D12_SHADER_RESOURCE_VIEW_DESC d3D12ShaderResourceViewDescription = default; d3D12ShaderResourceViewDescription.ViewDimension = d3D12SrvDimension; d3D12ShaderResourceViewDescription.Format = dxgiFormat; - d3D12ShaderResourceViewDescription.Shader4ComponentMapping = FX.D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + d3D12ShaderResourceViewDescription.Shader4ComponentMapping = Windows.D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; d3D12ShaderResourceViewDescription.Texture2D.MipLevels = uint.MaxValue; d3D12Device.CreateShaderResourceView(d3D12Resource, &d3D12ShaderResourceViewDescription, d3D12CpuDescriptorHandle); @@ -269,7 +268,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateCommandAllocator( d3D12CommandListType, - FX.__uuidof(), + Windows.__uuidof(), d3D12CommandAllocator.GetVoidAddressOf()).Assert(); return d3D12CommandAllocator.Move(); @@ -297,7 +296,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12CommandListType, d3D12CommandAllocator, d3D12PipelineState, - FX.__uuidof(), + Windows.__uuidof(), d3D12GraphicsCommandList.GetVoidAddressOf()).Assert(); return d3D12GraphicsCommandList.Move(); diff --git a/src/ComputeSharp/Graphics/Helpers/D3D12FeatureHelper.cs b/src/ComputeSharp/Graphics/Helpers/D3D12FeatureHelper.cs index 127c8b0f..f196faa7 100644 --- a/src/ComputeSharp/Graphics/Helpers/D3D12FeatureHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/D3D12FeatureHelper.cs @@ -3,7 +3,6 @@ using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using TerraFX.Interop; using static TerraFX.Interop.D3D12_FEATURE; -using FX = TerraFX.Interop.Windows; namespace ComputeSharp.Graphics.Helpers; @@ -51,7 +50,7 @@ internal static class D3D12FeatureHelper &d3D12Options7, (uint)sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS7)); - if (result == FX.S_OK) + if (result == Windows.S_OK) { return D3D12_HEAP_FLAGS.D3D12_HEAP_FLAG_CREATE_NOT_ZEROED; } diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs index 83a94ad5..8c711bbf 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs @@ -5,7 +5,6 @@ using ComputeSharp.Core.Extensions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Interop; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; using HRESULT = System.Int32; using static TerraFX.Interop.D3D_FEATURE_LEVEL; using static TerraFX.Interop.D3D_SHADER_MODEL; @@ -119,32 +118,32 @@ internal static partial class DeviceHelper HRESULT enumAdapters1Result = this.dxgiFactory6.Get()->EnumAdapterByGpuPreference( this.index, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, - FX.__uuidof(), + Windows.__uuidof(), dxgiAdapter1.GetVoidAddressOf()); - if (enumAdapters1Result == FX.DXGI_ERROR_NOT_FOUND) + if (enumAdapters1Result == Windows.DXGI_ERROR_NOT_FOUND) { - this.dxgiFactory6.Get()->EnumWarpAdapter(FX.__uuidof(), dxgiAdapter1.GetVoidAddressOf()).Assert(); + this.dxgiFactory6.Get()->EnumWarpAdapter(Windows.__uuidof(), dxgiAdapter1.GetVoidAddressOf()).Assert(); DXGI_ADAPTER_DESC1 dxgiDescription1; dxgiAdapter1.Get()->GetDesc1(&dxgiDescription1).Assert(); - HRESULT createDeviceResult = FX.D3D12CreateDevice( + HRESULT createDeviceResult = Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), null); - if (FX.SUCCEEDED(createDeviceResult) && + if (Windows.SUCCEEDED(createDeviceResult) && this.predicate?.Invoke(new GraphicsDeviceInfo(&dxgiDescription1)) != false) { using ComPtr d3D12Device = default; - FX.D3D12CreateDevice( + Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), d3D12Device.GetVoidAddressOf()).Assert(); this.graphicsDevice = GetOrCreateDevice(d3D12Device.Get(), (IDXGIAdapter*)dxgiAdapter1.Get(), &dxgiDescription1); @@ -171,21 +170,21 @@ internal static partial class DeviceHelper continue; } - HRESULT createDeviceResult = FX.D3D12CreateDevice( + HRESULT createDeviceResult = Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), null); - if (FX.SUCCEEDED(createDeviceResult) && + if (Windows.SUCCEEDED(createDeviceResult) && this.predicate?.Invoke(new GraphicsDeviceInfo(&dxgiDescription1)) != false) { using ComPtr d3D12Device = default; - FX.D3D12CreateDevice( + Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), d3D12Device.GetVoidAddressOf()).Assert(); if (d3D12Device.Get()->IsShaderModelSupported(D3D_SHADER_MODEL_6_0)) diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs index db0b8524..d3c3493c 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs @@ -4,7 +4,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Core.Extensions; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; using HRESULT = System.Int32; namespace ComputeSharp.Graphics.Helpers; @@ -17,7 +16,7 @@ internal static partial class DeviceHelper /// private const uint IDXGIFactoryCreationFlags = #if DEBUG - FX.DXGI_CREATE_FACTORY_DEBUG; + Windows.DXGI_CREATE_FACTORY_DEBUG; #else 0; #endif @@ -32,16 +31,16 @@ internal static partial class DeviceHelper EnableDebugMode(); - FX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, FX.__uuidof(), dxgiFactory4.GetVoidAddressOf()).Assert(); + Windows.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof(), dxgiFactory4.GetVoidAddressOf()).Assert(); HRESULT result = dxgiFactory4.CopyTo(dxgiFactory6); - if (result == FX.S_OK) + if (result == Windows.S_OK) { return; } - if (result == FX.E_NOINTERFACE) + if (result == Windows.E_NOINTERFACE) { IDXGIFactory4As6Backcompat.Create(dxgiFactory4.Get(), dxgiFactory6); @@ -62,14 +61,14 @@ internal static partial class DeviceHelper using ComPtr d3D12Debug = default; using ComPtr d3D12Debug1 = default; - FX.D3D12GetDebugInterface(FX.__uuidof(), d3D12Debug.GetVoidAddressOf()).Assert(); + Windows.D3D12GetDebugInterface(Windows.__uuidof(), d3D12Debug.GetVoidAddressOf()).Assert(); d3D12Debug.Get()->EnableDebugLayer(); - if (FX.SUCCEEDED(d3D12Debug.CopyTo(d3D12Debug1.GetAddressOf()))) + if (Windows.SUCCEEDED(d3D12Debug.CopyTo(d3D12Debug1.GetAddressOf()))) { - d3D12Debug1.Get()->SetEnableGPUBasedValidation(FX.TRUE); - d3D12Debug1.Get()->SetEnableSynchronizedCommandQueueValidation(FX.TRUE); + d3D12Debug1.Get()->SetEnableGPUBasedValidation(Windows.TRUE); + d3D12Debug1.Get()->SetEnableSynchronizedCommandQueueValidation(Windows.TRUE); } } diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs index b5dd93d0..ecd4383b 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs @@ -4,7 +4,6 @@ using ComputeSharp.Core.Extensions; using ComputeSharp.Graphics.Extensions; using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; using HRESULT = System.Int32; using static TerraFX.Interop.D3D_FEATURE_LEVEL; using static TerraFX.Interop.D3D_SHADER_MODEL; @@ -95,10 +94,10 @@ internal static partial class DeviceHelper HRESULT enumAdapters1Result = dxgiFactory6.Get()->EnumAdapterByGpuPreference( i++, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, - FX.__uuidof(), + Windows.__uuidof(), dxgiAdapter1.GetVoidAddressOf()); - if (enumAdapters1Result == FX.DXGI_ERROR_NOT_FOUND) + if (enumAdapters1Result == Windows.DXGI_ERROR_NOT_FOUND) { return false; } @@ -120,23 +119,23 @@ internal static partial class DeviceHelper // a device for adapters that would've failed at the FL11 check already. if (d3D12Device == null) { - HRESULT createDeviceResult = FX.D3D12CreateDevice( + HRESULT createDeviceResult = Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), null); - if (FX.SUCCEEDED(createDeviceResult)) + if (Windows.SUCCEEDED(createDeviceResult)) { using ComPtr d3D12DeviceCandidate = default; - createDeviceResult = FX.D3D12CreateDevice( + createDeviceResult = Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), d3D12DeviceCandidate.GetVoidAddressOf()); - if (FX.SUCCEEDED(createDeviceResult) && + if (Windows.SUCCEEDED(createDeviceResult) && d3D12DeviceCandidate.Get()->IsShaderModelSupported(D3D_SHADER_MODEL_6_0)) { return true; @@ -147,13 +146,13 @@ internal static partial class DeviceHelper { using ComPtr d3D12DeviceCandidate = default; - HRESULT createDeviceResult = FX.D3D12CreateDevice( + HRESULT createDeviceResult = Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), d3D12DeviceCandidate.GetVoidAddressOf()); - if (FX.SUCCEEDED(createDeviceResult) && + if (Windows.SUCCEEDED(createDeviceResult) && d3D12DeviceCandidate.Get()->IsShaderModelSupported(D3D_SHADER_MODEL_6_0)) { d3D12DeviceCandidate.CopyTo(d3D12Device); @@ -180,18 +179,18 @@ internal static partial class DeviceHelper using ComPtr dxgiAdapter1 = default; - dxgiFactory6.Get()->EnumWarpAdapter(FX.__uuidof(), dxgiAdapter1.GetVoidAddressOf()).Assert(); + dxgiFactory6.Get()->EnumWarpAdapter(Windows.__uuidof(), dxgiAdapter1.GetVoidAddressOf()).Assert(); dxgiAdapter1.Get()->GetDesc1(dxgiDescription1).Assert(); - HRESULT createDeviceResult = FX.D3D12CreateDevice( + HRESULT createDeviceResult = Windows.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL_11_0, - FX.__uuidof(), + Windows.__uuidof(), (void**)d3D12Device); dxgiAdapter1.CopyTo(dxgiAdapter); - return FX.SUCCEEDED(createDeviceResult); + return Windows.SUCCEEDED(createDeviceResult); } } diff --git a/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs b/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs index 7bd1eaef..96c44060 100644 --- a/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/WICFormatHelper.cs @@ -3,7 +3,7 @@ using System.Diagnostics.Contracts; using System.IO; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Diagnostics; -using FX = TerraFX.Interop.Windows; +using TerraFX.Interop; namespace ComputeSharp.Graphics.Helpers; @@ -23,11 +23,11 @@ internal static class WICFormatHelper public static Guid GetForType() where T : unmanaged { - if (typeof(T) == typeof(Bgra32)) return FX.GUID_WICPixelFormat32bppBGRA; - else if (typeof(T) == typeof(Rgba32)) return FX.GUID_WICPixelFormat32bppRGBA; - else if (typeof(T) == typeof(Rgba64)) return FX.GUID_WICPixelFormat64bppRGBA; - else if (typeof(T) == typeof(R8)) return FX.GUID_WICPixelFormat8bppGray; - else if (typeof(T) == typeof(R16)) return FX.GUID_WICPixelFormat16bppGray; + if (typeof(T) == typeof(Bgra32)) return Windows.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(Rgba32)) return Windows.GUID_WICPixelFormat32bppRGBA; + else if (typeof(T) == typeof(Rgba64)) return Windows.GUID_WICPixelFormat64bppRGBA; + else if (typeof(T) == typeof(R8)) return Windows.GUID_WICPixelFormat8bppGray; + else if (typeof(T) == typeof(R16)) return Windows.GUID_WICPixelFormat16bppGray; else return ThrowHelper.ThrowArgumentException("Invalid texture type"); } @@ -42,58 +42,58 @@ internal static class WICFormatHelper public static bool TryGetIntermediateFormatForType(Guid containerFormat, out Guid intermediateFormat) where T : unmanaged { - if (containerFormat == FX.GUID_ContainerFormatBmp) + if (containerFormat == Windows.GUID_ContainerFormatBmp) { if (typeof(T) == typeof(Bgra32)) intermediateFormat = default; - else if (typeof(T) == typeof(Rgba32)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; - else if (typeof(T) == typeof(Rgba64)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; - else if (typeof(T) == typeof(R8)) intermediateFormat = FX.GUID_WICPixelFormat24bppBGR; - else if (typeof(T) == typeof(R16)) intermediateFormat = FX.GUID_WICPixelFormat24bppBGR; + else if (typeof(T) == typeof(Rgba32)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(Rgba64)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(R8)) intermediateFormat = Windows.GUID_WICPixelFormat24bppBGR; + else if (typeof(T) == typeof(R16)) intermediateFormat = Windows.GUID_WICPixelFormat24bppBGR; else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type"); } - else if (containerFormat == FX.GUID_ContainerFormatPng) + else if (containerFormat == Windows.GUID_ContainerFormatPng) { if (typeof(T) == typeof(Bgra32)) intermediateFormat = default; - else if (typeof(T) == typeof(Rgba32)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(Rgba32)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default; else if (typeof(T) == typeof(R8)) intermediateFormat = default; - else if (typeof(T) == typeof(R16)) intermediateFormat = FX.GUID_WICPixelFormat8bppGray; + else if (typeof(T) == typeof(R16)) intermediateFormat = Windows.GUID_WICPixelFormat8bppGray; else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type"); } - else if (containerFormat == FX.GUID_ContainerFormatJpeg) + else if (containerFormat == Windows.GUID_ContainerFormatJpeg) { - if (typeof(T) == typeof(Bgra32)) intermediateFormat = FX.GUID_WICPixelFormat24bppBGR; - else if (typeof(T) == typeof(Rgba32)) intermediateFormat = FX.GUID_WICPixelFormat24bppBGR; - else if (typeof(T) == typeof(Rgba64)) intermediateFormat = FX.GUID_WICPixelFormat24bppBGR; + if (typeof(T) == typeof(Bgra32)) intermediateFormat = Windows.GUID_WICPixelFormat24bppBGR; + else if (typeof(T) == typeof(Rgba32)) intermediateFormat = Windows.GUID_WICPixelFormat24bppBGR; + else if (typeof(T) == typeof(Rgba64)) intermediateFormat = Windows.GUID_WICPixelFormat24bppBGR; else if (typeof(T) == typeof(R8)) intermediateFormat = default; - else if (typeof(T) == typeof(R16)) intermediateFormat = FX.GUID_WICPixelFormat8bppGray; + else if (typeof(T) == typeof(R16)) intermediateFormat = Windows.GUID_WICPixelFormat8bppGray; else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type"); } - else if (containerFormat == FX.GUID_ContainerFormatWmp) + else if (containerFormat == Windows.GUID_ContainerFormatWmp) { if (typeof(T) == typeof(Bgra32)) intermediateFormat = default; - else if (typeof(T) == typeof(Rgba32)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(Rgba32)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default; else if (typeof(T) == typeof(R8)) intermediateFormat = default; else if (typeof(T) == typeof(R16)) intermediateFormat = default; else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type"); } - else if (containerFormat == FX.GUID_ContainerFormatTiff) + else if (containerFormat == Windows.GUID_ContainerFormatTiff) { if (typeof(T) == typeof(Bgra32)) intermediateFormat = default; - else if (typeof(T) == typeof(Rgba32)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(Rgba32)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default; else if (typeof(T) == typeof(R8)) intermediateFormat = default; else if (typeof(T) == typeof(R16)) intermediateFormat = default; else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type"); } - else if (containerFormat == FX.GUID_ContainerFormatDds) + else if (containerFormat == Windows.GUID_ContainerFormatDds) { if (typeof(T) == typeof(Bgra32)) intermediateFormat = default; - else if (typeof(T) == typeof(Rgba32)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; - else if (typeof(T) == typeof(Rgba64)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; - else if (typeof(T) == typeof(R8)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; - else if (typeof(T) == typeof(R16)) intermediateFormat = FX.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(Rgba32)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(Rgba64)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(R8)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; + else if (typeof(T) == typeof(R16)) intermediateFormat = Windows.GUID_WICPixelFormat32bppBGRA; else intermediateFormat = ThrowHelper.ThrowArgumentException("Invalid texture type"); } else @@ -115,16 +115,16 @@ internal static class WICFormatHelper { return Path.GetExtension(filename).ToString() switch { - ".bmp" => FX.GUID_ContainerFormatBmp, - ".png" => FX.GUID_ContainerFormatPng, + ".bmp" => Windows.GUID_ContainerFormatBmp, + ".png" => Windows.GUID_ContainerFormatPng, ".jpg" or - ".jpeg" => FX.GUID_ContainerFormatJpeg, + ".jpeg" => Windows.GUID_ContainerFormatJpeg, ".jxr" or ".hdp" or ".wdp" or - ".wmp" => FX.GUID_ContainerFormatWmp, - ".tiff" => FX.GUID_ContainerFormatTiff, - ".dds" => FX.GUID_ContainerFormatDds, + ".wmp" => Windows.GUID_ContainerFormatWmp, + ".tiff" => Windows.GUID_ContainerFormatTiff, + ".dds" => Windows.GUID_ContainerFormatDds, _ => ThrowHelper.ThrowArgumentException("Invalid filename"), }; } diff --git a/src/ComputeSharp/Graphics/Helpers/WICHelper.cs b/src/ComputeSharp/Graphics/Helpers/WICHelper.cs index 67e7b7b5..24700c22 100644 --- a/src/ComputeSharp/Graphics/Helpers/WICHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/WICHelper.cs @@ -2,7 +2,6 @@ using System.Diagnostics.Contracts; using ComputeSharp.Core.Extensions; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; namespace ComputeSharp.Graphics.Helpers; @@ -22,13 +21,13 @@ internal sealed unsafe class WICHelper private WICHelper() { using ComPtr wicImagingFactory2 = default; - Guid wicImagingFactor2Clsid = FX.CLSID_WICImagingFactory2; + Guid wicImagingFactor2Clsid = Windows.CLSID_WICImagingFactory2; - FX.CoCreateInstance( + Windows.CoCreateInstance( &wicImagingFactor2Clsid, null, (uint)CLSCTX.CLSCTX_INPROC_SERVER, - FX.__uuidof(), + Windows.__uuidof(), wicImagingFactory2.GetVoidAddressOf()).Assert(); this.wicImagingFactory2 = wicImagingFactory2.Move(); @@ -66,7 +65,7 @@ internal sealed unsafe class WICHelper this.wicImagingFactory2.Get()->CreateDecoderFromFilename( (ushort*)p, null, - FX.GENERIC_READ, + Windows.GENERIC_READ, WICDecodeOptions.WICDecodeMetadataCacheOnDemand, wicBitmapDecoder.GetAddressOf()).Assert(); } @@ -132,7 +131,7 @@ internal sealed unsafe class WICHelper { wicStream.Get()->InitializeFromFilename( (ushort*)p, - FX.GENERIC_WRITE); + Windows.GENERIC_WRITE); } // Initialize the encoder diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs index d18f5050..03f967c7 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs @@ -8,7 +8,6 @@ using ComputeSharp.Interop; using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using static TerraFX.Interop.D3D12_FEATURE; -using FX = TerraFX.Interop.Windows; using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType; namespace ComputeSharp.Resources; @@ -59,7 +58,7 @@ public unsafe abstract class Buffer : NativeObject if (resourceType == ResourceType.Constant) { - Guard.IsBetweenOrEqualTo(length, 1, FX.D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT, nameof(length)); + Guard.IsBetweenOrEqualTo(length, 1, Windows.D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT, nameof(length)); } else { diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs index 56329c71..f6935282 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs @@ -12,7 +12,6 @@ using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE; using static TerraFX.Interop.D3D12_RESOURCE_STATES; using static TerraFX.Interop.D3D12_SRV_DIMENSION; using static TerraFX.Interop.D3D12_UAV_DIMENSION; -using FX = TerraFX.Interop.Windows; using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType; #pragma warning disable CS0618 @@ -74,8 +73,8 @@ public unsafe abstract class Texture2D : NativeObject, GraphicsResourceHelper { device.ThrowIfDisposed(); - Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(width)); - Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(height)); + Guard.IsBetweenOrEqualTo(width, 1, Windows.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(width)); + Guard.IsBetweenOrEqualTo(height, 1, Windows.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(height)); if (!device.D3D12Device->IsDxgiFormatSupported(DXGIFormatHelper.GetForType(), d3D12FormatSupport)) { diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs index 44985ebc..263a15a1 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs @@ -12,7 +12,6 @@ using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE; using static TerraFX.Interop.D3D12_RESOURCE_STATES; using static TerraFX.Interop.D3D12_SRV_DIMENSION; using static TerraFX.Interop.D3D12_UAV_DIMENSION; -using FX = TerraFX.Interop.Windows; using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType; #pragma warning disable CS0618 @@ -75,9 +74,9 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper { device.ThrowIfDisposed(); - Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(width)); - Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(height)); - Guard.IsBetweenOrEqualTo(depth, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(depth)); + Guard.IsBetweenOrEqualTo(width, 1, Windows.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(width)); + Guard.IsBetweenOrEqualTo(height, 1, Windows.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(height)); + Guard.IsBetweenOrEqualTo(depth, 1, Windows.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(depth)); if (!device.D3D12Device->IsDxgiFormatSupported(DXGIFormatHelper.GetForType(), d3D12FormatSupport)) { diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs index e927940d..dfa83ac1 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs @@ -6,7 +6,6 @@ using ComputeSharp.Interop; using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using static TerraFX.Interop.D3D12_FORMAT_SUPPORT1; -using FX = TerraFX.Interop.Windows; using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType; namespace ComputeSharp.Resources; @@ -50,8 +49,8 @@ public unsafe abstract class TransferTexture2D : NativeObject { device.ThrowIfDisposed(); - Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(width)); - Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(height)); + Guard.IsBetweenOrEqualTo(width, 1, Windows.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(width)); + Guard.IsBetweenOrEqualTo(height, 1, Windows.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(height)); if (!device.D3D12Device->IsDxgiFormatSupported(DXGIFormatHelper.GetForType(), D3D12_FORMAT_SUPPORT1_TEXTURE2D)) { diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs index bd98aea0..d9bf3be6 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs @@ -6,7 +6,6 @@ using ComputeSharp.Interop; using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using static TerraFX.Interop.D3D12_FORMAT_SUPPORT1; -using FX = TerraFX.Interop.Windows; using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType; namespace ComputeSharp.Resources; @@ -51,9 +50,9 @@ public unsafe abstract class TransferTexture3D : NativeObject { device.ThrowIfDisposed(); - Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(width)); - Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(height)); - Guard.IsBetweenOrEqualTo(depth, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(depth)); + Guard.IsBetweenOrEqualTo(width, 1, Windows.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(width)); + Guard.IsBetweenOrEqualTo(height, 1, Windows.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(height)); + Guard.IsBetweenOrEqualTo(depth, 1, Windows.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(depth)); if (!device.D3D12Device->IsDxgiFormatSupported(DXGIFormatHelper.GetForType(), D3D12_FORMAT_SUPPORT1_TEXTURE3D)) { diff --git a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs index 705b70d9..7432bf43 100644 --- a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs @@ -5,12 +5,12 @@ using ComputeSharp.Core.Helpers; using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; -using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Graphics.Resources.Interop; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; using Microsoft.Toolkit.Diagnostics; -using FX = TerraFX.Interop.Windows; +using TerraFX.Interop; +using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType; namespace ComputeSharp; @@ -26,7 +26,7 @@ public sealed class ConstantBuffer : Buffer /// /// The alignment boundary for elements in a constant buffer. /// - private const int ElementAlignment = FX.D3D12_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT; + private const int ElementAlignment = Windows.D3D12_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT; /// /// Creates a new instance with the specified parameters. diff --git a/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs b/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs index eb6d57b0..028f3613 100644 --- a/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs +++ b/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs @@ -1,7 +1,6 @@ using System; using System.ComponentModel; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; using static TerraFX.Interop.D3D12_DESCRIPTOR_RANGE_FLAGS; #pragma warning disable IDE0052, CS0414 @@ -46,6 +45,6 @@ public struct ResourceDescriptor descriptor.BaseShaderRegister = offset; descriptor.RegisterSpace = 0; descriptor.Flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE; - descriptor.OffsetInDescriptorsFromTableStart = FX.D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; + descriptor.OffsetInDescriptorsFromTableStart = Windows.D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; } } diff --git a/src/ComputeSharp/Shaders/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp/Shaders/Extensions/ID3D12DeviceExtensions.cs index 9caac2df..a5979b2c 100644 --- a/src/ComputeSharp/Shaders/Extensions/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp/Shaders/Extensions/ID3D12DeviceExtensions.cs @@ -5,7 +5,6 @@ using static TerraFX.Interop.D3D12_COMPARISON_FUNC; using static TerraFX.Interop.D3D12_FILTER; using static TerraFX.Interop.D3D12_PIPELINE_STATE_FLAGS; using static TerraFX.Interop.D3D12_TEXTURE_ADDRESS_MODE; -using FX = TerraFX.Interop.Windows; namespace ComputeSharp.Shaders.Extensions; @@ -72,7 +71,7 @@ internal static unsafe class ID3D12DeviceExtensions // Serialize the root signature from the data just computed. When this is done // we just work with the resulting blobs, so the input data can be unpinned. - FX.D3D12SerializeVersionedRootSignature( + Windows.D3D12SerializeVersionedRootSignature( &d3D12VersionedRootSignatureDescription, d3D3Blob.GetAddressOf(), d3D3BlobError.GetAddressOf()).Assert(); @@ -82,7 +81,7 @@ internal static unsafe class ID3D12DeviceExtensions 0, d3D3Blob.Get()->GetBufferPointer(), d3D3Blob.Get()->GetBufferSize(), - FX.__uuidof(), + Windows.__uuidof(), d3D12RootSignature.GetVoidAddressOf()).Assert(); return d3D12RootSignature.Move(); @@ -112,7 +111,7 @@ internal static unsafe class ID3D12DeviceExtensions d3D12Device.CreateComputePipelineState( &d3D12ComputePipelineStateDescription, - FX.__uuidof(), + Windows.__uuidof(), d3D12PipelineState.GetVoidAddressOf()).Assert(); return d3D12PipelineState.Move(); diff --git a/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs b/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs index 4c171fec..d7b6c39c 100644 --- a/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs +++ b/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs @@ -4,7 +4,6 @@ using ComputeSharp.__Internals; using ComputeSharp.Core.Extensions; using ComputeSharp.Shaders.Translation; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; #pragma warning disable CS0618 @@ -110,9 +109,9 @@ public static class ReflectionServices using ComPtr dxcUtils = default; - Guid dxcLibraryClsid = FX.CLSID_DxcLibrary; + Guid dxcLibraryClsid = Windows.CLSID_DxcLibrary; - FX.DxcCreateInstance(&dxcLibraryClsid, FX.__uuidof(), dxcUtils.GetVoidAddressOf()).Assert(); + Windows.DxcCreateInstance(&dxcLibraryClsid, Windows.__uuidof(), dxcUtils.GetVoidAddressOf()).Assert(); using ComPtr d3D12ShaderReflection = default; @@ -122,7 +121,7 @@ public static class ReflectionServices dxcUtils.Get()->CreateReflection( &dxcBuffer, - FX.__uuidof(), + Windows.__uuidof(), d3D12ShaderReflection.GetVoidAddressOf()).Assert(); D3D12_SHADER_DESC d3D12ShaderDescription; diff --git a/src/ComputeSharp/Shaders/ShaderRunner{T}.cs b/src/ComputeSharp/Shaders/ShaderRunner{T}.cs index e54f3fa8..2511c959 100644 --- a/src/ComputeSharp/Shaders/ShaderRunner{T}.cs +++ b/src/ComputeSharp/Shaders/ShaderRunner{T}.cs @@ -9,7 +9,6 @@ using ComputeSharp.Shaders.Translation.Models; using ComputeSharp.__Internals; using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; #pragma warning disable CS0618 @@ -122,9 +121,9 @@ internal static class ShaderRunner groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1), groupsZ = Math.DivRem(z, threadsZ, out int modZ) + (modZ == 0 ? 0 : 1); - Guard.IsBetweenOrEqualTo(groupsX, 1, FX.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); - Guard.IsBetweenOrEqualTo(groupsY, 1, FX.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); - Guard.IsBetweenOrEqualTo(groupsZ, 1, FX.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); + Guard.IsBetweenOrEqualTo(groupsX, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); + Guard.IsBetweenOrEqualTo(groupsY, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); + Guard.IsBetweenOrEqualTo(groupsZ, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); ShaderKey key = new(shader.GetDispatchId(), threadsX, threadsY, threadsZ); PipelineData? pipelineData; @@ -178,8 +177,8 @@ internal static class ShaderRunner groupsX = Math.DivRem(x, threadsX, out int modX) + (modX == 0 ? 0 : 1), groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1); - Guard.IsBetweenOrEqualTo(groupsX, 1, FX.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); - Guard.IsBetweenOrEqualTo(groupsY, 1, FX.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); + Guard.IsBetweenOrEqualTo(groupsX, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); + Guard.IsBetweenOrEqualTo(groupsY, 1, Windows.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX)); ShaderKey key = new(shader.GetDispatchId(), threadsX, threadsY, 1); PipelineData? pipelineData; diff --git a/src/ComputeSharp/Shaders/Translation/ShaderCompiler.LibraryLoading.cs b/src/ComputeSharp/Shaders/Translation/ShaderCompiler.LibraryLoading.cs index a44d2591..944f2d41 100644 --- a/src/ComputeSharp/Shaders/Translation/ShaderCompiler.LibraryLoading.cs +++ b/src/ComputeSharp/Shaders/Translation/ShaderCompiler.LibraryLoading.cs @@ -1,7 +1,7 @@ using System; using System.IO; using System.Runtime.InteropServices; -using FX = TerraFX.Interop.Windows; +using TerraFX.Interop; namespace ComputeSharp.Shaders.Translation; @@ -23,7 +23,7 @@ internal sealed unsafe partial class ShaderCompiler // libraries from the NuGet directory, if an RID is not in use, or we need to ensure that dxil.dll is // loaded correctly in case the program was executed with the host being in another directory. // This happens when doing eg. "dotnet bin\Debug\net5.0\MyApp.dll", which would crash at runtime. - FX.ResolveLibrary += (libraryName, assembly, searchPath) => + Windows.ResolveLibrary += (libraryName, assembly, searchPath) => { if (libraryName is not "dxcompiler") return IntPtr.Zero; diff --git a/src/ComputeSharp/Shaders/Translation/ShaderCompiler.cs b/src/ComputeSharp/Shaders/Translation/ShaderCompiler.cs index 8aa46e28..84989ae9 100644 --- a/src/ComputeSharp/Shaders/Translation/ShaderCompiler.cs +++ b/src/ComputeSharp/Shaders/Translation/ShaderCompiler.cs @@ -4,7 +4,6 @@ using System.Runtime.CompilerServices; using ComputeSharp.Core.Extensions; using ComputeSharp.Exceptions; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; namespace ComputeSharp.Shaders.Translation; @@ -49,11 +48,11 @@ internal sealed unsafe partial class ShaderCompiler using ComPtr dxcLibrary = default; using ComPtr dxcIncludeHandler = default; - Guid dxcCompilerCLGuid = FX.CLSID_DxcCompiler; - Guid dxcLibraryCLGuid = FX.CLSID_DxcLibrary; + Guid dxcCompilerCLGuid = Windows.CLSID_DxcCompiler; + Guid dxcLibraryCLGuid = Windows.CLSID_DxcLibrary; - FX.DxcCreateInstance(&dxcCompilerCLGuid, FX.__uuidof(), dxcCompiler.GetVoidAddressOf()).Assert(); - FX.DxcCreateInstance(&dxcLibraryCLGuid, FX.__uuidof(), dxcLibrary.GetVoidAddressOf()).Assert(); + Windows.DxcCreateInstance(&dxcCompilerCLGuid, Windows.__uuidof(), dxcCompiler.GetVoidAddressOf()).Assert(); + Windows.DxcCreateInstance(&dxcLibraryCLGuid, Windows.__uuidof(), dxcLibrary.GetVoidAddressOf()).Assert(); dxcLibrary.Get()->CreateIncludeHandler(dxcIncludeHandler.GetAddressOf()).Assert(); diff --git a/tests/ComputeSharp.Tests/InteropServicesTests.cs b/tests/ComputeSharp.Tests/InteropServicesTests.cs index 8009f899..cc163ea1 100644 --- a/tests/ComputeSharp.Tests/InteropServicesTests.cs +++ b/tests/ComputeSharp.Tests/InteropServicesTests.cs @@ -5,7 +5,6 @@ using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; using TerraFX.Interop; -using FX = TerraFX.Interop.Windows; using static TerraFX.Interop.D3D12_RESOURCE_DIMENSION; namespace ComputeSharp.Tests; @@ -20,7 +19,7 @@ public unsafe partial class InteropServicesTests { using ComPtr d3D12Device = default; - InteropServices.GetID3D12Device(device.Get(), FX.__uuidof(), (void**)d3D12Device.GetAddressOf()); + InteropServices.GetID3D12Device(device.Get(), Windows.__uuidof(), (void**)d3D12Device.GetAddressOf()); Assert.IsTrue(d3D12Device.Get() != null); @@ -30,9 +29,9 @@ public unsafe partial class InteropServicesTests d3D12Device.Dispose(); - int hResult = InteropServices.TryGetID3D12Device(device.Get(), FX.__uuidof(), (void**)d3D12Device.GetAddressOf()); + int hResult = InteropServices.TryGetID3D12Device(device.Get(), Windows.__uuidof(), (void**)d3D12Device.GetAddressOf()); - Assert.AreEqual(hResult, FX.S_OK); + Assert.AreEqual(hResult, Windows.S_OK); Assert.IsTrue(d3D12Device.Get() != null); luid = d3D12Device.Get()->GetAdapterLuid(); @@ -51,16 +50,16 @@ public unsafe partial class InteropServicesTests using ComPtr d3D12Resource = default; - InteropServices.GetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + InteropServices.GetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); d3D12Resource.Dispose(); - int hResult = InteropServices.TryGetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + int hResult = InteropServices.TryGetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); - Assert.AreEqual(hResult, FX.S_OK); + Assert.AreEqual(hResult, Windows.S_OK); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); } @@ -75,16 +74,16 @@ public unsafe partial class InteropServicesTests using ComPtr d3D12Resource = default; - InteropServices.GetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + InteropServices.GetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_TEXTURE2D); d3D12Resource.Dispose(); - int hResult = InteropServices.TryGetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + int hResult = InteropServices.TryGetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); - Assert.AreEqual(hResult, FX.S_OK); + Assert.AreEqual(hResult, Windows.S_OK); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_TEXTURE2D); } @@ -99,16 +98,16 @@ public unsafe partial class InteropServicesTests using ComPtr d3D12Resource = default; - InteropServices.GetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + InteropServices.GetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_TEXTURE3D); d3D12Resource.Dispose(); - int hResult = InteropServices.TryGetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + int hResult = InteropServices.TryGetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); - Assert.AreEqual(hResult, FX.S_OK); + Assert.AreEqual(hResult, Windows.S_OK); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_TEXTURE3D); } @@ -123,16 +122,16 @@ public unsafe partial class InteropServicesTests using ComPtr d3D12Resource = default; - InteropServices.GetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + InteropServices.GetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); d3D12Resource.Dispose(); - int hResult = InteropServices.TryGetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + int hResult = InteropServices.TryGetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); - Assert.AreEqual(hResult, FX.S_OK); + Assert.AreEqual(hResult, Windows.S_OK); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); } @@ -147,16 +146,16 @@ public unsafe partial class InteropServicesTests using ComPtr d3D12Resource = default; - InteropServices.GetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + InteropServices.GetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); d3D12Resource.Dispose(); - int hResult = InteropServices.TryGetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + int hResult = InteropServices.TryGetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); - Assert.AreEqual(hResult, FX.S_OK); + Assert.AreEqual(hResult, Windows.S_OK); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); } @@ -171,16 +170,16 @@ public unsafe partial class InteropServicesTests using ComPtr d3D12Resource = default; - InteropServices.GetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + InteropServices.GetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); d3D12Resource.Dispose(); - int hResult = InteropServices.TryGetID3D12Resource(buffer, FX.__uuidof(), (void**)d3D12Resource.GetAddressOf()); + int hResult = InteropServices.TryGetID3D12Resource(buffer, Windows.__uuidof(), (void**)d3D12Resource.GetAddressOf()); - Assert.AreEqual(hResult, FX.S_OK); + Assert.AreEqual(hResult, Windows.S_OK); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); }