API Surface (4) record GpuBufferSlice(GpuBuffer buffer, long offset, long length)
GpuBufferSlice slice(final long offset, final long length)
GpuBufferSlice.MappedView map(final boolean read, final boolean write)
void close()
String literals (2) "Offset of "
" and length "
Code Graph: Dependencies (2) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
GpuBufferSlice.java 32 lines · Minecraft 26.3 · verbatim Copy
1 package com.mojang.renderpearl.api.buffers;
2
3 import com.mojang.renderpearl.util.UncheckedAutoCloseable;
4 import java.nio.ByteBuffer;
5 import net.fabricmc.api.EnvType;
6 import net.fabricmc.api.Environment;
7
8 @Environment(EnvType.CLIENT)
9 public record GpuBufferSlice(GpuBuffer buffer, long offset, long length) {
10 public GpuBufferSlice slice(final long offset, final long length) {
11 if (offset >= 0L && length >= 0L && offset + length <= this.length) {
12 return new GpuBufferSlice(this.buffer, this.offset + offset, length);
13 } else {
14 throw new IllegalArgumentException(
15 "Offset of " + offset + " and length " + length + " would put new slice outside existing slice's range (of " + this.offset + "," + this.length + ")"
16 );
17 }
18 }
19
20 public GpuBufferSlice.MappedView map(final boolean read, final boolean write) {
21 return this.buffer.map(this.offset, this.length, read, write);
22 }
23
24 @Environment(EnvType.CLIENT)
25 public record MappedView(GpuBufferSlice slice, ByteBuffer data, Runnable onClose) implements UncheckedAutoCloseable {
26 @Override
27 public void close() {
28 this.onClose.run();
29 }
30 }
31 }
32
Decompiled Minecraft 26.3 source of GpuBufferSlice (com/mojang/renderpearl/api/buffers/GpuBufferSlice.java) with Mojang official mappings, stored verbatim on the site.