GpuFormat .java

com.mojang.renderpearl.api.GpuFormat (enum): members: R8_UNORM, R8_SNORM, RG8_UNORM, RG8_SNORM, RGB8_UNORM, RGB8_SNORM, RGBA8_UNORM, RGBA8_SNORM, R8_UINT.

com.mojang.renderpearl.apienum131 linesclient4.2 KB

API Surface (8)

int blockSize()
int byteAlignment()
GpuFormat.ComponentType componentType()
int componentCount()
boolean hasColorAspect()
boolean hasDepthAspect()
boolean hasStencilAspect()
int byteSize()

Fields & Constants (2)

componentType
componentCount

Same Package (1)

Full Source

GpuFormat.java131 lines · Minecraft 26.3 · verbatim
1
package com.mojang.renderpearl.api;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
6
@Environment(EnvType.CLIENT)
7
public enum GpuFormat {
8
	R8_UNORM(GpuFormat.ComponentType.UNORM_8, 1),
9
	R8_SNORM(GpuFormat.ComponentType.SNORM_8, 1),
10
	RG8_UNORM(GpuFormat.ComponentType.UNORM_8, 2),
11
	RG8_SNORM(GpuFormat.ComponentType.SNORM_8, 2),
12
	RGB8_UNORM(GpuFormat.ComponentType.UNORM_8, 3),
13
	RGB8_SNORM(GpuFormat.ComponentType.SNORM_8, 3),
14
	RGBA8_UNORM(GpuFormat.ComponentType.UNORM_8, 4),
15
	RGBA8_SNORM(GpuFormat.ComponentType.SNORM_8, 4),
16
	R16_UNORM(GpuFormat.ComponentType.UNORM_16, 1),
17
	R16_SNORM(GpuFormat.ComponentType.SNORM_16, 1),
18
	RG16_UNORM(GpuFormat.ComponentType.UNORM_16, 2),
19
	RG16_SNORM(GpuFormat.ComponentType.SNORM_16, 2),
20
	RGB16_UNORM(GpuFormat.ComponentType.UNORM_16, 3),
21
	RGB16_SNORM(GpuFormat.ComponentType.SNORM_16, 3),
22
	RGBA16_UNORM(GpuFormat.ComponentType.UNORM_16, 4),
23
	RGBA16_SNORM(GpuFormat.ComponentType.SNORM_16, 4),
24
	R8_UINT(GpuFormat.ComponentType.UINT_8, 1),
25
	R8_SINT(GpuFormat.ComponentType.SINT_8, 1),
26
	RG8_UINT(GpuFormat.ComponentType.UINT_8, 2),
27
	RG8_SINT(GpuFormat.ComponentType.SINT_8, 2),
28
	RGB8_UINT(GpuFormat.ComponentType.UINT_8, 3),
29
	RGB8_SINT(GpuFormat.ComponentType.SINT_8, 3),
30
	RGBA8_UINT(GpuFormat.ComponentType.UINT_8, 4),
31
	RGBA8_SINT(GpuFormat.ComponentType.SINT_8, 4),
32
	R16_UINT(GpuFormat.ComponentType.UINT_16, 1),
33
	R16_SINT(GpuFormat.ComponentType.SINT_16, 1),
34
	RG16_UINT(GpuFormat.ComponentType.UINT_16, 2),
35
	RG16_SINT(GpuFormat.ComponentType.SINT_16, 2),
36
	RGB16_UINT(GpuFormat.ComponentType.UINT_16, 3),
37
	RGB16_SINT(GpuFormat.ComponentType.SINT_16, 3),
38
	RGBA16_UINT(GpuFormat.ComponentType.UINT_16, 4),
39
	RGBA16_SINT(GpuFormat.ComponentType.SINT_16, 4),
40
	R32_UINT(GpuFormat.ComponentType.UINT_32, 1),
41
	R32_SINT(GpuFormat.ComponentType.SINT_32, 1),
42
	RG32_UINT(GpuFormat.ComponentType.UINT_32, 2),
43
	RG32_SINT(GpuFormat.ComponentType.SINT_32, 2),
44
	RGB32_UINT(GpuFormat.ComponentType.UINT_32, 3),
45
	RGB32_SINT(GpuFormat.ComponentType.SINT_32, 3),
46
	RGBA32_UINT(GpuFormat.ComponentType.UINT_32, 4),
47
	RGBA32_SINT(GpuFormat.ComponentType.SINT_32, 4),
48
	R16_FLOAT(GpuFormat.ComponentType.FLOAT_16, 1),
49
	RG16_FLOAT(GpuFormat.ComponentType.FLOAT_16, 2),
50
	RGB16_FLOAT(GpuFormat.ComponentType.FLOAT_16, 3),
51
	RGBA16_FLOAT(GpuFormat.ComponentType.FLOAT_16, 4),
52
	R32_FLOAT(GpuFormat.ComponentType.FLOAT_32, 1),
53
	RG32_FLOAT(GpuFormat.ComponentType.FLOAT_32, 2),
54
	RGB32_FLOAT(GpuFormat.ComponentType.FLOAT_32, 3),
55
	RGBA32_FLOAT(GpuFormat.ComponentType.FLOAT_32, 4),
56
	RGB10A2_UNORM(GpuFormat.ComponentType.OPAQUE_32, 1),
57
	RGB10A2_UINT(GpuFormat.ComponentType.OPAQUE_32, 1),
58
	RG11B10_FLOAT(GpuFormat.ComponentType.OPAQUE_32, 1),
59
	D32_FLOAT(GpuFormat.ComponentType.OPAQUE_32, 1),
60
	D32_FLOAT_S8_UINT(GpuFormat.ComponentType.OPAQUE_64, 1),
61
	D24_UNORM_S8_UINT(GpuFormat.ComponentType.OPAQUE_32, 1),
62
	D16_UNORM(GpuFormat.ComponentType.OPAQUE_16, 1),
63
	S8_UINT(GpuFormat.ComponentType.OPAQUE_8, 1);
64
65
	private final GpuFormat.ComponentType componentType;
66
	private final int componentCount;
67
68
	GpuFormat(final GpuFormat.ComponentType componentType, final int componentCount) {
69
		this.componentType = componentType;
70
		this.componentCount = componentCount;
71
	}
72
73
	public int blockSize() {
74
		return this.componentType.byteSize() * this.componentCount;
75
	}
76
77
	public int byteAlignment() {
78
		return this.componentType.byteSize();
79
	}
80
81
	public GpuFormat.ComponentType componentType() {
82
		return this.componentType;
83
	}
84
85
	public int componentCount() {
86
		return this.componentCount;
87
	}
88
89
	public boolean hasColorAspect() {
90
		return !this.hasDepthAspect() && !this.hasStencilAspect();
91
	}
92
93
	public boolean hasDepthAspect() {
94
		return this == D32_FLOAT || this == D32_FLOAT_S8_UINT || this == D24_UNORM_S8_UINT || this == D16_UNORM;
95
	}
96
97
	public boolean hasStencilAspect() {
98
		return this == S8_UINT || this == D32_FLOAT_S8_UINT || this == D24_UNORM_S8_UINT;
99
	}
100
101
	@Environment(EnvType.CLIENT)
102
	public enum ComponentType {
103
		UNORM_8(1),
104
		SNORM_8(1),
105
		UINT_8(1),
106
		SINT_8(1),
107
		UNORM_16(2),
108
		SNORM_16(2),
109
		UINT_16(2),
110
		SINT_16(2),
111
		FLOAT_16(2),
112
		UINT_32(4),
113
		SINT_32(4),
114
		FLOAT_32(4),
115
		OPAQUE_8(1),
116
		OPAQUE_16(2),
117
		OPAQUE_32(4),
118
		OPAQUE_64(8);
119
120
		private final int byteSize;
121
122
		ComponentType(final int byteSize) {
123
			this.byteSize = byteSize;
124
		}
125
126
		public int byteSize() {
127
			return this.byteSize;
128
		}
129
	}
130
}
131

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