diff --git a/Directory.Build.props b/Directory.Build.props
index 4fa9c8c..d71d2b5 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -14,7 +14,7 @@
true
$(MSBuildThisFileDirectory)NuGet.config
- 1.9.13
+ 1.9.14
true
diff --git a/src/Vortice.Win32.Graphics.Direct3D11/ID3D11DeviceContext.cs b/src/Vortice.Win32.Graphics.Direct3D11/ID3D11DeviceContext.cs
index fc0c18c..402b4c9 100644
--- a/src/Vortice.Win32.Graphics.Direct3D11/ID3D11DeviceContext.cs
+++ b/src/Vortice.Win32.Graphics.Direct3D11/ID3D11DeviceContext.cs
@@ -8,6 +8,7 @@ namespace Win32.Graphics.Direct3D11;
public static unsafe class ID3D11DeviceContextExtensions
{
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RSSetViewport(
ref this TD3D11DeviceContext self,
float x, float y, float width, float height, float minDepth = 0.0f, float maxDepth = 1.0f)
@@ -17,6 +18,7 @@ public static unsafe class ID3D11DeviceContextExtensions
self.RSSetViewports(1, &viewport);
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RSSetViewport(
ref this TD3D11DeviceContext self,
Viewport viewport)
@@ -25,6 +27,17 @@ public static unsafe class ID3D11DeviceContextExtensions
self.RSSetViewports(1, &viewport);
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void RSSetScissorRect(
+ ref this TD3D11DeviceContext self,
+ int width, int height)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ Rect rawRect = Rect.Create(0, 0, width, height);
+ self.RSSetScissorRects(1, &rawRect);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RSSetScissorRect(
ref this TD3D11DeviceContext self,
int x, int y, int width, int height)
@@ -34,6 +47,7 @@ public static unsafe class ID3D11DeviceContextExtensions
self.RSSetScissorRects(1, &rawRect);
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RSSetScissorRect(
ref this TD3D11DeviceContext self,
Rect rect)
@@ -42,6 +56,7 @@ public static unsafe class ID3D11DeviceContextExtensions
self.RSSetScissorRects(1, &rect);
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void OMSetBlendState(
ref this TD3D11DeviceContext self,
ID3D11BlendState* blendState)
@@ -50,6 +65,7 @@ public static unsafe class ID3D11DeviceContextExtensions
self.OMSetBlendState(blendState, null, D3D11_DEFAULT_SAMPLE_MASK);
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void OMSetBlendState(
ref this TD3D11DeviceContext self,
ID3D11BlendState* blendState, float* blendFactor)
@@ -57,126 +73,178 @@ public static unsafe class ID3D11DeviceContextExtensions
{
self.OMSetBlendState(blendState, blendFactor, D3D11_DEFAULT_SAMPLE_MASK);
}
-}
-public unsafe partial struct ID3D11DeviceContext
-{
- public void IASetVertexBuffer(int slot, ID3D11Buffer* buffer, uint stride, uint offset = 0)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void UnsetRenderTargets(ref this TD3D11DeviceContext self)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
- IASetVertexBuffers((uint)slot, 1, buffer == null ? null : &buffer, &stride, &offset);
+ self.OMSetRenderTargets(0, null, null);
}
- public void VSSetShaderResource(uint slot, ID3D11ShaderResourceView* view)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void OMSetRenderTargets(ref this TD3D11DeviceContext self,
+ ID3D11RenderTargetView* renderTargetView, ID3D11DepthStencilView* depthStencilView = null)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
- VSSetShaderResources(slot, 1, view != null ? &view : null);
- }
-
- public void VSSetSampler(uint slot, ID3D11SamplerState* sampler)
- {
- VSSetSamplers(slot, 1, sampler != null ? &sampler : null);
- }
-
- public void VSSetConstantBuffer(uint slot, ID3D11Buffer* constantBuffer)
- {
- VSSetConstantBuffers(slot, 1, constantBuffer != null ? &constantBuffer : null);
- }
-
- public void PSSetShaderResource(uint slot, ID3D11ShaderResourceView* view)
- {
- PSSetShaderResources(slot, 1, view != null ? &view : null);
- }
-
- public void PSSetSampler(uint slot, ID3D11SamplerState* sampler)
- {
- PSSetSamplers(slot, 1, sampler != null ? &sampler : null);
- }
-
- public void PSSetConstantBuffer(uint slot, ID3D11Buffer* constantBuffer)
- {
- PSSetConstantBuffers(slot, 1, constantBuffer != null ? &constantBuffer : null);
- }
-
- public void CSSetShaderResource(uint slot, ID3D11ShaderResourceView* view)
- {
- CSSetShaderResources(slot, 1, view != null ? &view : null);
- }
-
- public void CSSetSampler(uint slot, ID3D11SamplerState* sampler)
- {
- CSSetSamplers(slot, 1, sampler != null ? &sampler : null);
- }
-
- public void CSSetConstantBuffer(uint slot, ID3D11Buffer* constantBuffer)
- {
- CSSetConstantBuffers(slot, 1, constantBuffer != null ? &constantBuffer : null);
- }
-
- public void UnsetRenderTargets()
- {
- OMSetRenderTargets(0, null, null);
- }
-
- public void OMSetRenderTargets(ID3D11RenderTargetView* renderTargetView, ID3D11DepthStencilView* depthStencilView = null)
- {
- OMSetRenderTargets(1,
+ self.OMSetRenderTargets(1,
renderTargetView == null ? null : &renderTargetView,
depthStencilView);
}
- public void ClearRenderTargetView(ID3D11RenderTargetView* renderTargetView, Color4 color)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void OMSetRenderTargets(ref this TD3D11DeviceContext self,
+ ID3D11RenderTargetView*[] renderTargetViews, ID3D11DepthStencilView* depthStencilView = default)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
- ClearRenderTargetView(renderTargetView, (float*)&color);
+ fixed (ID3D11RenderTargetView** ppRenderTargetViews = renderTargetViews)
+ {
+ self.OMSetRenderTargets((uint)renderTargetViews.Length, ppRenderTargetViews, depthStencilView);
+ }
}
- public void ClearUnorderedAccessViewFloat(ID3D11UnorderedAccessView* unorderedAccessView, Color4 color)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void IASetVertexBuffer(ref this TD3D11DeviceContext self,
+ int slot, ID3D11Buffer* buffer, uint stride, uint offset = 0)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
- ClearUnorderedAccessViewFloat(unorderedAccessView, (float*)&color);
+ self.IASetVertexBuffers((uint)slot, 1, buffer == null ? null : &buffer, &stride, &offset);
}
- public HResult Map(ID3D11Texture2D* resource,
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void ClearRenderTargetView(ref this TD3D11DeviceContext self, ID3D11RenderTargetView* renderTargetView, Color4 color)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.ClearRenderTargetView(renderTargetView, (float*)&color);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void ClearUnorderedAccessViewFloat(ref this TD3D11DeviceContext self, ID3D11UnorderedAccessView* unorderedAccessView, Color4 color)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.ClearUnorderedAccessViewFloat(unorderedAccessView, (float*)&color);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ComPtr FinishCommandList(ref this TD3D11DeviceContext self, bool restoreDeferredContextState = false)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ using ComPtr commandList = default;
+ ThrowIfFailed(self.FinishCommandList(restoreDeferredContextState, commandList.GetAddressOf()));
+
+ return commandList.Move();
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static HResult Map(ref this TD3D11DeviceContext self, ID3D11Texture2D* resource,
uint mipSlice, uint arraySlice,
MapMode mode, MapFlags flags,
MappedSubresource* pMappedResource, out uint subresource, out uint mipSize)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
subresource = resource->CalculateSubResourceIndex(mipSlice, arraySlice, out mipSize);
- return Map((ID3D11Resource*)resource, subresource, mode, flags, pMappedResource);
+ return self.Map((ID3D11Resource*)resource, subresource, mode, flags, pMappedResource);
}
- public Span Map(ID3D11Texture2D* resource,
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Span Map(ref this TD3D11DeviceContext self, ID3D11Texture2D* resource,
uint mipSlice, uint arraySlice,
- MapMode mode = MapMode.Read, MapFlags flags = MapFlags.None) where T : unmanaged
+ MapMode mode = MapMode.Read, MapFlags flags = MapFlags.None)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ where T : unmanaged
{
uint subresource = resource->CalculateSubResourceIndex(mipSlice, arraySlice, out uint mipSize);
MappedSubresource mappedSubresource;
- ThrowIfFailed(Map((ID3D11Resource*)resource, subresource, mode, flags, &mappedSubresource));
+ ThrowIfFailed(self.Map((ID3D11Resource*)resource, subresource, mode, flags, &mappedSubresource));
Span source = new(mappedSubresource.pData, (int)(mipSize * mappedSubresource.RowPitch));
return global::System.Runtime.InteropServices.MemoryMarshal.Cast(source);
}
- public void Unmap(ID3D11Texture1D* resource, uint mipSlice, uint arraySlice)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Unmap(ref this TD3D11DeviceContext self, ID3D11Texture1D* resource, uint mipSlice, uint arraySlice)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
uint subresource = resource->CalculateSubResourceIndex(mipSlice, arraySlice, out _);
- Unmap((ID3D11Resource*)resource, subresource);
+ self.Unmap((ID3D11Resource*)resource, subresource);
}
- public void Unmap(ID3D11Texture2D* resource, uint mipSlice, uint arraySlice)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Unmap(ref this TD3D11DeviceContext self, ID3D11Texture2D* resource, uint mipSlice, uint arraySlice)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
uint subresource = resource->CalculateSubResourceIndex(mipSlice, arraySlice, out _);
- Unmap((ID3D11Resource*)resource, subresource);
+ self.Unmap((ID3D11Resource*)resource, subresource);
}
- public void Unmap(ID3D11Texture3D* resource, uint mipSlice, uint arraySlice)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Unmap(ref this TD3D11DeviceContext self, ID3D11Texture3D* resource, uint mipSlice, uint arraySlice)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
uint subresource = resource->CalculateSubResourceIndex(mipSlice, arraySlice, out _);
- Unmap((ID3D11Resource*)resource, subresource);
+ self.Unmap((ID3D11Resource*)resource, subresource);
}
- public ComPtr FinishCommandList(bool RestoreDeferredContextState = false)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void VSSetShaderResource(ref this TD3D11DeviceContext self, uint slot, ID3D11ShaderResourceView* view)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
{
- using ComPtr commandList = default;
- ThrowIfFailed(FinishCommandList(RestoreDeferredContextState, commandList.GetAddressOf()));
+ self.VSSetShaderResources(slot, 1, view != null ? &view : null);
+ }
- return commandList.Move();
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void VSSetSampler(ref this TD3D11DeviceContext self, uint slot, ID3D11SamplerState* sampler)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.VSSetSamplers(slot, 1, sampler != null ? &sampler : null);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void VSSetConstantBuffer(ref this TD3D11DeviceContext self, uint slot, ID3D11Buffer* constantBuffer)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.VSSetConstantBuffers(slot, 1, constantBuffer != null ? &constantBuffer : null);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void PSSetShaderResource(ref this TD3D11DeviceContext self, uint slot, ID3D11ShaderResourceView* view)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.PSSetShaderResources(slot, 1, view != null ? &view : null);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void PSSetSampler(ref this TD3D11DeviceContext self, uint slot, ID3D11SamplerState* sampler)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.PSSetSamplers(slot, 1, sampler != null ? &sampler : null);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void PSSetConstantBuffer(ref this TD3D11DeviceContext self, uint slot, ID3D11Buffer* constantBuffer)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.PSSetConstantBuffers(slot, 1, constantBuffer != null ? &constantBuffer : null);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void CSSetShaderResource(ref this TD3D11DeviceContext self, uint slot, ID3D11ShaderResourceView* view)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.CSSetShaderResources(slot, 1, view != null ? &view : null);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void CSSetSampler(ref this TD3D11DeviceContext self, uint slot, ID3D11SamplerState* sampler)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.CSSetSamplers(slot, 1, sampler != null ? &sampler : null);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void CSSetConstantBuffer(ref this TD3D11DeviceContext self, uint slot, ID3D11Buffer* constantBuffer)
+ where TD3D11DeviceContext : unmanaged, ID3D11DeviceContext.Interface
+ {
+ self.CSSetConstantBuffers(slot, 1, constantBuffer != null ? &constantBuffer : null);
}
}
diff --git a/src/Vortice.Win32/ComPtr.cs b/src/Vortice.Win32/ComPtr.cs
index 0da450b..7ceb8af 100644
--- a/src/Vortice.Win32/ComPtr.cs
+++ b/src/Vortice.Win32/ComPtr.cs
@@ -286,6 +286,17 @@ public unsafe struct ComPtr : IDisposable
return GetAddressOf();
}
+ ///
+ /// Releases the current COM object in use and gets the address of the instance as a void* double pointer.
+ /// This method is only valid when the current instance is on the stack or pinned.
+ /// The raw pointer to the current instance.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void** ReleaseAndGetVoidAddressOf()
+ {
+ _ = InternalRelease();
+ return GetVoidAddressOf();
+ }
+
///
/// Moves the current instance and resets it without releasing the reference.
///