From 42e3ac91af1c5251235f226e76443f0c5675dcbd Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Sat, 27 Jan 2024 03:44:19 +0000 Subject: [PATCH] Vertex instance input shortcut (#53) Reviewed-on: https://gitea.moonside.games/MoonsideGames/MoonWorks/pulls/53 --- src/Graphics/RefreshStructs.cs | 4 ++-- src/Graphics/VertexBindingAndAttributes.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Graphics/RefreshStructs.cs b/src/Graphics/RefreshStructs.cs index d2b8407..6b046bd 100644 --- a/src/Graphics/RefreshStructs.cs +++ b/src/Graphics/RefreshStructs.cs @@ -127,12 +127,12 @@ namespace MoonWorks.Graphics public uint Stride; public VertexInputRate InputRate; - public static VertexBinding Create(uint binding = 0) where T : unmanaged + public static VertexBinding Create(uint binding = 0, VertexInputRate inputRate = VertexInputRate.Vertex) where T : unmanaged { return new VertexBinding { Binding = binding, - InputRate = VertexInputRate.Vertex, + InputRate = inputRate, Stride = (uint) Marshal.SizeOf() }; } diff --git a/src/Graphics/VertexBindingAndAttributes.cs b/src/Graphics/VertexBindingAndAttributes.cs index cff9d55..44217eb 100644 --- a/src/Graphics/VertexBindingAndAttributes.cs +++ b/src/Graphics/VertexBindingAndAttributes.cs @@ -14,9 +14,9 @@ namespace MoonWorks.Graphics VertexAttributes = attributes; } - public static VertexBindingAndAttributes Create(uint bindingIndex) where T : unmanaged, IVertexType + public static VertexBindingAndAttributes Create(uint bindingIndex, uint locationOffset = 0, VertexInputRate inputRate = VertexInputRate.Vertex) where T : unmanaged, IVertexType { - VertexBinding binding = VertexBinding.Create(bindingIndex); + VertexBinding binding = VertexBinding.Create(bindingIndex, inputRate); VertexAttribute[] attributes = new VertexAttribute[T.Formats.Length]; uint offset = 0; @@ -27,7 +27,7 @@ namespace MoonWorks.Graphics attributes[i] = new VertexAttribute { Binding = bindingIndex, - Location = i, + Location = locationOffset + i, Format = format, Offset = offset };