BindGroupLayout .java

com.mojang.renderpearl.api.pipeline.BindGroupLayout (record): members: uniforms, UniformDescription, ensureCompatible, flattenUniforms, builder, Builder.

com.mojang.renderpearl.api.pipelinerecord90 linesclient2.8 KB

API Surface (8)

record BindGroupLayout(List<BindGroupLayout.UniformDescription> uniforms)
BindGroupLayout.Builder builder()
List<BindGroupLayout.UniformDescription> flattenUniforms(final List<BindGroupLayout> bindGroupLayouts)
void ensureCompatible(final List<BindGroupLayout> bindGroupLayouts)
BindGroupLayout.Builder withUniform(final String name, final UniformType type)
BindGroupLayout.Builder withUniform(final String name, final UniformType type, final GpuFormat format)
BindGroupLayout build()
record UniformDescription(String name, UniformType type, @Nullable GpuFormat gpuFormat)

String literals (4)

"Duplicate bind name '"
"' in bind group layout "
"Only texel buffer can specify texture format"
"Texel buffer needs a texture format"

Code Graph: Dependencies (2)

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

Full Source

BindGroupLayout.java90 lines · Minecraft 26.3 · verbatim
1
package com.mojang.renderpearl.api.pipeline;
2
3
import com.mojang.renderpearl.api.GpuFormat;
4
import java.util.ArrayList;
5
import java.util.HashSet;
6
import java.util.List;
7
import java.util.Set;
8
import net.fabricmc.api.EnvType;
9
import net.fabricmc.api.Environment;
10
import org.jspecify.annotations.Nullable;
11
12
@Environment(EnvType.CLIENT)
13
public record BindGroupLayout(List<BindGroupLayout.UniformDescription> uniforms) {
14
	public BindGroupLayout {
15
		uniforms = List.copyOf(uniforms);
16
	}
17
18
	public static BindGroupLayout.Builder builder() {
19
		return new BindGroupLayout.Builder();
20
	}
21
22
	public static List<BindGroupLayout.UniformDescription> flattenUniforms(final List<BindGroupLayout> bindGroupLayouts) {
23
		List<BindGroupLayout.UniformDescription> flattened = new ArrayList<>();
24
25
		for (BindGroupLayout bindGroupLayout : bindGroupLayouts) {
26
			flattened.addAll(bindGroupLayout.uniforms());
27
		}
28
29
		return flattened;
30
	}
31
32
	public static void ensureCompatible(final List<BindGroupLayout> bindGroupLayouts) {
33
		Set<String> names = new HashSet<>();
34
35
		for (int layoutIndex = 0; layoutIndex < bindGroupLayouts.size(); layoutIndex++) {
36
			BindGroupLayout bindGroupLayout = bindGroupLayouts.get(layoutIndex);
37
38
			for (BindGroupLayout.UniformDescription uniform : bindGroupLayout.uniforms()) {
39
				if (!names.add(uniform.name())) {
40
					throw new IllegalArgumentException("Duplicate bind name '" + uniform.name() + "' in bind group layout " + layoutIndex);
41
				}
42
			}
43
		}
44
	}
45
46
	@Environment(EnvType.CLIENT)
47
	public static class Builder {
48
		private final List<BindGroupLayout.UniformDescription> uniforms = new ArrayList<>();
49
50
		private Builder() {
51
		}
52
53
		public BindGroupLayout.Builder withUniform(final String name, final UniformType type) {
54
			if (type == UniformType.TEXEL_BUFFER) {
55
				throw new IllegalArgumentException("Cannot use texel buffer without specifying texture format");
56
			}
57
58
			this.uniforms.add(new BindGroupLayout.UniformDescription(name, type));
59
			return this;
60
		}
61
62
		public BindGroupLayout.Builder withUniform(final String name, final UniformType type, final GpuFormat format) {
63
			if (type != UniformType.TEXEL_BUFFER) {
64
				throw new IllegalArgumentException("Only texel buffer can specify texture format");
65
			}
66
67
			this.uniforms.add(new BindGroupLayout.UniformDescription(name, format));
68
			return this;
69
		}
70
71
		public BindGroupLayout build() {
72
			return new BindGroupLayout(this.uniforms);
73
		}
74
	}
75
76
	@Environment(EnvType.CLIENT)
77
	public record UniformDescription(String name, UniformType type, @Nullable GpuFormat gpuFormat) {
78
		public UniformDescription(final String name, final UniformType type) {
79
			this(name, type, null);
80
			if (type == UniformType.TEXEL_BUFFER) {
81
				throw new IllegalArgumentException("Texel buffer needs a texture format");
82
			}
83
		}
84
85
		public UniformDescription(final String name, final GpuFormat gpuFormat) {
86
			this(name, UniformType.TEXEL_BUFFER, gpuFormat);
87
		}
88
	}
89
}
90

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