allow sampler binding calls to take array segment

moar-validation
cosmonaut 2022-11-15 17:53:30 -08:00
parent c2ef78d136
commit 02b20f79f5
1 changed files with 34 additions and 12 deletions

View File

@ -368,7 +368,7 @@ namespace MoonWorks.Graphics
/// </summary>
/// <param name="textureSamplerBindings">The texture-sampler pairs to bind.</param>
public unsafe void BindVertexSamplers(
params TextureSamplerBinding[] textureSamplerBindings
ArraySegment<TextureSamplerBinding> textureSamplerBindings
)
{
#if DEBUG
@ -379,16 +379,16 @@ namespace MoonWorks.Graphics
throw new System.InvalidOperationException("The vertex shader of the current graphics pipeline does not take any samplers!");
}
if (currentGraphicsPipeline.VertexShaderInfo.SamplerBindingCount < textureSamplerBindings.Length)
if (currentGraphicsPipeline.VertexShaderInfo.SamplerBindingCount < textureSamplerBindings.Count)
{
throw new System.InvalidOperationException("Vertex sampler count exceeds the amount used by the vertex shader!");
}
#endif
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length];
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Count];
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Count];
for (var i = 0; i < textureSamplerBindings.Length; i += 1)
for (var i = 0; i < textureSamplerBindings.Count; i += 1)
{
#if DEBUG
AssertTextureSamplerBindingNonNull(textureSamplerBindings[i]);
@ -408,13 +408,24 @@ namespace MoonWorks.Graphics
}
/// <summary>
/// Binds samplers to be used by the fragment shader.
/// Binds samplers to be used by the vertex shader.
/// </summary>
/// <param name="textureSamplerBindings">An array of texture-sampler pairs to bind.</param>
public unsafe void BindFragmentSamplers(
/// <param name="textureSamplerBindings">The texture-sampler pairs to bind.</param>
public unsafe void BindVertexSamplers(
params TextureSamplerBinding[] textureSamplerBindings
)
{
BindVertexSamplers(new ArraySegment<TextureSamplerBinding>(textureSamplerBindings));
}
/// <summary>
/// Binds samplers to be used by the vertex shader.
/// </summary>
/// <param name="textureSamplerBindings">The texture-sampler pairs to bind.</param>
public unsafe void BindFragmentSamplers(
ArraySegment<TextureSamplerBinding> textureSamplerBindings
)
{
#if DEBUG
AssertGraphicsPipelineBound();
@ -423,16 +434,16 @@ namespace MoonWorks.Graphics
throw new System.InvalidOperationException("The fragment shader of the current graphics pipeline does not take any samplers!");
}
if (currentGraphicsPipeline.FragmentShaderInfo.SamplerBindingCount < textureSamplerBindings.Length)
if (currentGraphicsPipeline.FragmentShaderInfo.SamplerBindingCount < textureSamplerBindings.Count)
{
throw new System.InvalidOperationException("Fragment sampler count exceeds the amount used by the fragment shader!");
}
#endif
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Length];
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Length];
var texturePtrs = stackalloc IntPtr[textureSamplerBindings.Count];
var samplerPtrs = stackalloc IntPtr[textureSamplerBindings.Count];
for (var i = 0; i < textureSamplerBindings.Length; i += 1)
for (var i = 0; i < textureSamplerBindings.Count; i += 1)
{
#if DEBUG
AssertTextureSamplerBindingNonNull(textureSamplerBindings[i]);
@ -451,6 +462,17 @@ namespace MoonWorks.Graphics
);
}
/// <summary>
/// Binds samplers to be used by the fragment shader.
/// </summary>
/// <param name="textureSamplerBindings">An array of texture-sampler pairs to bind.</param>
public unsafe void BindFragmentSamplers(
params TextureSamplerBinding[] textureSamplerBindings
)
{
BindFragmentSamplers(new ArraySegment<TextureSamplerBinding>(textureSamplerBindings));
}
/// <summary>
/// Pushes vertex shader uniforms to the device.
/// </summary>