diff --git a/Directory.Build.props b/Directory.Build.props index 5a31711..de03e52 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ true $(MSBuildThisFileDirectory)NuGet.config - 1.9.10 + 1.9.11 true diff --git a/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Device.cs b/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Device.cs index 32e4530..d5f7a13 100644 --- a/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Device.cs +++ b/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Device.cs @@ -52,7 +52,7 @@ public static unsafe partial class ID3D12DeviceExtensions fixed (FeatureLevel* pFeatureLevels = featureLevels) { - var featureData = new FeatureDataFeatureLevels + FeatureDataFeatureLevels featureData = new() { NumFeatureLevels = (uint)featureLevels.Length, pFeatureLevelsRequested = pFeatureLevels, diff --git a/src/Vortice.Win32.Graphics.Direct3D12/ID3D12GraphicsCommandList.cs b/src/Vortice.Win32.Graphics.Direct3D12/ID3D12GraphicsCommandList.cs new file mode 100644 index 0000000..4070b15 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D12/ID3D12GraphicsCommandList.cs @@ -0,0 +1,86 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public static unsafe class ID3D12GraphicsCommandListExtensions +{ + public static void ResourceBarrierTransition( + ref this TD3D12GraphicsCommandList self, + ID3D12Resource* resource, + ResourceStates stateBefore, + ResourceStates stateAfter, + uint subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, + ResourceBarrierFlags flags = ResourceBarrierFlags.None) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + ResourceBarrier barrier = Direct3D12.ResourceBarrier.InitTransition(resource, stateBefore, stateAfter, subresource, flags); + self.ResourceBarrier(1u, &barrier); + } + + public static void ResourceBarrierAliasing( + ref this TD3D12GraphicsCommandList self, + ID3D12Resource* resourceBefore, + ID3D12Resource* resourceAfter) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + ResourceBarrier barrier = Direct3D12.ResourceBarrier.InitAliasing(resourceBefore, resourceAfter); + self.ResourceBarrier(1u, &barrier); + } + + public static void ResourceBarrierUAV( + ref this TD3D12GraphicsCommandList self, ID3D12Resource* resource) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + ResourceBarrier barrier = Direct3D12.ResourceBarrier.InitUAV(resource); + self.ResourceBarrier(1u, &barrier); + } + + public static void ResourceBarrier(ref this TD3D12GraphicsCommandList self, ResourceBarrier barrier) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + self.ResourceBarrier(1u, &barrier); + } + + public static void ResourceBarrier( + ref this TD3D12GraphicsCommandList self, ResourceBarrier[] barriers) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + fixed (ResourceBarrier* pBarriers = barriers) + { + self.ResourceBarrier((uint)barriers.Length, pBarriers); + } + } + + public static void ResourceBarrier( + ref this TD3D12GraphicsCommandList self, int numBarriers, ResourceBarrier[] barriers) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + fixed (ResourceBarrier* pBarriers = barriers) + { + self.ResourceBarrier((uint)numBarriers, pBarriers); + } + } + + public static void ResourceBarrier( + ref this TD3D12GraphicsCommandList self, ReadOnlySpan barriers) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + fixed (ResourceBarrier* pBarriers = barriers) + { + self.ResourceBarrier((uint)barriers.Length, pBarriers); + } + } + + public static void ResourceBarrier( + ref this TD3D12GraphicsCommandList self, int numBarriers, ReadOnlySpan barriers) + where TD3D12GraphicsCommandList : unmanaged, ID3D12GraphicsCommandList.Interface + { + fixed (ResourceBarrier* pBarriers = barriers) + { + self.ResourceBarrier((uint)numBarriers, pBarriers); + } + } +}