From 8e121c63a1714f4c7ec458d3184d7b6ad6a7f19b Mon Sep 17 00:00:00 2001 From: Amer Koleci Date: Wed, 4 Jan 2023 15:43:59 +0100 Subject: [PATCH] Various improvements. --- Directory.Build.props | 2 +- .../ID3D11Device.cs | 38 ++++++++++++++++++ .../ID3DUserDefinedAnnotation.cs | 39 +++++++++++++++++++ .../ID3D12Object.cs | 12 +++--- 4 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 src/Vortice.Win32.Graphics.Direct3D11/ID3DUserDefinedAnnotation.cs diff --git a/Directory.Build.props b/Directory.Build.props index f8e8bc2..2515fe4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ true $(MSBuildThisFileDirectory)NuGet.config - 1.9.8 + 1.9.9 true diff --git a/src/Vortice.Win32.Graphics.Direct3D11/ID3D11Device.cs b/src/Vortice.Win32.Graphics.Direct3D11/ID3D11Device.cs index b655d42..b06b749 100644 --- a/src/Vortice.Win32.Graphics.Direct3D11/ID3D11Device.cs +++ b/src/Vortice.Win32.Graphics.Direct3D11/ID3D11Device.cs @@ -373,6 +373,23 @@ public static unsafe class ID3D11DeviceExtension } } + public static HResult CreateInputLayout(ref this TD3D11Device self, + ReadOnlySpan inputElements, + uint inputElementsCount, + ReadOnlySpan shaderBytecode, + ID3D11InputLayout** ppInputLayout) + where TD3D11Device : unmanaged, ID3D11Device.Interface + { + fixed (InputElementDescription* pInputElements = inputElements) + fixed (byte* pShaderBytecode = shaderBytecode) + { + return self.CreateInputLayout( + pInputElements, inputElementsCount, + pShaderBytecode, (nuint)shaderBytecode.Length, + ppInputLayout); + } + } + public static ComPtr CreateInputLayout(ref this TD3D11Device self, ReadOnlySpan inputElements, ReadOnlySpan shaderBytecode) @@ -392,4 +409,25 @@ public static unsafe class ID3D11DeviceExtension return inputLayout.Move(); } + + public static ComPtr CreateInputLayout(ref this TD3D11Device self, + ReadOnlySpan inputElements, + uint inputElementsCount, + ReadOnlySpan shaderBytecode) + where TD3D11Device : unmanaged, ID3D11Device.Interface + { + using ComPtr inputLayout = default; + + fixed (InputElementDescription* pInputElements = inputElements) + fixed (byte* pShaderBytecode = shaderBytecode) + { + ThrowIfFailed(self.CreateInputLayout( + pInputElements, inputElementsCount, + pShaderBytecode, (nuint)shaderBytecode.Length, + inputLayout.GetAddressOf()) + ); + } + + return inputLayout.Move(); + } } diff --git a/src/Vortice.Win32.Graphics.Direct3D11/ID3DUserDefinedAnnotation.cs b/src/Vortice.Win32.Graphics.Direct3D11/ID3DUserDefinedAnnotation.cs new file mode 100644 index 0000000..e3c9701 --- /dev/null +++ b/src/Vortice.Win32.Graphics.Direct3D11/ID3DUserDefinedAnnotation.cs @@ -0,0 +1,39 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D11; + +unsafe partial struct ID3DUserDefinedAnnotation +{ + public int BeginEvent(string name) + { + fixed (char* namePtr = name) + { + return BeginEvent((ushort*)namePtr); + } + } + + public int BeginEvent(ReadOnlySpan name) + { + fixed (char* namePtr = name) + { + return BeginEvent((ushort*)namePtr); + } + } + + public void SetMarker(string name) + { + fixed (char* namePtr = name) + { + SetMarker((ushort*)namePtr); + } + } + + public void SetMarker(ReadOnlySpan name) + { + fixed (char* namePtr = name) + { + SetMarker((ushort*)namePtr); + } + } +} diff --git a/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Object.cs b/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Object.cs index b988872..6683288 100644 --- a/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Object.cs +++ b/src/Vortice.Win32.Graphics.Direct3D12/ID3D12Object.cs @@ -3,21 +3,23 @@ namespace Win32.Graphics.Direct3D12; -public partial struct ID3D12Object +public static unsafe class ID3D12ObjectExtensions { - public unsafe HResult SetName(ReadOnlySpan name) + public static void SetName(ref this TID3D12Object self, ReadOnlySpan name) + where TID3D12Object : unmanaged, ID3D12Object.Interface { fixed (char* namePtr = name) { - return SetName((ushort*)namePtr); + _ = self.SetName((ushort*)namePtr); } } - public unsafe HResult SetName(string name) + public static void SetName(ref this TID3D12Object self, string name) + where TID3D12Object : unmanaged, ID3D12Object.Interface { fixed (char* namePtr = name) { - return SetName((ushort*)namePtr); + _ = self.SetName((ushort*)namePtr); } } }