GpuSurface .java

com.mojang.renderpearl.api.device.GpuSurface (interface, 56 lines): members: Configuration, PresentMode, isAcquired, currentConfiguration, blitFromTexture.

com.mojang.renderpearl.api.deviceinterface56 linesclientextends UncheckedAutoCloseable1.7 KB

API Surface (1)

GpuSurface.PresentMode getSupportedVsyncMode(final Collection<GpuSurface.PresentMode> supportedModes, final boolean vsync)

String literals (1)

"No supported presentation mode was found"

Code Graph: Dependencies (3)

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

Full Source

GpuSurface.java56 lines · Minecraft 26.3 · verbatim
1
package com.mojang.renderpearl.api.device;
2
3
import com.mojang.renderpearl.api.commands.CommandEncoder;
4
import com.mojang.renderpearl.api.textures.GpuTextureView;
5
import com.mojang.renderpearl.util.UncheckedAutoCloseable;
6
import java.util.Collection;
7
import java.util.Optional;
8
import net.fabricmc.api.EnvType;
9
import net.fabricmc.api.Environment;
10
11
@Environment(EnvType.CLIENT)
12
public interface GpuSurface extends UncheckedAutoCloseable {
13
	void configure(GpuSurface.Configuration config) throws SurfaceException;
14
15
	Optional<GpuSurface.Configuration> currentConfiguration();
16
17
	Collection<GpuSurface.PresentMode> supportedPresentModes();
18
19
	boolean isSuboptimal();
20
21
	boolean isAcquired();
22
23
	void acquireNextTexture() throws SurfaceException;
24
25
	void blitFromTexture(CommandEncoder commandEncoder, GpuTextureView textureView);
26
27
	void present();
28
29
	@Environment(EnvType.CLIENT)
30
	record Configuration(int width, int height, GpuSurface.PresentMode presentMode) {
31
	}
32
33
	@Environment(EnvType.CLIENT)
34
	enum PresentMode {
35
		IMMEDIATE,
36
		MAILBOX,
37
		FIFO,
38
		FIFO_RELAXED;
39
40
		private static final GpuSurface.PresentMode[] PRESENT_MODES_VSYNC = new GpuSurface.PresentMode[]{FIFO};
41
		private static final GpuSurface.PresentMode[] PRESENT_MODES_NO_VSYNC = new GpuSurface.PresentMode[]{IMMEDIATE, MAILBOX, FIFO};
42
43
		public static GpuSurface.PresentMode getSupportedVsyncMode(final Collection<GpuSurface.PresentMode> supportedModes, final boolean vsync) {
44
			GpuSurface.PresentMode[] preferred = vsync ? PRESENT_MODES_VSYNC : PRESENT_MODES_NO_VSYNC;
45
46
			for (GpuSurface.PresentMode mode : preferred) {
47
				if (supportedModes.contains(mode)) {
48
					return mode;
49
				}
50
			}
51
52
			throw new IllegalStateException("No supported presentation mode was found");
53
		}
54
	}
55
}
56

Decompiled Minecraft 26.3 source of GpuSurface (com/mojang/renderpearl/api/device/GpuSurface.java) with Mojang official mappings, stored verbatim on the site.