Backport MemoryStack to reduce direct buffer allocations (#751)

* Initial MemoryStack backport

* Remove stubs, for now

Will re-add as needed

* Implement mallocInt

* Replace some buffer allocation

* Add mallocFloat

* Replace more uses of direct buffer allocation

* Reorder methods

Fixes a clinit crash and makes it easier to compare to upstream

* Remove another direct buffer creation
This commit is contained in:
ah-OOG-ah authored and GitHub committed 2024-11-25 16:26:07 -05:00
1 parent 78072236d2
commit c353c83cf3
13 files changed
+808 -97

No files matched your search

@@ -1,5 +1,6 @@
package net.coderbot.iris.rendertarget;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import lombok.Getter;
@@ -40,11 +41,13 @@ public class RenderTarget {
this.width = builder.width;
this.height = builder.height;
IntBuffer textures = BufferUtils.createIntBuffer(2);
GL11.glGenTextures(textures);
try (MemoryStack stack = MemoryStack.stackPush()) {
IntBuffer textures = stack.mallocInt(2);
GL11.glGenTextures(textures);
this.mainTexture = textures.get(0);
this.altTexture = textures.get(1);
this.mainTexture = textures.get(0);
this.altTexture = textures.get(1);
}
boolean isPixelFormatInteger = builder.internalFormat.getPixelFormat().isInteger();
setupTexture(mainTexture, builder.width, builder.height, !isPixelFormatInteger);