AbstractCheckpointStorage .java

com.mojang.renderpearl.backend.vulkan.checkpoints.AbstractCheckpointStorage (class, 66 lines): members: checkpointsByFrame, maxFramesInFlight, Checkpoint.

com.mojang.renderpearl.backend.vulkan.checkpointsclass66 linesclient2.2 KB

Implements

API Surface (3)

void rotate()
void recordCheckpoint(final VkCommandBuffer commandBuffer, final CheckpointExtension.CheckpointType type, final Supplier<String> label)
record Checkpoint(int id, String label, CheckpointExtension.CheckpointType type)

Fields & Constants (5)

queue
maxFramesInFlight
frame
checkpointsByFrame
nextCheckpointId

Code Graph: Dependencies (2)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

AbstractCheckpointStorage.java66 lines · Minecraft 26.3 · verbatim
1
package com.mojang.renderpearl.backend.vulkan.checkpoints;
2
3
import com.mojang.renderpearl.backend.vulkan.VulkanQueue;
4
import java.util.ArrayList;
5
import java.util.List;
6
import java.util.function.Supplier;
7
import net.fabricmc.api.EnvType;
8
import net.fabricmc.api.Environment;
9
import org.jspecify.annotations.Nullable;
10
import org.lwjgl.vulkan.VkCommandBuffer;
11
import org.lwjgl.vulkan.VkQueue;
12
13
@Environment(EnvType.CLIENT)
14
abstract class AbstractCheckpointStorage implements CheckpointExtension.CheckpointStorage {
15
	protected final VkQueue queue;
16
	private final int maxFramesInFlight;
17
	private int frame;
18
	private final AbstractCheckpointStorage.Frame[] checkpointsByFrame;
19
	private int nextCheckpointId;
20
21
	protected AbstractCheckpointStorage(final VulkanQueue queue, final int maxFramesInFlight) {
22
		this.queue = queue.vkQueue();
23
		this.maxFramesInFlight = maxFramesInFlight;
24
		this.checkpointsByFrame = new AbstractCheckpointStorage.Frame[maxFramesInFlight];
25
26
		for (int i = 0; i < maxFramesInFlight; i++) {
27
			this.checkpointsByFrame[i] = new AbstractCheckpointStorage.Frame(new ArrayList<>());
28
		}
29
	}
30
31
	@Override
32
	public void rotate() {
33
		this.frame = (this.frame + 1) % this.maxFramesInFlight;
34
		this.checkpointsByFrame[this.frame].checkpoints.clear();
35
	}
36
37
	@Override
38
	public void recordCheckpoint(final VkCommandBuffer commandBuffer, final CheckpointExtension.CheckpointType type, final Supplier<String> label) {
39
		int id = this.nextCheckpointId++;
40
		this.checkpointsByFrame[this.frame].checkpoints.add(new AbstractCheckpointStorage.Checkpoint(id, label.get(), type));
41
		this.recordCheckpoint(commandBuffer, id);
42
	}
43
44
	protected abstract void recordCheckpoint(VkCommandBuffer commandBuffer, int id);
45
46
	protected AbstractCheckpointStorage.@Nullable Checkpoint findCheckpoint(final int id) {
47
		for (AbstractCheckpointStorage.Frame frame : this.checkpointsByFrame) {
48
			for (AbstractCheckpointStorage.Checkpoint checkpoint : frame.checkpoints) {
49
				if (checkpoint.id() == id) {
50
					return checkpoint;
51
				}
52
			}
53
		}
54
55
		return null;
56
	}
57
58
	@Environment(EnvType.CLIENT)
59
	protected record Checkpoint(int id, String label, CheckpointExtension.CheckpointType type) {
60
	}
61
62
	@Environment(EnvType.CLIENT)
63
	private record Frame(List<AbstractCheckpointStorage.Checkpoint> checkpoints) {
64
	}
65
}
66

Decompiled Minecraft 26.3 source of AbstractCheckpointStorage (com/mojang/renderpearl/backend/vulkan/checkpoints/AbstractCheckpointStorage.java) with Mojang official mappings, stored verbatim on the site.