GlQueryPool .java

com.mojang.renderpearl.backend.opengl.GlQueryPool (class): members: handles, getValues, writeTimestamp, closed, getValue, size, close. imports: GL33C.

com.mojang.renderpearl.backend.openglclass59 linesclient1.5 KB

Implements

API Surface (5)

int size()
OptionalLong getValue(final int index)
OptionalLong[] getValues(final int index, final int count)
void writeTimestamp(final int index)
void close()

Fields & Constants (2)

handles
closed

String literals (2)

" starting at "
", when total size is "

Code Graph: Dependencies (1)

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

Full Source

GlQueryPool.java59 lines · Minecraft 26.3 · verbatim
1
package com.mojang.renderpearl.backend.opengl;
2
3
import com.mojang.renderpearl.api.commands.GpuQueryPool;
4
import java.util.OptionalLong;
5
import net.fabricmc.api.EnvType;
6
import net.fabricmc.api.Environment;
7
import org.lwjgl.opengl.GL33C;
8
9
@Environment(EnvType.CLIENT)
10
public class GlQueryPool implements GpuQueryPool {
11
	private final int[] handles;
12
	private boolean closed;
13
14
	public GlQueryPool(final int size) {
15
		this.handles = new int[size];
16
		GL33C.glGenQueries(this.handles);
17
	}
18
19
	@Override
20
	public int size() {
21
		return this.handles.length;
22
	}
23
24
	@Override
25
	public OptionalLong getValue(final int index) {
26
		int handle = this.handles[index];
27
		return GL33C.glGetQueryObjecti(handle, 34919) == 0 ? OptionalLong.empty() : OptionalLong.of(GL33C.glGetQueryObjectui64(handle, 34918));
28
	}
29
30
	@Override
31
	public OptionalLong[] getValues(final int index, final int count) {
32
		if (index + count > this.handles.length) {
33
			throw new IndexOutOfBoundsException(
34
				"getValues would read out-of-bounds for an array of " + count + " starting at " + index + ", when total size is " + this.handles.length
35
			);
36
		}
37
38
		OptionalLong[] result = new OptionalLong[count];
39
40
		for (int i = 0; i < count; i++) {
41
			result[i] = this.getValue(index + i);
42
		}
43
44
		return result;
45
	}
46
47
	protected void writeTimestamp(final int index) {
48
		GL33C.glQueryCounter(this.handles[index], 36392);
49
	}
50
51
	@Override
52
	public void close() {
53
		if (!this.closed) {
54
			this.closed = true;
55
			GL33C.glDeleteQueries(this.handles);
56
		}
57
	}
58
}
59

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