Add validation checks for AcquireSwapchainTexture and BindVertexBuffers (#37)

This replaces the Refresh-side check for window claim status in AcquireSwapchainTexture, and adds validation to ensure that BindVertexBuffers is not called before BindGraphicsPipeline.

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #37
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
pull/39/head
TheSpydog 2022-12-29 03:18:36 +00:00 committed by cosmonaut
parent d76633bdfc
commit f96298f991
1 changed files with 27 additions and 0 deletions

View File

@ -847,6 +847,10 @@ namespace MoonWorks.Graphics
in BufferBinding bufferBinding, in BufferBinding bufferBinding,
uint firstBinding = 0 uint firstBinding = 0
) { ) {
#if DEBUG
AssertGraphicsPipelineBound();
#endif
var bufferPtrs = stackalloc IntPtr[1]; var bufferPtrs = stackalloc IntPtr[1];
var offsets = stackalloc ulong[1]; var offsets = stackalloc ulong[1];
@ -874,6 +878,10 @@ namespace MoonWorks.Graphics
in BufferBinding bufferBindingTwo, in BufferBinding bufferBindingTwo,
uint firstBinding = 0 uint firstBinding = 0
) { ) {
#if DEBUG
AssertGraphicsPipelineBound();
#endif
var bufferPtrs = stackalloc IntPtr[2]; var bufferPtrs = stackalloc IntPtr[2];
var offsets = stackalloc ulong[2]; var offsets = stackalloc ulong[2];
@ -906,6 +914,10 @@ namespace MoonWorks.Graphics
in BufferBinding bufferBindingThree, in BufferBinding bufferBindingThree,
uint firstBinding = 0 uint firstBinding = 0
) { ) {
#if DEBUG
AssertGraphicsPipelineBound();
#endif
var bufferPtrs = stackalloc IntPtr[3]; var bufferPtrs = stackalloc IntPtr[3];
var offsets = stackalloc ulong[3]; var offsets = stackalloc ulong[3];
@ -942,6 +954,10 @@ namespace MoonWorks.Graphics
in BufferBinding bufferBindingFour, in BufferBinding bufferBindingFour,
uint firstBinding = 0 uint firstBinding = 0
) { ) {
#if DEBUG
AssertGraphicsPipelineBound();
#endif
var bufferPtrs = stackalloc IntPtr[4]; var bufferPtrs = stackalloc IntPtr[4];
var offsets = stackalloc ulong[4]; var offsets = stackalloc ulong[4];
@ -974,6 +990,10 @@ namespace MoonWorks.Graphics
in Span<BufferBinding> bufferBindings, in Span<BufferBinding> bufferBindings,
uint firstBinding = 0 uint firstBinding = 0
) { ) {
#if DEBUG
AssertGraphicsPipelineBound();
#endif
var bufferPtrs = stackalloc IntPtr[bufferBindings.Length]; var bufferPtrs = stackalloc IntPtr[bufferBindings.Length];
var offsets = stackalloc ulong[bufferBindings.Length]; var offsets = stackalloc ulong[bufferBindings.Length];
@ -1623,6 +1643,13 @@ namespace MoonWorks.Graphics
public Texture AcquireSwapchainTexture( public Texture AcquireSwapchainTexture(
Window window Window window
) { ) {
#if DEBUG
if (!window.Claimed)
{
throw new System.InvalidOperationException("Cannot acquire swapchain texture, window has not been claimed!");
}
#endif
var texturePtr = Refresh.Refresh_AcquireSwapchainTexture( var texturePtr = Refresh.Refresh_AcquireSwapchainTexture(
Device.Handle, Device.Handle,
Handle, Handle,