rework sampler binding API call

pull/14/head
cosmonaut 2021-02-11 12:25:12 -08:00
parent 44cd77eecb
commit e6fa95b823
1 changed files with 18 additions and 4 deletions

View File

@ -213,12 +213,13 @@ namespace MoonWorks.Graphics
} }
public unsafe void BindVertexSamplers( public unsafe void BindVertexSamplers(
params TextureSamplerBinding[] textureSamplerBindings TextureSamplerBinding[] textureSamplerBindings,
int length
) { ) {
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length]; var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
var samplerPtrs = 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; texturePtrs[i] = textureSamplerBindings[i].Texture.Handle;
samplerPtrs[i] = textureSamplerBindings[i].Sampler.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 params TextureSamplerBinding[] textureSamplerBindings
) {
BindVertexSamplers(textureSamplerBindings, textureSamplerBindings.Length);
}
public unsafe void BindFragmentSamplers(
TextureSamplerBinding[] textureSamplerBindings,
int length
) { ) {
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length]; var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
var samplerPtrs = 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; texturePtrs[i] = textureSamplerBindings[i].Texture.Handle;
samplerPtrs[i] = textureSamplerBindings[i].Sampler.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( public unsafe void Clear(
in Rect clearRect, in Rect clearRect,
ClearOptionsFlags clearOptions, ClearOptionsFlags clearOptions,