MappableRingBuffer.java
net.minecraft.client.renderer.MappableRingBuffer
信息
- 全限定名:net.minecraft.client.renderer.MappableRingBuffer
- 类型:public class
- 包:net.minecraft.client.renderer
- 源码路径:src/main/java/net/minecraft/client/renderer/MappableRingBuffer.java
- 起始行号:L13
- 实现:AutoCloseable
- 职责:
TODO
字段/常量
-
BUFFER_COUNT- 类型:
int - 修饰符:
private static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
buffers- 类型:
GpuBuffer[] - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
fences- 类型:
GpuFence[] - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
size- 类型:
int - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
current- 类型:
int - 修饰符:
private - 源码定位:
L18 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public MappableRingBuffer(Supplier<String> label, int usage, int size) @ L20
- 构造器名:MappableRingBuffer
- 源码定位:L20
- 修饰符:public
参数:
- label: Supplier
- usage: int
- size: int
说明:
TODO
方法
下面的方法块按源码顺序生成。
public int size() @ L35
- 方法名:size
- 源码定位:L35
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public GpuBuffer currentBuffer() @ L39
- 方法名:currentBuffer
- 源码定位:L39
- 返回类型:GpuBuffer
- 修饰符:public
参数:
- 无
说明:
TODO
public void rotate() @ L50
- 方法名:rotate
- 源码定位:L50
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void close() @ L59
- 方法名:close
- 源码定位:L59
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class MappableRingBuffer implements AutoCloseable {
private static final int BUFFER_COUNT = 3;
private final GpuBuffer[] buffers = new GpuBuffer[3];
private final @Nullable GpuFence[] fences = new GpuFence[3];
private final int size;
private int current = 0;
public MappableRingBuffer(Supplier<String> label, @GpuBuffer.Usage int usage, int size) {
GpuDevice device = RenderSystem.getDevice();
if ((usage & 1) == 0 && (usage & 2) == 0) {
throw new IllegalArgumentException("MappableRingBuffer requires at least one of USAGE_MAP_READ or USAGE_MAP_WRITE");
} else {
for (int i = 0; i < 3; i++) {
int finalI = i;
this.buffers[i] = device.createBuffer(() -> label.get() + " #" + finalI, usage, size);
this.fences[i] = null;
}
this.size = size;
}
}
public int size() {
return this.size;
}
public GpuBuffer currentBuffer() {
GpuFence fence = this.fences[this.current];
if (fence != null) {
fence.awaitCompletion(Long.MAX_VALUE);
fence.close();
this.fences[this.current] = null;
}
return this.buffers[this.current];
}
public void rotate() {
if (this.fences[this.current] != null) {
this.fences[this.current].close();
}
this.fences[this.current] = RenderSystem.getDevice().createCommandEncoder().createFence();
this.current = (this.current + 1) % 3;
}
@Override
public void close() {
for (int i = 0; i < 3; i++) {
this.buffers[i].close();
if (this.fences[i] != null) {
this.fences[i].close();
}
}
}
}引用的其他类
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderSystem.getDevice()
- 引用位置: