From b8762e2c29c4a23333a1cc5d8c478f7c64c94eaa Mon Sep 17 00:00:00 2001 From: squid233 <60126026+squid233@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:08:18 +0800 Subject: [PATCH] Replace overrun.marshal.MemoryStack with io.github.overrun.memstack.MemoryStack --- modules/overrungl.core/build.gradle.kts | 2 + .../src/main/java/module-info.java | 1 + .../src/main/java/module-info.java | 1 + .../src/main/java/overrungl/glfw/GLFW.java | 106 ++++++++--------- .../src/main/java/module-info.java | 1 + .../src/main/java/overrungl/joml/Matrixn.java | 111 ------------------ .../src/main/java/overrungl/joml/Vectorn.java | 100 ---------------- .../src/main/java/module-info.java | 1 + .../src/main/java/overrungl/opengl/GL10.java | 40 +++---- .../src/main/java/overrungl/opengl/GL10C.java | 32 ++--- .../src/main/java/overrungl/opengl/GL11C.java | 12 +- .../src/main/java/overrungl/opengl/GL15C.java | 34 +++--- .../src/main/java/overrungl/opengl/GL20C.java | 38 +++--- .../src/main/java/overrungl/opengl/GL30C.java | 57 ++++----- .../src/main/java/overrungl/opengl/GL31C.java | 20 ++-- .../src/main/java/overrungl/opengl/GL32C.java | 20 ++-- .../src/main/java/overrungl/opengl/GL33C.java | 32 ++--- .../src/main/java/overrungl/opengl/GL40C.java | 32 ++--- .../src/main/java/overrungl/opengl/GL41C.java | 22 ++-- .../src/main/java/overrungl/opengl/GL42C.java | 10 +- .../src/main/java/overrungl/opengl/GL43C.java | 28 ++--- .../src/main/java/overrungl/opengl/GL45C.java | 106 ++++++++--------- .../src/main/java/overrungl/opengl/GL46C.java | 4 +- .../main/java/overrungl/opengl/GLFinder.java | 4 +- .../src/main/java/module-info.java | 1 + .../src/main/java/overrungl/stb/STBImage.java | 13 +- .../main/java/overrungl/stb/STBTrueType.java | 8 +- .../demo/mem/MemoryUtilBenchmark.java | 11 +- .../main/java/overrungl/demo/nfd/NFDTest.java | 14 +-- .../java/overrungl/demo/opengl/GL30Test.java | 4 +- 30 files changed, 328 insertions(+), 537 deletions(-) diff --git a/modules/overrungl.core/build.gradle.kts b/modules/overrungl.core/build.gradle.kts index 5444dfe4..c9ee25d3 100644 --- a/modules/overrungl.core/build.gradle.kts +++ b/modules/overrungl.core/build.gradle.kts @@ -19,6 +19,8 @@ val targetJavaVersion = jdkVersion.toInt() dependencies { api("io.github.over-run:marshal:$overrunMarshalVersion") api("io.github.over-run:platform:$overrunPlatformVersion") + //TODO + api("io.github.over-run:memstack:0.2.0") } tasks.register("assembleJavadocArgs") { diff --git a/modules/overrungl.core/src/main/java/module-info.java b/modules/overrungl.core/src/main/java/module-info.java index 2cf2348c..3633f68a 100644 --- a/modules/overrungl.core/src/main/java/module-info.java +++ b/modules/overrungl.core/src/main/java/module-info.java @@ -32,6 +32,7 @@ overrungl.vulkan; requires transitive io.github.overrun.marshal; + requires transitive io.github.overrun.memstack; requires transitive io.github.overrun.platform; requires static org.jetbrains.annotations; } diff --git a/modules/overrungl.glfw/src/main/java/module-info.java b/modules/overrungl.glfw/src/main/java/module-info.java index ac5fb419..14b75d2e 100644 --- a/modules/overrungl.glfw/src/main/java/module-info.java +++ b/modules/overrungl.glfw/src/main/java/module-info.java @@ -25,4 +25,5 @@ requires transitive overrungl.core; requires static org.jetbrains.annotations; + requires io.github.overrun.memstack; } diff --git a/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java b/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java index fa91f016..4986f9bd 100644 --- a/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java +++ b/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java @@ -16,10 +16,10 @@ package overrungl.glfw; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Downcall; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.*; import overrungl.internal.RuntimeHelper; @@ -1360,10 +1360,10 @@ static String getPlatformString(int platformCode) { */ @Skip default Triplet.OfInt getVersion() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pMajor = stack.ints(0); - var pMinor = stack.ints(0); - var pRev = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pMajor = stack.allocate(JAVA_INT); + var pMinor = stack.allocate(JAVA_INT); + var pRev = stack.allocate(JAVA_INT); ngetVersion(pMajor, pMinor, pRev); return new Triplet.OfInt(pMajor.get(JAVA_INT, 0), pMinor.get(JAVA_INT, 0), @@ -1448,7 +1448,7 @@ default Triplet.OfInt getVersion() { */ @Skip default Tuple2.OfObjInt getError() { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { final MemorySegment seg = stack.allocate(ADDRESS); final int err = ngetError(seg); return new Tuple2.OfObjInt<>(Unmarshal.unmarshalStringPointer(seg), err); @@ -1561,8 +1561,8 @@ default MemorySegment setErrorCallback(@Nullable GLFWErrorFun callback) { */ @Skip default MemorySegment @Nullable [] getMonitors() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pCount = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pCount = stack.allocate(JAVA_INT); var pMonitors = ngetMonitors(pCount); return Unmarshal.unmarshalAsAddressArray(pMonitors.reinterpret(ADDRESS.scale(0L, pCount.get(JAVA_INT, 0L)))); } @@ -1624,9 +1624,9 @@ default MemorySegment setErrorCallback(@Nullable GLFWErrorFun callback) { */ @Skip default Pair.OfInt getMonitorPos(MemorySegment monitor) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var px = stack.ints(0); - var py = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var px = stack.allocate(JAVA_INT); + var py = stack.allocate(JAVA_INT); ngetMonitorPos(monitor, px, py); return new Pair.OfInt(px.get(JAVA_INT, 0), py.get(JAVA_INT, 0)); } @@ -1679,11 +1679,11 @@ default Pair.OfInt getMonitorPos(MemorySegment monitor) { */ @Skip default Quad.OfInt getMonitorWorkarea(MemorySegment monitor) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var px = stack.ints(0); - var py = stack.ints(0); - var pw = stack.ints(0); - var ph = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var px = stack.allocate(JAVA_INT); + var py = stack.allocate(JAVA_INT); + var pw = stack.allocate(JAVA_INT); + var ph = stack.allocate(JAVA_INT); ngetMonitorWorkarea(monitor, px, py, pw, ph); return new Quad.OfInt(px.get(JAVA_INT, 0), py.get(JAVA_INT, 0), @@ -1741,9 +1741,9 @@ default Quad.OfInt getMonitorWorkarea(MemorySegment monitor) { */ @Skip default Pair.OfInt getMonitorPhysicalSize(MemorySegment monitor) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pw = stack.ints(0); - var ph = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pw = stack.allocate(JAVA_INT); + var ph = stack.allocate(JAVA_INT); ngetMonitorPhysicalSize(monitor, pw, ph); return new Pair.OfInt(pw.get(JAVA_INT, 0), ph.get(JAVA_INT, 0)); } @@ -1797,9 +1797,9 @@ default Pair.OfInt getMonitorPhysicalSize(MemorySegment monitor) { */ @Skip default Pair.OfFloat getMonitorContentScale(MemorySegment monitor) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var px = stack.floats(0F); - var py = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var px = stack.allocate(JAVA_FLOAT); + var py = stack.allocate(JAVA_FLOAT); ngetMonitorContentScale(monitor, px, py); return new Pair.OfFloat(px.get(JAVA_FLOAT, 0), py.get(JAVA_FLOAT, 0)); } @@ -1945,8 +1945,8 @@ default MemorySegment setMonitorCallback(@Nullable GLFWMonitorFun callback) { */ @Skip default @Nullable GLFWVidMode getVideoModes(MemorySegment monitor) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pCount = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pCount = stack.allocate(JAVA_INT); var pModes = ngetVideoModes(monitor, pCount); if (Unmarshal.isNullPointer(pModes)) { return null; @@ -2596,9 +2596,9 @@ default void setWindowIcon(MemorySegment window, @Nullable GLFWImage images) { */ @Skip default Pair.OfInt getWindowPos(MemorySegment window) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var px = stack.ints(0); - var py = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var px = stack.allocate(JAVA_INT); + var py = stack.allocate(JAVA_INT); ngetWindowPos(window, px, py); return new Pair.OfInt(px.get(JAVA_INT, 0), py.get(JAVA_INT, 0)); } @@ -2677,9 +2677,9 @@ default Pair.OfInt getWindowPos(MemorySegment window) { */ @Skip default Pair.OfInt getWindowSize(MemorySegment window) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pw = stack.ints(0); - var ph = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pw = stack.allocate(JAVA_INT); + var ph = stack.allocate(JAVA_INT); ngetWindowSize(window, pw, ph); return new Pair.OfInt(pw.get(JAVA_INT, 0), ph.get(JAVA_INT, 0)); } @@ -2834,9 +2834,9 @@ default Pair.OfInt getWindowSize(MemorySegment window) { */ @Skip default Pair.OfInt getFramebufferSize(MemorySegment window) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pw = stack.ints(0); - var ph = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pw = stack.allocate(JAVA_INT); + var ph = stack.allocate(JAVA_INT); ngetFramebufferSize(window, pw, ph); return new Pair.OfInt(pw.get(JAVA_INT, 0), ph.get(JAVA_INT, 0)); } @@ -2901,11 +2901,11 @@ default Pair.OfInt getFramebufferSize(MemorySegment window) { */ @Skip default Quad.OfInt getWindowFrameSize(MemorySegment window) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pl = stack.ints(0); - var pt = stack.ints(0); - var pr = stack.ints(0); - var pb = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pl = stack.allocate(JAVA_INT); + var pt = stack.allocate(JAVA_INT); + var pr = stack.allocate(JAVA_INT); + var pb = stack.allocate(JAVA_INT); ngetWindowFrameSize(window, pl, pt, pr, pb); return new Quad.OfInt(pl.get(JAVA_INT, 0), pt.get(JAVA_INT, 0), @@ -2961,9 +2961,9 @@ default Quad.OfInt getWindowFrameSize(MemorySegment window) { */ @Skip default Pair.OfFloat getWindowContentScale(MemorySegment window) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var px = stack.floats(0F); - var py = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var px = stack.allocate(JAVA_FLOAT); + var py = stack.allocate(JAVA_FLOAT); ngetWindowContentScale(window, px, py); return new Pair.OfFloat(px.get(JAVA_FLOAT, 0), py.get(JAVA_FLOAT, 0)); } @@ -4113,9 +4113,9 @@ default MemorySegment setWindowContentScaleCallback(MemorySegment window, @Nulla */ @Skip default Pair.OfDouble getCursorPos(MemorySegment window) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var px = stack.doubles(0D); - var py = stack.doubles(0D); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var px = stack.allocate(JAVA_DOUBLE); + var py = stack.allocate(JAVA_DOUBLE); ngetCursorPos(window, px, py); return new Pair.OfDouble(px.get(JAVA_DOUBLE, 0), py.get(JAVA_DOUBLE, 0)); } @@ -4635,8 +4635,8 @@ default MemorySegment setDropCallback(MemorySegment window, @Nullable GLFWDropFu */ @Skip default float @Nullable [] getJoystickAxes(int jid) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pCount = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pCount = stack.allocate(JAVA_INT); MemorySegment pAxes = ngetJoystickAxes(jid, pCount); final int count = pCount.get(JAVA_INT, 0); if (count == 0) return null; @@ -4687,8 +4687,8 @@ default MemorySegment setDropCallback(MemorySegment window, @Nullable GLFWDropFu */ @Skip default int @Nullable [] getJoystickButtons(int jid) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pCount = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pCount = stack.allocate(JAVA_INT); MemorySegment pButtons = ngetJoystickButtons(jid, pCount); final int count = pCount.get(JAVA_INT, 0); if (count == 0) return null; @@ -4755,8 +4755,8 @@ default MemorySegment setDropCallback(MemorySegment window, @Nullable GLFWDropFu */ @Skip default byte[] getJoystickHats(int jid) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pCount = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pCount = stack.allocate(JAVA_INT); var pHats = ngetJoystickHats(jid, pCount); return Unmarshal.unmarshalAsByteArray(pHats.reinterpret(JAVA_BYTE.scale(0L, pCount.get(JAVA_INT, 0)))); } @@ -5122,7 +5122,7 @@ default void nsetClipboardString(MemorySegment string) { */ @Skip default void setClipboardString(String string) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { nsetClipboardString(stack.allocateFrom(string)); } } @@ -5545,8 +5545,8 @@ default String getClipboardString() { */ @Skip default String @Nullable [] getRequiredInstanceExtensions() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pCount = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pCount = stack.allocate(JAVA_INT); MemorySegment pExt = ngetRequiredInstanceExtensions(pCount); final int count = pCount.get(JAVA_INT, 0); if (count == 0) return null; diff --git a/modules/overrungl.joml/src/main/java/module-info.java b/modules/overrungl.joml/src/main/java/module-info.java index 413eddba..cffc9288 100644 --- a/modules/overrungl.joml/src/main/java/module-info.java +++ b/modules/overrungl.joml/src/main/java/module-info.java @@ -25,4 +25,5 @@ requires transitive overrungl.core; requires transitive org.joml; + requires io.github.overrun.memstack; } diff --git a/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java b/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java index 55cab3ec..36f43f35 100644 --- a/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java +++ b/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java @@ -17,7 +17,6 @@ package overrungl.joml; import org.joml.*; -import overrun.marshal.MemoryStack; import overrungl.util.MemoryUtil; import java.lang.foreign.MemoryLayout; @@ -290,116 +289,6 @@ public static MemorySegment malloc(Matrix4dc mat) { return put(mat, MemoryUtil.malloc(MAT4D)); } - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix2fc mat) { - return put(mat, stack.malloc(MAT2F)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix2dc mat) { - return put(mat, stack.malloc(MAT2D)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix3x2fc mat) { - return put(mat, stack.malloc(MAT3X2F)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix3x2dc mat) { - return put(mat, stack.malloc(MAT3X2D)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix3fc mat) { - return put(mat, stack.malloc(MAT3F)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix3dc mat) { - return put(mat, stack.malloc(MAT3D)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix4x3fc mat) { - return put(mat, stack.malloc(MAT4X3F)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix4x3dc mat) { - return put(mat, stack.malloc(MAT4X3D)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix4fc mat) { - return put(mat, stack.malloc(MAT4F)); - } - - /** - * Allocates the matrix on stack. - * - * @param stack the memory stack - * @param mat the matrix - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Matrix4dc mat) { - return put(mat, stack.malloc(MAT4D)); - } - /** * Puts the matrix at the given offset. * diff --git a/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java b/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java index da229136..c17d84ae 100644 --- a/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java +++ b/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java @@ -17,7 +17,6 @@ package overrungl.joml; import org.joml.*; -import overrun.marshal.MemoryStack; import overrungl.util.MemoryUtil; import java.lang.foreign.MemoryLayout; @@ -264,105 +263,6 @@ public static MemorySegment malloc(Vector4dc vec) { return put(vec, MemoryUtil.malloc(VEC4D)); } - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector2ic vec) { - return put(vec, stack.malloc(VEC2I)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector2fc vec) { - return put(vec, stack.malloc(VEC2F)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector2dc vec) { - return put(vec, stack.malloc(VEC2D)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector3ic vec) { - return put(vec, stack.malloc(VEC3I)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector3fc vec) { - return put(vec, stack.malloc(VEC3F)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector3dc vec) { - return put(vec, stack.malloc(VEC3D)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector4ic vec) { - return put(vec, stack.malloc(VEC4I)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector4fc vec) { - return put(vec, stack.malloc(VEC4F)); - } - - /** - * Allocates the vector on stack. - * - * @param stack the memory stack - * @param vec the vector - * @return the memory address - */ - public static MemorySegment malloc(MemoryStack stack, Vector4dc vec) { - return put(vec, stack.malloc(VEC4D)); - } - /** * Puts the vector at the given offset. * diff --git a/modules/overrungl.opengl/src/main/java/module-info.java b/modules/overrungl.opengl/src/main/java/module-info.java index 9a87a7d3..d4634274 100644 --- a/modules/overrungl.opengl/src/main/java/module-info.java +++ b/modules/overrungl.opengl/src/main/java/module-info.java @@ -39,4 +39,5 @@ requires transitive overrungl.core; requires static org.jetbrains.annotations; + requires io.github.overrun.memstack; } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10.java index de5d92c1..24c05a5a 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -508,7 +508,7 @@ default void getClipPlane(int plane, MemorySegment equation) { @Skip default double[] getClipPlane(int plane) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { var pEq = stack.allocate(JAVA_DOUBLE, 4); getClipPlane(plane, pEq); return Unmarshal.unmarshalAsDoubleArray(pEq); @@ -527,8 +527,8 @@ default void getLightfv(SegmentAllocator allocator, int light, int pname, @Ref f @Skip default float getLightfv(int light, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_FLOAT); getLightfv(light, pname, pParams); return pParams.get(JAVA_FLOAT, 0); } @@ -546,8 +546,8 @@ default void getLightiv(SegmentAllocator allocator, int light, int pname, @Ref i @Skip default int getLightiv(int light, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_INT); getLightiv(light, pname, pParams); return pParams.get(JAVA_INT, 0); } @@ -565,8 +565,8 @@ default void getMapdv(SegmentAllocator allocator, int target, int query, @Ref do @Skip default double getMapdv(int target, int query) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pv = stack.doubles(0D); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pv = stack.allocate(JAVA_DOUBLE); getMapdv(target, query, pv); return pv.get(JAVA_DOUBLE, 0); } @@ -584,8 +584,8 @@ default void getMapfv(SegmentAllocator allocator, int target, int query, @Ref fl @Skip default float getMapfv(int target, int query) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pv = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pv = stack.allocate(JAVA_FLOAT); getMapfv(target, query, pv); return pv.get(JAVA_FLOAT, 0); } @@ -603,8 +603,8 @@ default void getMapiv(SegmentAllocator allocator, int target, int query, @Ref in @Skip default int getMapiv(int target, int query) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pv = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pv = stack.allocate(JAVA_INT); getMapiv(target, query, pv); return pv.get(JAVA_INT, 0); } @@ -622,8 +622,8 @@ default void getMaterialfv(SegmentAllocator allocator, int face, int pname, @Ref @Skip default float getMaterialfv(int face, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_FLOAT); getMaterialfv(face, pname, pParams); return pParams.get(JAVA_FLOAT, 0); } @@ -641,8 +641,8 @@ default void getMaterialiv(SegmentAllocator allocator, int face, int pname, @Ref @Skip default int getMaterialiv(int face, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_INT); getMaterialiv(face, pname, pParams); return pParams.get(JAVA_INT, 0); } @@ -700,8 +700,8 @@ default void getTexEnvfv(SegmentAllocator allocator, int target, int pname, @Ref @Skip default float getTexEnvfv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_FLOAT); getTexEnvfv(target, pname, pParams); return pParams.get(JAVA_FLOAT, 0); } @@ -719,8 +719,8 @@ default void getTexEnviv(SegmentAllocator allocator, int target, int pname, @Ref @Skip default int getTexEnviv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_INT); getTexEnviv(target, pname, pParams); return pParams.get(JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10C.java index f63c78f5..cb15adfe 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL10C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -303,7 +303,7 @@ default void getBooleanv(SegmentAllocator allocator, int pname, @Ref boolean[] d @Skip default boolean getBooleanv(int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { var pData = stack.allocate(JAVA_BOOLEAN); getBooleanv(pname, pData); return pData.get(JAVA_BOOLEAN, 0); @@ -322,8 +322,8 @@ default void getDoublev(SegmentAllocator allocator, int pname, @Ref double[] dat @Skip default double getDoublev(int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pData = stack.doubles(0D); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pData = stack.allocate(JAVA_DOUBLE); getDoublev(pname, pData); return pData.get(JAVA_DOUBLE, 0); } @@ -346,8 +346,8 @@ default void getFloatv(SegmentAllocator allocator, int pname, @Ref float[] data) @Skip default float getFloatv(int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pData = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pData = stack.allocate(JAVA_FLOAT); getFloatv(pname, pData); return pData.get(JAVA_FLOAT, 0); } @@ -365,8 +365,8 @@ default void getIntegerv(SegmentAllocator allocator, int pname, @Ref int[] data) @Skip default int getIntegerv(int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pData = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pData = stack.allocate(JAVA_INT); getIntegerv(pname, pData); return pData.get(JAVA_INT, 0); } @@ -401,8 +401,8 @@ default void getTexLevelParameterfv(SegmentAllocator allocator, int target, int @Skip default float getTexLevelParameterfv(int target, int level, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_FLOAT); getTexLevelParameterfv(target, level, pname, pParams); return pParams.get(JAVA_FLOAT, 0); } @@ -420,8 +420,8 @@ default void getTexLevelParameteriv(SegmentAllocator allocator, int target, int @Skip default int getTexLevelParameteriv(int target, int level, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_INT); getTexLevelParameteriv(target, level, pname, pParams); return pParams.get(JAVA_INT, 0); } @@ -439,8 +439,8 @@ default void getTexParameterfv(SegmentAllocator allocator, int target, int pname @Skip default float getTexParameterfv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_FLOAT); getTexParameterfv(target, pname, pParams); return pParams.get(JAVA_FLOAT, 0); } @@ -458,8 +458,8 @@ default void getTexParameteriv(SegmentAllocator allocator, int target, int pname @Skip default int getTexParameteriv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_INT); getTexParameteriv(target, pname, pParams); return pParams.get(JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL11C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL11C.java index a01d444c..827f4c89 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL11C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL11C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -99,7 +99,7 @@ default void deleteTextures(int n, MemorySegment textures) { @Skip default void deleteTextures(int... textures) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteTextures(textures.length, Marshal.marshal(stack, textures)); } } @@ -143,8 +143,8 @@ default void genTextures(SegmentAllocator allocator, @Ref int[] textures) { @Skip default int genTextures() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pTex = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pTex = stack.allocate(ValueLayout.JAVA_INT); genTextures(1, pTex); return pTex.get(ValueLayout.JAVA_INT, 0); } @@ -157,8 +157,8 @@ default void getPointerv(int pname, MemorySegment params) { @Skip default MemorySegment getPointer(int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.segments(MemorySegment.NULL); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(ValueLayout.ADDRESS); getPointerv(pname, pParams); return pParams.get(ValueLayout.ADDRESS, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL15C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL15C.java index b1e76d17..abfb2ed4 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL15C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL15C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -181,7 +181,7 @@ default void deleteBuffers(int n, MemorySegment buffers) { @Skip default void deleteBuffers(int... buffers) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteBuffers(buffers.length, Marshal.marshal(stack, buffers)); } } @@ -193,7 +193,7 @@ default void deleteQueries(int n, MemorySegment ids) { @Skip default void deleteQueries(int... ids) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteQueries(ids.length, Marshal.marshal(stack, ids)); } } @@ -217,8 +217,8 @@ default void genBuffers(SegmentAllocator allocator, @Ref int[] buffers) { @Skip default int genBuffers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); genBuffers(1, seg); return seg.get(ValueLayout.JAVA_INT, 0); } @@ -238,8 +238,8 @@ default void genQueries(SegmentAllocator allocator, @Ref int[] ids) { @Skip default int genQueries() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); genQueries(1, seg); return seg.get(ValueLayout.JAVA_INT, 0); } @@ -252,8 +252,8 @@ default void getBufferParameteriv(int target, int pname, MemorySegment params) { @Skip default int getBufferParameteriv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); getBufferParameteriv(target, pname, seg); return seg.get(ValueLayout.JAVA_INT, 0); } @@ -266,8 +266,8 @@ default void getBufferPointerv(int target, int pname, MemorySegment params) { @Skip default MemorySegment getBufferPointerv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.segments(MemorySegment.NULL); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.ADDRESS); getBufferPointerv(target, pname, seg); return seg.get(ValueLayout.ADDRESS, 0); } @@ -327,8 +327,8 @@ default void getQueryObjectiv(int id, int pname, MemorySegment params) { @Skip default int getQueryObjectiv(int id, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); getQueryObjectiv(id, pname, seg); return seg.get(ValueLayout.JAVA_INT, 0); } @@ -341,8 +341,8 @@ default void getQueryObjectuiv(int id, int pname, MemorySegment params) { @Skip default int getQueryObjectuiv(int id, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); getQueryObjectuiv(id, pname, seg); return seg.get(ValueLayout.JAVA_INT, 0); } @@ -355,8 +355,8 @@ default void getQueryiv(int target, int pname, MemorySegment params) { @Skip default int getQueryiv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); getQueryiv(target, pname, seg); return seg.get(ValueLayout.JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL20C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL20C.java index be4e4232..aa3fdfd7 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL20C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL20C.java @@ -16,10 +16,10 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -255,7 +255,7 @@ default void getProgramInfoLog(int program, int bufSize, MemorySegment length, M @Skip default String getProgramInfoLog(int program, int bufSize, @Ref int @Nullable [] length) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { var pLen = Marshal.marshal(stack, length); var pLog = stack.allocate(JAVA_BYTE, bufSize); getProgramInfoLog(program, bufSize, pLen, pLog); @@ -281,8 +281,8 @@ default void getProgramiv(SegmentAllocator allocator, int program, int pname, @R @Skip default int getProgramiv(int program, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getProgramiv(program, pname, seg); return seg.get(JAVA_INT, 0); } @@ -295,7 +295,7 @@ default void getShaderInfoLog(int shader, int bufSize, MemorySegment length, Mem @Skip default String getShaderInfoLog(int shader, int bufSize, @Ref int @Nullable [] length) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { var pLen = Marshal.marshal(stack, length); var pLog = stack.allocate(JAVA_BYTE, bufSize); getShaderInfoLog(shader, bufSize, pLen, pLog); @@ -316,7 +316,7 @@ default void getShaderSource(int shader, int bufSize, MemorySegment length, Memo @Skip default String getShaderSource(int shader, int bufSize, @Ref int @Nullable [] length) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { var pLen = Marshal.marshal(stack, length); var pSrc = stack.allocate(JAVA_BYTE, bufSize); getShaderSource(shader, bufSize, pLen, pSrc); @@ -342,8 +342,8 @@ default void getShaderiv(SegmentAllocator allocator, int shader, int pname, @Ref @Skip default int getShaderiv(int shader, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getShaderiv(shader, pname, seg); return seg.get(JAVA_INT, 0); } @@ -371,8 +371,8 @@ default void getUniformfv(SegmentAllocator allocator, int program, int location, @Skip default float getUniformfv(int program, int location) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_FLOAT); getUniformfv(program, location, seg); return seg.get(JAVA_FLOAT, 0); } @@ -390,8 +390,8 @@ default void getUniformiv(SegmentAllocator allocator, int program, int location, @Skip default int getUniformiv(int program, int location) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getUniformiv(program, location, seg); return seg.get(JAVA_INT, 0); } @@ -439,8 +439,8 @@ default void getVertexAttribdv(SegmentAllocator allocator, int index, int pname, @Skip default double getVertexAttribdv(int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.doubles(0D); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_DOUBLE); getVertexAttribdv(index, pname, seg); return seg.get(JAVA_DOUBLE, 0); } @@ -458,8 +458,8 @@ default void getVertexAttribfv(SegmentAllocator allocator, int index, int pname, @Skip default float getVertexAttribfv(int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_FLOAT); getVertexAttribfv(index, pname, seg); return seg.get(JAVA_FLOAT, 0); } @@ -477,8 +477,8 @@ default void getVertexAttribiv(SegmentAllocator allocator, int index, int pname, @Skip default int getVertexAttribiv(int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getVertexAttribiv(index, pname, seg); return seg.get(JAVA_INT, 0); } @@ -511,7 +511,7 @@ default void shaderSource(SegmentAllocator allocator, int shader, String[] strin @Skip default void shaderSource(int shader, String string) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { shaderSource(shader, 1, stack.allocateFrom(ADDRESS, Marshal.marshal(stack, string)), MemorySegment.NULL); } } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL30C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL30C.java index 01e20e10..e143d1a5 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL30C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL30C.java @@ -16,10 +16,10 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -32,7 +32,8 @@ import java.lang.foreign.SegmentAllocator; import java.lang.invoke.MethodHandle; -import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.ValueLayout.JAVA_BOOLEAN; +import static java.lang.foreign.ValueLayout.JAVA_INT; /** * The OpenGL 3.0 core profile functions. @@ -389,7 +390,7 @@ default void deleteFramebuffers(int n, MemorySegment framebuffers) { @Skip default void deleteFramebuffers(int... framebuffers) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteFramebuffers(framebuffers.length, Marshal.marshal(stack, framebuffers)); } } @@ -401,7 +402,7 @@ default void deleteRenderbuffers(int n, MemorySegment renderbuffers) { @Skip default void deleteRenderbuffers(int... renderbuffers) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteRenderbuffers(renderbuffers.length, Marshal.marshal(stack, renderbuffers)); } } @@ -413,7 +414,7 @@ default void deleteVertexArrays(int n, MemorySegment arrays) { @Skip default void deleteVertexArrays(int... arrays) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteVertexArrays(arrays.length, Marshal.marshal(stack, arrays)); } } @@ -482,8 +483,8 @@ default void genFramebuffers(SegmentAllocator allocator, @Ref int[] framebuffers @Skip default int genFramebuffers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); genFramebuffers(1, seg); return seg.get(JAVA_INT, 0); } @@ -503,8 +504,8 @@ default void genRenderbuffers(SegmentAllocator allocator, @Ref int[] renderbuffe @Skip default int genRenderbuffers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); genRenderbuffers(1, seg); return seg.get(JAVA_INT, 0); } @@ -524,8 +525,8 @@ default void genVertexArrays(SegmentAllocator allocator, @Ref int[] arrays) { @Skip default int genVertexArrays() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); genVertexArrays(1, seg); return seg.get(JAVA_INT, 0); } @@ -548,7 +549,7 @@ default void getBooleani_v(SegmentAllocator allocator, int target, int index, @R @Skip default boolean getBooleani_v(int target, int index) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { var seg = stack.allocate(JAVA_BOOLEAN); getBooleani_v(target, index, seg); return seg.get(JAVA_BOOLEAN, 0); @@ -572,8 +573,8 @@ default void getFramebufferAttachmentParameteriv(int target, int attachment, int @Skip default int getFramebufferAttachmentParameteriv(int target, int attachment, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getFramebufferAttachmentParameteriv(target, attachment, pname, seg); return seg.get(JAVA_INT, 0); } @@ -591,8 +592,8 @@ default void getIntegeri_v(SegmentAllocator allocator, int target, int index, @R @Skip default int getIntegeri_v(int target, int index) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getIntegeri_v(target, index, seg); return seg.get(JAVA_INT, 0); } @@ -610,8 +611,8 @@ default void getRenderbufferParameteriv(int target, int pname, @Ref int[] params @Skip default int getRenderbufferParameteriv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getRenderbufferParameteriv(target, pname, seg); return seg.get(JAVA_INT, 0); } @@ -641,8 +642,8 @@ default void getTexParameterIiv(SegmentAllocator allocator, int target, int pnam @Skip default int getTexParameterIiv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getTexParameterIiv(target, pname, seg); return seg.get(JAVA_INT, 0); } @@ -660,8 +661,8 @@ default void getTexParameterIuiv(SegmentAllocator allocator, int target, int pna @Skip default int getTexParameterIuiv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getTexParameterIuiv(target, pname, seg); return seg.get(JAVA_INT, 0); } @@ -689,8 +690,8 @@ default void getUniformuiv(SegmentAllocator allocator, int program, int location @Skip default int getUniformuiv(int program, int location) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getUniformuiv(program, location, seg); return seg.get(JAVA_INT, 0); } @@ -708,8 +709,8 @@ default void getVertexAttribIiv(SegmentAllocator allocator, int index, int pname @Skip default int getVertexAttribIiv(int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getVertexAttribIiv(index, pname, seg); return seg.get(JAVA_INT, 0); } @@ -727,8 +728,8 @@ default void getVertexAttribIuiv(SegmentAllocator allocator, int index, int pnam @Skip default int getVertexAttribIuiv(int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getVertexAttribIuiv(index, pname, seg); return seg.get(JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL31C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL31C.java index ebdd273e..422f716b 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL31C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL31C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -142,8 +142,8 @@ default void getActiveUniformBlockName(int program, int uniformBlockIndex, int b @Skip default String getActiveUniformBlockName(int program, int uniformBlockIndex, int bufSize) { - try (MemoryStack stack = MemoryStack.stackPush()) { - final MemorySegment length = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + final MemorySegment length = stack.allocate(ValueLayout.JAVA_INT); var pName = stack.allocate(ValueLayout.JAVA_BYTE, bufSize); getActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, pName); return Unmarshal.unmarshalAsString(pName.reinterpret(length.get(ValueLayout.JAVA_INT, 0L) + 1)); @@ -167,8 +167,8 @@ default void getActiveUniformName(int program, int uniformIndex, int bufSize, Me @Skip default String getActiveUniformName(int program, int uniformIndex, int bufSize) { - try (MemoryStack stack = MemoryStack.stackPush()) { - final MemorySegment length = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + final MemorySegment length = stack.allocate(ValueLayout.JAVA_INT); var pName = stack.allocate(ValueLayout.JAVA_BYTE, bufSize); getActiveUniformName(program, uniformIndex, bufSize, length, pName); return Unmarshal.unmarshalAsString(pName.reinterpret(length.get(ValueLayout.JAVA_INT, 0L) + 1)); @@ -189,9 +189,9 @@ default void getActiveUniformsiv(SegmentAllocator allocator, int program, int[] @Skip default int getActiveUniformsiv(int program, int uniformIndex, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); - getActiveUniformsiv(program, 1, stack.ints(uniformIndex), pname, seg); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); + getActiveUniformsiv(program, 1, stack.allocateFrom(ValueLayout.JAVA_INT, uniformIndex), pname, seg); return seg.get(ValueLayout.JAVA_INT, 0); } } @@ -220,8 +220,8 @@ default void getUniformIndices(SegmentAllocator allocator, int program, String[] @Skip default int getUniformIndices(int program, String uniformName) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); getUniformIndices(program, 1, stack.allocateFrom(uniformName), seg); return seg.get(ValueLayout.JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL32C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL32C.java index bfe44bef..b78d4286 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL32C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL32C.java @@ -16,10 +16,10 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -197,8 +197,8 @@ default void getBufferParameteri64v(int target, int pname, MemorySegment params) @Skip default long getBufferParameteri64v(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.longs(0L); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_LONG); getBufferParameteri64v(target, pname, seg); return seg.get(JAVA_LONG, 0); } @@ -216,8 +216,8 @@ default void getInteger64i_v(SegmentAllocator allocator, int target, int index, @Skip default long getInteger64i_v(int target, int index) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.longs(0L); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_LONG); getInteger64i_v(target, index, seg); return seg.get(JAVA_LONG, 0); } @@ -235,8 +235,8 @@ default void getInteger64v(SegmentAllocator allocator, int pname, @Ref long[] da @Skip default long getInteger64v(int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pData = stack.longs(0L); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pData = stack.allocate(JAVA_LONG); getInteger64v(pname, pData); return pData.get(JAVA_LONG, 0); } @@ -254,7 +254,7 @@ default void getMultisamplefv(SegmentAllocator allocator, int pname, int index, @Skip default float[] getMultisamplefv(int pname, int index) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { float[] val = new float[2]; getMultisamplefv(stack, pname, index, val); return val; @@ -277,8 +277,8 @@ default void getSynciv(SegmentAllocator allocator, MemorySegment sync, int pname @Skip default int getSynciv(MemorySegment sync, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getSynciv(sync, pname, 1, MemorySegment.NULL, seg); return seg.get(JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL33C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL33C.java index bba0e81e..d180b5a9 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL33C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL33C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -85,7 +85,7 @@ default void deleteSamplers(int count, MemorySegment samplers) { @Skip default void deleteSamplers(int... samplers) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteSamplers(samplers.length, Marshal.marshal(stack, samplers)); } } @@ -104,8 +104,8 @@ default void genSamplers(SegmentAllocator allocator, @Ref int[] samplers) { @Skip default int genSamplers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); genSamplers(1, seg); return seg.get(JAVA_INT, 0); } @@ -128,8 +128,8 @@ default void getQueryObjecti64v(int id, int pname, MemorySegment params) { @Skip default long getQueryObjecti64v(int id, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.longs(0L); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_LONG); getQueryObjecti64v(id, pname, seg); return seg.get(JAVA_LONG, 0); } @@ -142,8 +142,8 @@ default void getQueryObjectui64v(int id, int pname, MemorySegment params) { @Skip default long getQueryObjectui64v(int id, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.longs(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_LONG); getQueryObjectui64v(id, pname, seg); return seg.get(JAVA_LONG, 0); } @@ -161,8 +161,8 @@ default void getSamplerParameterIiv(SegmentAllocator allocator, int sampler, int @Skip default int getSamplerParameterIiv(int sampler, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getSamplerParameterIiv(sampler, pname, seg); return seg.get(JAVA_INT, 0); } @@ -180,8 +180,8 @@ default void getSamplerParameterIuiv(SegmentAllocator allocator, int sampler, in @Skip default int getSamplerParameterIuiv(int sampler, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getSamplerParameterIuiv(sampler, pname, seg); return seg.get(JAVA_INT, 0); } @@ -199,8 +199,8 @@ default void getSamplerParameterfv(SegmentAllocator allocator, int sampler, int @Skip default float getSamplerParameterf(int sampler, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_FLOAT); getSamplerParameterfv(sampler, pname, seg); return seg.get(JAVA_FLOAT, 0); } @@ -218,8 +218,8 @@ default void getSamplerParameteriv(SegmentAllocator allocator, int sampler, int @Skip default int getSamplerParameteri(int sampler, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getSamplerParameteriv(sampler, pname, seg); return seg.get(JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL40C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL40C.java index 0687281f..6c80412e 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL40C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL40C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -169,7 +169,7 @@ default void deleteTransformFeedbacks(int n, MemorySegment ids) { @Skip default void deleteTransformFeedbacks(int... ids) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteTransformFeedbacks(ids.length, Marshal.marshal(stack, ids)); } } @@ -233,8 +233,8 @@ default void genTransformFeedbacks(SegmentAllocator allocator, @Ref int[] ids) { @Skip default int genTransformFeedbacks() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); genTransformFeedbacks(1, seg); return seg.get(JAVA_INT, 0); } @@ -247,8 +247,8 @@ default void getActiveSubroutineName(int program, int shaderType, int index, int @Skip default String getActiveSubroutineName(int program, int shaderType, int index, int bufSize) { - try (MemoryStack stack = MemoryStack.stackPush()) { - final MemorySegment length = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + final MemorySegment length = stack.allocate(JAVA_INT); var seg = stack.allocate(JAVA_BYTE, bufSize); getActiveSubroutineName(program, shaderType, index, bufSize, length, seg); return Unmarshal.unmarshalAsString(seg.reinterpret(length.get(JAVA_INT, 0L) + 1)); @@ -262,8 +262,8 @@ default void getActiveSubroutineUniformName(int program, int shaderType, int ind @Skip default String getActiveSubroutineUniformName(int program, int shaderType, int index, int bufSize) { - try (MemoryStack stack = MemoryStack.stackPush()) { - final MemorySegment length = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + final MemorySegment length = stack.allocate(JAVA_INT); var seg = stack.allocate(JAVA_BYTE, bufSize); getActiveSubroutineUniformName(program, shaderType, index, bufSize, length, seg); return Unmarshal.unmarshalAsString(seg.reinterpret(length.get(JAVA_INT, 0L) + 1)); @@ -282,8 +282,8 @@ default void getActiveSubroutineUniformiv(SegmentAllocator allocator, int progra @Skip default int getActiveSubroutineUniformiv(int program, int shaderType, int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getActiveSubroutineUniformiv(program, shaderType, index, pname, seg); return seg.get(JAVA_INT, 0); } @@ -296,8 +296,8 @@ default void getProgramStageiv(int program, int shaderType, int pname, MemorySeg @Skip default int getProgramStageiv(int program, int shaderType, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getProgramStageiv(program, shaderType, pname, seg); return seg.get(JAVA_INT, 0); } @@ -310,8 +310,8 @@ default void getQueryIndexediv(int target, int index, int pname, MemorySegment p @Skip default int getQueryIndexediv(int target, int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getQueryIndexediv(target, index, pname, seg); return seg.get(JAVA_INT, 0); } @@ -359,8 +359,8 @@ default void getUniformdv(SegmentAllocator allocator, int program, int location, @Skip default double getUniformd(int program, int location) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.doubles(0D); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_DOUBLE); getUniformdv(program, location, seg); return seg.get(JAVA_DOUBLE, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL41C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL41C.java index 41482b31..61e03e0e 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL41C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL41C.java @@ -16,10 +16,10 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -110,7 +110,7 @@ default int createShaderProgramv(SegmentAllocator allocator, int type, String[] @Skip default int createShaderProgramv(int type, String string) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { return createShaderProgramv(type, 1, stack.allocateFrom(ADDRESS, Marshal.marshal(stack, string))); } } @@ -122,7 +122,7 @@ default void deleteProgramPipelines(int n, MemorySegment pipelines) { @Skip default void deleteProgramPipelines(int... pipelines) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { deleteProgramPipelines(pipelines.length, Marshal.marshal(stack, pipelines)); } } @@ -161,8 +161,8 @@ default void genProgramPipelines(SegmentAllocator allocator, @Ref int[] pipeline @Skip default int genProgramPipelines() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); genProgramPipelines(1, seg); return seg.get(JAVA_INT, 0); } @@ -180,8 +180,8 @@ default void getDoublei_v(SegmentAllocator allocator, int target, int index, @Re @Skip default double getDoublei_v(int target, int index) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.doubles(0D); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_DOUBLE); getDoublei_v(target, index, seg); return seg.get(JAVA_DOUBLE, 0); } @@ -199,8 +199,8 @@ default void getFloati_v(SegmentAllocator allocator, int target, int index, @Ref @Skip default float getFloati_v(int target, int index) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_FLOAT); getFloati_v(target, index, seg); return seg.get(JAVA_FLOAT, 0); } @@ -250,8 +250,8 @@ default void getProgramPipelineiv(int pipeline, int pname, MemorySegment params) @Skip default int getProgramPipelineiv(int pipeline, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getProgramPipelineiv(pipeline, pname, seg); return seg.get(JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL42C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL42C.java index 133a58f6..9e715014 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL42C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL42C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -232,8 +232,8 @@ default void getActiveAtomicCounterBufferiv(SegmentAllocator allocator, int prog @Skip default int getActiveAtomicCounterBufferiv(int program, int bufferIndex, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); getActiveAtomicCounterBufferiv(program, bufferIndex, pname, seg); return seg.get(ValueLayout.JAVA_INT, 0); } @@ -253,8 +253,8 @@ default void getInternalformativ(SegmentAllocator allocator, int target, int int @Skip default int getInternalformativ(int target, int internalFormat, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ValueLayout.JAVA_INT); getInternalformativ(target, internalFormat, pname, 1, seg); return seg.get(ValueLayout.JAVA_INT, 0); } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL43C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL43C.java index dbefc237..9359a5b6 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL43C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL43C.java @@ -16,10 +16,10 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -365,7 +365,7 @@ default void debugMessageInsert(int source, int type, int id, int severity, int @Skip default void debugMessageInsert(int source, int type, int id, int severity, String buf) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { debugMessageInsert(source, type, id, severity, -1, Marshal.marshal(stack, buf)); } } @@ -420,8 +420,8 @@ default void getFramebufferParameteriv(int target, int pname, MemorySegment para @Skip default int getFramebufferParameteriv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getFramebufferParameteriv(target, pname, seg); return seg.get(JAVA_INT, 0); } @@ -441,8 +441,8 @@ default void getInternalformati64v(SegmentAllocator allocator, int target, int i @Skip default long getInternalformati64v(int target, int internalFormat, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.longs(0L); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_LONG); getInternalformati64v(target, internalFormat, pname, 1, seg); return seg.get(JAVA_LONG, 0); } @@ -503,8 +503,8 @@ default void getProgramInterfaceiv(int program, int programInterface, int pname, @Skip default int getProgramInterfaceiv(int program, int programInterface, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getProgramInterfaceiv(program, programInterface, pname, seg); return seg.get(JAVA_INT, 0); } @@ -607,7 +607,7 @@ default void invalidateFramebuffer(int target, int numAttachments, MemorySegment @Skip default void invalidateFramebuffer(int target, int... attachments) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { invalidateFramebuffer(target, attachments.length, Marshal.marshal(stack, attachments)); } } @@ -624,8 +624,8 @@ default void invalidateSubFramebuffer(SegmentAllocator allocator, int target, in @Skip default void invalidateSubFramebuffer(int target, int attachment, int x, int y, int width, int height) { - try (MemoryStack stack = MemoryStack.stackPush()) { - invalidateSubFramebuffer(target, 1, stack.ints(attachment), x, y, width, height); + try (MemoryStack stack = MemoryStack.pushLocal()) { + invalidateSubFramebuffer(target, 1, stack.allocateFrom(JAVA_INT, attachment), x, y, width, height); } } @@ -666,7 +666,7 @@ default void objectLabel(int identifier, int name, int length, MemorySegment lab @Skip default void objectLabel(int identifier, int name, String label) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { objectLabel(identifier, name, -1, Marshal.marshal(stack, label)); } } @@ -678,7 +678,7 @@ default void objectPtrLabel(MemorySegment ptr, int length, MemorySegment label) @Skip default void objectPtrLabel(MemorySegment ptr, String label) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { objectPtrLabel(ptr, -1, Marshal.marshal(stack, label)); } } @@ -695,7 +695,7 @@ default void pushDebugGroup(int source, int id, int length, MemorySegment messag @Skip default void pushDebugGroup(int source, int id, String message) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { pushDebugGroup(source, id, -1, Marshal.marshal(stack, message)); } } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL45C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL45C.java index c61ee4d3..fed31739 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL45C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL45C.java @@ -16,9 +16,9 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.Unmarshal; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Ref; @@ -186,8 +186,8 @@ default void createBuffers(SegmentAllocator allocator, @Ref int[] buffers) { @Skip default int createBuffers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createBuffers(1, seg); return seg.get(JAVA_INT, 0); } @@ -207,8 +207,8 @@ default void createFramebuffers(SegmentAllocator allocator, @Ref int[] framebuff @Skip default int createFramebuffers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createFramebuffers(1, seg); return seg.get(JAVA_INT, 0); } @@ -228,8 +228,8 @@ default void createProgramPipelines(SegmentAllocator allocator, @Ref int[] pipel @Skip default int createProgramPipelines() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createProgramPipelines(1, seg); return seg.get(JAVA_INT, 0); } @@ -249,8 +249,8 @@ default void createQueries(SegmentAllocator allocator, int target, @Ref int[] id @Skip default int createQueries(int target) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createQueries(target, 1, seg); return seg.get(JAVA_INT, 0); } @@ -270,8 +270,8 @@ default void createRenderbuffers(SegmentAllocator allocator, @Ref int[] renderbu @Skip default int createRenderbuffers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createRenderbuffers(1, seg); return seg.get(JAVA_INT, 0); } @@ -291,8 +291,8 @@ default void createSamplers(SegmentAllocator allocator, @Ref int[] samplers) { @Skip default int createSamplers() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createSamplers(1, seg); return seg.get(JAVA_INT, 0); } @@ -312,8 +312,8 @@ default void createTextures(SegmentAllocator allocator, int target, @Ref int[] t @Skip default int createTextures(int target) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pTex = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pTex = stack.allocate(JAVA_INT); createTextures(target, 1, pTex); return pTex.get(JAVA_INT, 0); } @@ -333,8 +333,8 @@ default void createTransformFeedbacks(SegmentAllocator allocator, @Ref int[] ids @Skip default int createTransformFeedbacks() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createTransformFeedbacks(1, seg); return seg.get(JAVA_INT, 0); } @@ -354,8 +354,8 @@ default void createVertexArrays(SegmentAllocator allocator, @Ref int[] arrays) { @Skip default int createVertexArrays() { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); createVertexArrays(1, seg); return seg.get(JAVA_INT, 0); } @@ -403,8 +403,8 @@ default void getNamedBufferParameteri64v(int buffer, int pname, MemorySegment pa @Skip default long getNamedBufferParameteri64v(int buffer, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.longs(0L); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_LONG); getNamedBufferParameteri64v(buffer, pname, seg); return seg.get(JAVA_LONG, 0); } @@ -417,8 +417,8 @@ default void getNamedBufferParameteriv(int buffer, int pname, MemorySegment para @Skip default int getNamedBufferParameteriv(int buffer, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getNamedBufferParameteriv(buffer, pname, seg); return seg.get(JAVA_INT, 0); } @@ -431,8 +431,8 @@ default void getNamedBufferPointerv(int target, int pname, MemorySegment params) @Skip default MemorySegment getNamedBufferPointerv(int target, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.segments(MemorySegment.NULL); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(ADDRESS); getNamedBufferPointerv(target, pname, seg); return seg.get(ADDRESS, 0); } @@ -492,8 +492,8 @@ default void getNamedFramebufferAttachmentParameteriv(int framebuffer, int attac @Skip default int getNamedFramebufferAttachmentParameteriv(int framebuffer, int attachment, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getNamedFramebufferAttachmentParameteriv(framebuffer, attachment, pname, seg); return seg.get(JAVA_INT, 0); } @@ -506,8 +506,8 @@ default void getNamedFramebufferParameteriv(int framebuffer, int pname, MemorySe @Skip default int getNamedFramebufferParameteriv(int framebuffer, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getNamedFramebufferParameteriv(framebuffer, pname, seg); return seg.get(JAVA_INT, 0); } @@ -525,8 +525,8 @@ default void getNamedRenderbufferParameteriv(int renderbuffer, int pname, @Ref i @Skip default int getNamedRenderbufferParameteriv(int renderbuffer, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getNamedRenderbufferParameteriv(renderbuffer, pname, seg); return seg.get(JAVA_INT, 0); } @@ -569,8 +569,8 @@ default void getTextureLevelParameterfv(SegmentAllocator allocator, int texture, @Skip default float getTextureLevelParameterfv(int texture, int level, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_FLOAT); getTextureLevelParameterfv(texture, level, pname, pParams); return pParams.get(JAVA_FLOAT, 0); } @@ -588,8 +588,8 @@ default void getTextureLevelParameteriv(SegmentAllocator allocator, int texture, @Skip default int getTextureLevelParameteriv(int texture, int level, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_INT); getTextureLevelParameteriv(texture, level, pname, pParams); return pParams.get(JAVA_INT, 0); } @@ -607,8 +607,8 @@ default void getTextureParameterIiv(SegmentAllocator allocator, int texture, int @Skip default int getTextureParameterIiv(int texture, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getTextureParameterIiv(texture, pname, seg); return seg.get(JAVA_INT, 0); } @@ -626,8 +626,8 @@ default void getTextureParameterIuiv(SegmentAllocator allocator, int texture, in @Skip default int getTextureParameterIuiv(int texture, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getTextureParameterIuiv(texture, pname, seg); return seg.get(JAVA_INT, 0); } @@ -645,8 +645,8 @@ default void getTextureParameterfv(SegmentAllocator allocator, int texture, int @Skip default float getTextureParameterfv(int texture, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.floats(0F); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_FLOAT); getTextureParameterfv(texture, pname, pParams); return pParams.get(JAVA_FLOAT, 0); } @@ -664,8 +664,8 @@ default void getTextureParameteriv(SegmentAllocator allocator, int texture, int @Skip default int getTextureParameteriv(int texture, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var pParams = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var pParams = stack.allocate(JAVA_INT); getTextureParameteriv(texture, pname, pParams); return pParams.get(JAVA_INT, 0); } @@ -741,8 +741,8 @@ default void getVertexArrayIndexed64iv(int vaobj, int index, int pname, MemorySe @Skip default long getVertexArrayIndexed64iv(int vaobj, int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.longs(0L); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_LONG); getVertexArrayIndexed64iv(vaobj, index, pname, seg); return seg.get(JAVA_LONG, 0); } @@ -755,8 +755,8 @@ default void getVertexArrayIndexediv(int vaobj, int index, int pname, MemorySegm @Skip default int getVertexArrayIndexediv(int vaobj, int index, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getVertexArrayIndexediv(vaobj, index, pname, seg); return seg.get(JAVA_INT, 0); } @@ -769,8 +769,8 @@ default void getVertexArrayiv(int vaobj, int pname, MemorySegment param) { @Skip default int getVertexArrayiv(int vaobj, int pname) { - try (MemoryStack stack = MemoryStack.stackPush()) { - var seg = stack.ints(0); + try (MemoryStack stack = MemoryStack.pushLocal()) { + var seg = stack.allocate(JAVA_INT); getVertexArrayiv(vaobj, pname, seg); return seg.get(JAVA_INT, 0); } @@ -904,8 +904,8 @@ default void invalidateNamedFramebufferData(SegmentAllocator allocator, int fram @Skip default void invalidateNamedFramebufferData(int framebuffer, int attachment) { - try (MemoryStack stack = MemoryStack.stackPush()) { - invalidateNamedFramebufferData(framebuffer, 1, stack.ints(attachment)); + try (MemoryStack stack = MemoryStack.pushLocal()) { + invalidateNamedFramebufferData(framebuffer, 1, stack.allocateFrom(JAVA_INT, attachment)); } } @@ -921,8 +921,8 @@ default void invalidateNamedFramebufferSubData(SegmentAllocator allocator, int f @Skip default void invalidateNamedFramebufferSubData(int framebuffer, int attachment, int x, int y, int width, int height) { - try (MemoryStack stack = MemoryStack.stackPush()) { - invalidateNamedFramebufferSubData(framebuffer, 1, stack.ints(attachment), x, y, width, height); + try (MemoryStack stack = MemoryStack.pushLocal()) { + invalidateNamedFramebufferSubData(framebuffer, 1, stack.allocateFrom(JAVA_INT, attachment), x, y, width, height); } } diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL46C.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL46C.java index e17d06ab..c1a91001 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL46C.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GL46C.java @@ -16,10 +16,10 @@ package overrungl.opengl; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Marshal; -import overrun.marshal.MemoryStack; import overrun.marshal.gen.Entrypoint; import overrun.marshal.gen.Skip; import overrungl.opengl.ext.arb.GLARBGLSpirv; @@ -96,7 +96,7 @@ default void specializeShader(SegmentAllocator allocator, int shader, @Nullable @Skip default void specializeShader(int shader, @Nullable String pEntryPoint) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { specializeShader(shader, Marshal.marshal(stack, pEntryPoint), 0, diff --git a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GLFinder.java b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GLFinder.java index 4b079421..b131b215 100644 --- a/modules/overrungl.opengl/src/main/java/overrungl/opengl/GLFinder.java +++ b/modules/overrungl.opengl/src/main/java/overrungl/opengl/GLFinder.java @@ -16,7 +16,7 @@ package overrungl.opengl; -import overrun.marshal.MemoryStack; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.Unmarshal; import overrungl.util.value.Pair; @@ -109,7 +109,7 @@ static boolean getExtensions(GLLoadFunc load, // extension count int numExtsI; - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { final MemorySegment pNumExtsI = stack.allocate(ValueLayout.JAVA_INT); try { glGetIntegerv.invokeExact(GL.NUM_EXTENSIONS, pNumExtsI); diff --git a/modules/overrungl.stb/src/main/java/module-info.java b/modules/overrungl.stb/src/main/java/module-info.java index 15fb80f2..c0d5ad2a 100644 --- a/modules/overrungl.stb/src/main/java/module-info.java +++ b/modules/overrungl.stb/src/main/java/module-info.java @@ -25,4 +25,5 @@ requires transitive overrungl.core; requires static org.jetbrains.annotations; + requires io.github.overrun.memstack; } diff --git a/modules/overrungl.stb/src/main/java/overrungl/stb/STBImage.java b/modules/overrungl.stb/src/main/java/overrungl/stb/STBImage.java index 57a89b77..d06b73e5 100644 --- a/modules/overrungl.stb/src/main/java/overrungl/stb/STBImage.java +++ b/modules/overrungl.stb/src/main/java/overrungl/stb/STBImage.java @@ -16,10 +16,11 @@ package overrungl.stb; +import io.github.overrun.memstack.MemoryStack; import org.jetbrains.annotations.Nullable; import overrun.marshal.DirectAccess; import overrun.marshal.Downcall; -import overrun.marshal.MemoryStack; +import overrun.marshal.Marshal; import overrun.marshal.Unmarshal; import overrun.marshal.gen.*; @@ -274,12 +275,12 @@ default MemorySegment loadGifFromMemory(MemorySegment buffer, MemorySegment dela @Skip default MemorySegment loadGifFromMemory(SegmentAllocator allocator, byte[] buffer, @Ref int[][] delays, @Ref int[] x, @Ref int[] y, @Ref int[] z, @Ref int[] comp, int reqComp) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { var pd = stack.allocate(ValueLayout.ADDRESS); - var px = stack.ints(x); - var py = stack.ints(y); - var pz = stack.ints(z); - var pc = stack.ints(comp); + var px = Marshal.marshal(stack, x); + var py = Marshal.marshal(stack, y); + var pz = Marshal.marshal(stack, z); + var pc = Marshal.marshal(stack, comp); var addr = loadGifFromMemory(allocator.allocateFrom(ValueLayout.JAVA_BYTE, buffer), pd, px, py, pz, pc, reqComp); Unmarshal.copy(px, x); Unmarshal.copy(py, y); diff --git a/modules/overrungl.stb/src/main/java/overrungl/stb/STBTrueType.java b/modules/overrungl.stb/src/main/java/overrungl/stb/STBTrueType.java index e2a42f1f..c0382b73 100644 --- a/modules/overrungl.stb/src/main/java/overrungl/stb/STBTrueType.java +++ b/modules/overrungl.stb/src/main/java/overrungl/stb/STBTrueType.java @@ -150,7 +150,7 @@ *

SAMPLE PROGRAMS

* Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless. * {@snippet lang = java: - * import overrun.marshal.MemoryStack; + * import io.github.overrun.memstack.MemoryStack; * import java.lang.foreign.Arena; * import java.nio.channels.FileChannel; * import java.nio.file.Path; @@ -184,7 +184,7 @@ * gl.enable(GL.TEXTURE_2D); * gl.bindTexture(GL.TEXTURE_2D, ftex); * gl.begin(GL.QUADS); - * try (var stack = MemoryStack.stackPush()) { + * try (var stack = MemoryStack.pushLocal()) { * var q = STBTTAlignedQuad.OF.of(stack); * var px = stack.floats(x); * var py = stack.floats(y); @@ -205,7 +205,7 @@ *

* Complete program (this compiles): get a single bitmap, print as ASCII art * {@snippet lang = java: - * import overrun.marshal.MemoryStack; + * import io.github.overrun.memstack.MemoryStack; * import overrungl.stb.STBTTFontInfo; * import overrungl.stb.STBTrueType; * @@ -230,7 +230,7 @@ * stbtt.initFont(font, ttf_buffer, stbtt.getFontOffsetForIndex(ttf_buffer, 0)); * } * - * try (var stack = MemoryStack.stackPush()) { + * try (var stack = MemoryStack.pushLocal()) { * var pw = stack.ints(0); * var ph = stack.ints(0); * var bitmap = stbtt.getCodepointBitmap(font, 0, stbtt.scaleForPixelHeight(font, s), c, pw, ph, MemorySegment.NULL, MemorySegment.NULL); diff --git a/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilBenchmark.java b/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilBenchmark.java index 8c0174ba..7aa49826 100644 --- a/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilBenchmark.java +++ b/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilBenchmark.java @@ -16,13 +16,13 @@ package overrungl.demo.mem; +import io.github.overrun.memstack.MemoryStack; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.OptionsBuilder; -import overrun.marshal.MemoryStack; import overrungl.util.MemoryUtil; import java.lang.foreign.Arena; @@ -75,16 +75,9 @@ public void measureCalloc(Blackhole bh) { } } - @Benchmark - public void measureStackMalloc(Blackhole bh) { - try (MemoryStack stack = MemoryStack.stackPush()) { - bh.consume(stack.malloc(size, 1L)); - } - } - @Benchmark public void measureStackCalloc(Blackhole bh) { - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { bh.consume(stack.allocate(size)); } } diff --git a/modules/samples/src/main/java/overrungl/demo/nfd/NFDTest.java b/modules/samples/src/main/java/overrungl/demo/nfd/NFDTest.java index 35abef22..68ad62b3 100644 --- a/modules/samples/src/main/java/overrungl/demo/nfd/NFDTest.java +++ b/modules/samples/src/main/java/overrungl/demo/nfd/NFDTest.java @@ -16,7 +16,7 @@ package overrungl.demo.nfd; -import overrun.marshal.MemoryStack; +import io.github.overrun.memstack.MemoryStack; import overrungl.nfd.NFD; import overrungl.nfd.NFDEnumerator; import overrungl.nfd.NFDNFilterItem; @@ -39,7 +39,7 @@ private static void openDialog() { // or before/after every time you want to show a file dialog. nfd.init(); - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { String[] outPath = new String[1]; // prepare filters for the dialog @@ -68,8 +68,8 @@ private static void openDialogMultiple() { // or before/after every time you want to show a file dialog. nfd.init(); - try (MemoryStack stack = MemoryStack.stackPush()) { - MemorySegment pOutPaths = stack.segments(MemorySegment.NULL); + try (MemoryStack stack = MemoryStack.pushLocal()) { + MemorySegment pOutPaths = stack.allocate(ValueLayout.ADDRESS); String[] outPath = new String[1]; // prepare filters for the dialog @@ -109,8 +109,8 @@ private static void openDialogMultipleEnum() { // or before/after every time you want to show a file dialog. nfd.init(); - try (MemoryStack stack = MemoryStack.stackPush()) { - MemorySegment pOutPaths = stack.segments(MemorySegment.NULL); + try (MemoryStack stack = MemoryStack.pushLocal()) { + MemorySegment pOutPaths = stack.allocate(ValueLayout.ADDRESS); // prepare filters for the dialog final var filterItem = NFDNFilterItem.create(stack, @@ -173,7 +173,7 @@ private static void saveDialog() { // or before/after every time you want to show a file dialog. nfd.init(); - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { String[] savePath = new String[1]; // prepare filters for the dialog diff --git a/modules/samples/src/main/java/overrungl/demo/opengl/GL30Test.java b/modules/samples/src/main/java/overrungl/demo/opengl/GL30Test.java index fd09db64..35e69e75 100644 --- a/modules/samples/src/main/java/overrungl/demo/opengl/GL30Test.java +++ b/modules/samples/src/main/java/overrungl/demo/opengl/GL30Test.java @@ -16,7 +16,7 @@ package overrungl.demo.opengl; -import overrun.marshal.MemoryStack; +import io.github.overrun.memstack.MemoryStack; import overrun.marshal.Unmarshal; import overrungl.demo.util.IOUtil; import overrungl.glfw.GLFW; @@ -107,7 +107,7 @@ private void load(Arena arena) { gl.bindTexture(GL.TEXTURE_2D, tex); gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.NEAREST); gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.NEAREST); - try (MemoryStack stack = MemoryStack.stackPush()) { + try (MemoryStack stack = MemoryStack.pushLocal()) { final STBImage stbImage = STBImage.INSTANCE; var px = stack.allocate(JAVA_INT); var py = stack.allocate(JAVA_INT);