From 20c126fb88895717fffbe96efa645b5ce96a56ac Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Thu, 11 Apr 2024 19:33:42 +0300 Subject: [PATCH] New Image3D command. --- Quik/CommandMachine/CommandList.cs | 29 ++++++++++++++++++++++-- Quik/CommandMachine/Image.cs | 18 +++++++++++++++ Quik/CommandMachine/ImageCommandFlags.cs | 10 -------- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 Quik/CommandMachine/Image.cs delete mode 100644 Quik/CommandMachine/ImageCommandFlags.cs diff --git a/Quik/CommandMachine/CommandList.cs b/Quik/CommandMachine/CommandList.cs index 28007e2..d5b3e5d 100644 --- a/Quik/CommandMachine/CommandList.cs +++ b/Quik/CommandMachine/CommandList.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; namespace Quik.CommandMachine { @@ -230,7 +231,7 @@ namespace Quik.CommandMachine Enqueue(uv); } - public void Image(QuikTexture texture, QRectangle[] rectangles, bool interleavedUV = false) + public void Image(QuikTexture texture, ReadOnlySpan rectangles, bool interleavedUV = false) { int count = rectangles.Length; ImageCommandFlags flags = ImageCommandFlags.None; @@ -251,7 +252,7 @@ namespace Quik.CommandMachine } } - public void Image(QuikTexture texture, QRectangle[] rectangles, QRectangle[] uvs) + public void Image(QuikTexture texture, ReadOnlySpan rectangles, ReadOnlySpan uvs) { int count = Math.Min(rectangles.Length, uvs.Length); Enqueue(Command.Image); @@ -265,6 +266,30 @@ namespace Quik.CommandMachine } } + public void Image3D(QuikTexture texture, in Image3DCall call) + { + Enqueue(Command.Image); + Enqueue(new Frame(ImageCommandFlags.Image3d | ImageCommandFlags.Single)); + Enqueue(new Frame(texture)); + Enqueue(call.Rectangle); + Enqueue(call.UVs); + Enqueue(new Frame(call.Layer)); + } + + public void Image3D(QuikTexture texture, ReadOnlySpan calls) + { + Enqueue(Command.Image); + Enqueue(new Frame((int)ImageCommandFlags.Image3d, calls.Length)); + Enqueue(new Frame(texture)); + + foreach (Image3DCall call in calls) + { + Enqueue(call.Rectangle); + Enqueue(call.UVs); + Enqueue(new Frame(call.Layer)); + } + } + public void Splice(CommandList list) { foreach (Frame frame in list) diff --git a/Quik/CommandMachine/Image.cs b/Quik/CommandMachine/Image.cs new file mode 100644 index 0000000..7902e36 --- /dev/null +++ b/Quik/CommandMachine/Image.cs @@ -0,0 +1,18 @@ +namespace Quik.CommandMachine +{ + public enum ImageCommandFlags + { + None = 0, + + Single = 1 << 0, + UVs = 1 << 1, + Image3d = 1 << 2, + } + + public struct Image3DCall + { + public QRectangle Rectangle; + public QRectangle UVs; + public int Layer; + } +} \ No newline at end of file diff --git a/Quik/CommandMachine/ImageCommandFlags.cs b/Quik/CommandMachine/ImageCommandFlags.cs deleted file mode 100644 index dda5b0b..0000000 --- a/Quik/CommandMachine/ImageCommandFlags.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Quik.CommandMachine -{ - public enum ImageCommandFlags - { - None = 0, - - Single = 1 << 0, - UVs = 1 << 1 - } -} \ No newline at end of file