GlBuffer.java

com.mojang.blaze3d.opengl.GlBuffer

信息

  • 全限定名:com.mojang.blaze3d.opengl.GlBuffer
  • 类型:public class
  • 包:com.mojang.blaze3d.opengl
  • 源码路径:src/main/java/com/mojang/blaze3d/opengl/GlBuffer.java
  • 起始行号:L13
  • 继承:GpuBuffer
  • 职责:

    TODO

字段/常量

  • MEMORY_POOl

    • 类型: MemoryPool
    • 修饰符: protected static final
    • 源码定位: L14
    • 说明:

      TODO

  • closed

    • 类型: boolean
    • 修饰符: protected
    • 源码定位: L15
    • 说明:

      TODO

  • label

    • 类型: Supplier<String>
    • 修饰符: protected final
    • 源码定位: L16
    • 说明:

      TODO

  • dsa

    • 类型: DirectStateAccess
    • 修饰符: private final
    • 源码定位: L17
    • 说明:

      TODO

  • handle

    • 类型: int
    • 修饰符: protected final
    • 源码定位: L18
    • 说明:

      TODO

  • persistentBuffer

    • 类型: ByteBuffer
    • 修饰符: protected
    • 源码定位: L19
    • 说明:

      TODO

内部类/嵌套类型

  • com.mojang.blaze3d.opengl.GlBuffer.GlMappedView
    • 类型: class
    • 修饰符: public static
    • 源码定位: L53
    • 说明:

      TODO

构造器

protected GlBuffer(Supplier<String> label, DirectStateAccess dsa, int usage, long size, int handle, ByteBuffer persistentBuffer) @ L21

  • 构造器名:GlBuffer
  • 源码定位:L21
  • 修饰符:protected

参数:

  • label: Supplier
  • dsa: DirectStateAccess
  • usage: int
  • size: long
  • handle: int
  • persistentBuffer: ByteBuffer

说明:

TODO

方法

下面的方法块按源码顺序生成。

public boolean isClosed() @ L33

  • 方法名:isClosed
  • 源码定位:L33
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public void close() @ L38

  • 方法名:close
  • 源码定位:L38
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class GlBuffer extends GpuBuffer {
    protected static final MemoryPool MEMORY_POOl = TracyClient.createMemoryPool("GPU Buffers");
    protected boolean closed;
    protected final @Nullable Supplier<String> label;
    private final DirectStateAccess dsa;
    protected final int handle;
    protected @Nullable ByteBuffer persistentBuffer;
 
    protected GlBuffer(
        @Nullable Supplier<String> label, DirectStateAccess dsa, @GpuBuffer.Usage int usage, long size, int handle, @Nullable ByteBuffer persistentBuffer
    ) {
        super(usage, size);
        this.label = label;
        this.dsa = dsa;
        this.handle = handle;
        this.persistentBuffer = persistentBuffer;
        int clampedSize = (int)Math.min(size, 2147483647L);
        MEMORY_POOl.malloc(handle, clampedSize);
    }
 
    @Override
    public boolean isClosed() {
        return this.closed;
    }
 
    @Override
    public void close() {
        if (!this.closed) {
            this.closed = true;
            if (this.persistentBuffer != null) {
                this.dsa.unmapBuffer(this.handle, this.usage());
                this.persistentBuffer = null;
            }
 
            GlStateManager._glDeleteBuffers(this.handle);
            MEMORY_POOl.free(this.handle);
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class GlMappedView implements GpuBuffer.MappedView {
        private final Runnable unmap;
        private final GlBuffer buffer;
        private final ByteBuffer data;
        private boolean closed;
 
        protected GlMappedView(Runnable unmap, GlBuffer buffer, ByteBuffer data) {
            this.unmap = unmap;
            this.buffer = buffer;
            this.data = data;
        }
 
        @Override
        public ByteBuffer data() {
            return this.data;
        }
 
        @Override
        public void close() {
            if (!this.closed) {
                this.closed = true;
                this.unmap.run();
            }
        }
    }
}

引用的其他类