Skip to content

Commit cbf15e6

Browse files
committed
ai, mac
1 parent a3b4f19 commit cbf15e6

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod_name=MadParticle
3535
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3636
mod_license=GNU GPL 3.0
3737
# The mod version. See https://semver.org/
38-
mod_version=26.1.2-0
38+
mod_version=26.1.2-1
3939
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
4040
# This should match the base package used for the mod sources.
4141
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

src/main/java/cn/ussshenzhou/madparticle/particle/render/PersistentMappedArrayBuffer.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package cn.ussshenzhou.madparticle.particle.render;
22

3+
import com.mojang.blaze3d.buffers.GpuBuffer;
4+
import com.mojang.blaze3d.opengl.GlBuffer;
5+
import com.mojang.blaze3d.systems.RenderSystem;
36
import org.lwjgl.system.MemoryUtil;
47

58
import java.nio.ByteBuffer;
@@ -60,30 +63,25 @@ public void next() {
6063
}
6164

6265
public static class PersistentMappedBuffer {
63-
private ByteBuffer mappedBuffer;
64-
private final int id;
66+
private final GpuBuffer gpuBuffer;
67+
private final GpuBuffer.MappedView mappedBuffer;
6568

6669
public PersistentMappedBuffer(int byteSize) {
67-
this.id = glGenBuffers();
68-
glBindBuffer(GL_ARRAY_BUFFER, id);
69-
int flag = GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT;
70-
glBufferStorage(GL_ARRAY_BUFFER, byteSize, flag);
71-
mappedBuffer = glMapBufferRange(GL_ARRAY_BUFFER, 0, byteSize, flag);
72-
glBindBuffer(GL_ARRAY_BUFFER, 0);
70+
gpuBuffer = RenderSystem.getDevice().createBuffer(() -> "MadParticle VBO", GpuBuffer.USAGE_MAP_WRITE, byteSize);
71+
mappedBuffer = RenderSystem.getDevice().createCommandEncoder().mapBuffer(gpuBuffer, false, true);
7372
}
7473

7574
public long getAddress() {
76-
return MemoryUtil.memAddress(mappedBuffer);
75+
return MemoryUtil.memAddress(mappedBuffer.data());
7776
}
7877

7978
public void free() {
80-
glUnmapNamedBuffer(id);
81-
glDeleteBuffers(id);
82-
mappedBuffer = null;
79+
mappedBuffer.close();
80+
gpuBuffer.close();
8381
}
8482

8583
public void bind() {
86-
glBindBuffer(GL_ARRAY_BUFFER, id);
84+
glBindBuffer(GL_ARRAY_BUFFER, ((GlBuffer) (gpuBuffer)).handle);
8785
}
8886

8987
}

0 commit comments

Comments
 (0)