From e6fa95b82350dcf2186d3e8407286b3b58f2c0d7 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 11 Feb 2021 12:25:12 -0800 Subject: [PATCH] rework sampler binding API call --- src/Graphics/CommandBuffer.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index 2a73c74..8b464d8 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -213,12 +213,13 @@ namespace MoonWorks.Graphics } public unsafe void BindVertexSamplers( - params TextureSamplerBinding[] textureSamplerBindings + TextureSamplerBinding[] textureSamplerBindings, + int length ) { var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length]; var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length]; - for (var i = 0; i < textureSamplerBindings.Length; i += 1) + for (var i = 0; i < length; i += 1) { texturePtrs[i] = textureSamplerBindings[i].Texture.Handle; samplerPtrs[i] = textureSamplerBindings[i].Sampler.Handle; @@ -232,13 +233,20 @@ namespace MoonWorks.Graphics ); } - public unsafe void BindFragmentSamplers( + public unsafe void BindVertexSamplers( params TextureSamplerBinding[] textureSamplerBindings + ) { + BindVertexSamplers(textureSamplerBindings, textureSamplerBindings.Length); + } + + public unsafe void BindFragmentSamplers( + TextureSamplerBinding[] textureSamplerBindings, + int length ) { var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length]; var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length]; - for (var i = 0; i < textureSamplerBindings.Length; i += 1) + for (var i = 0; i < length; i += 1) { texturePtrs[i] = textureSamplerBindings[i].Texture.Handle; samplerPtrs[i] = textureSamplerBindings[i].Sampler.Handle; @@ -252,6 +260,12 @@ namespace MoonWorks.Graphics ); } + public unsafe void BindFragmentSamplers( + params TextureSamplerBinding[] textureSamplerBindings + ) { + BindFragmentSamplers(textureSamplerBindings, textureSamplerBindings.Length); + } + public unsafe void Clear( in Rect clearRect, ClearOptionsFlags clearOptions,