This commit is contained in:
Sergey 2025-09-18 12:46:36 +00:00
commit 2033d36e57
1254 changed files with 2497 additions and 2453 deletions

View file

@ -0,0 +1,77 @@
package com.mojang.blaze3d;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.systems.GpuDevice;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Locale;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
public class GraphicsWorkarounds {
private static final List<String> INTEL_GEN11_CORE = List.of(
"i3-1000g1",
"i3-1000g4",
"i3-1000ng4",
"i3-1005g1",
"i3-l13g4",
"i5-1030g4",
"i5-1030g7",
"i5-1030ng7",
"i5-1034g1",
"i5-1035g1",
"i5-1035g4",
"i5-1035g7",
"i5-1038ng7",
"i5-l16g7",
"i7-1060g7",
"i7-1060ng7",
"i7-1065g7",
"i7-1068g7",
"i7-1068ng7"
);
private static final List<String> INTEL_GEN11_ATOM = List.of("x6211e", "x6212re", "x6214re", "x6413e", "x6414re", "x6416re", "x6425e", "x6425re", "x6427fe");
private static final List<String> INTEL_GEN11_CELERON = List.of("j6412", "j6413", "n4500", "n4505", "n5095", "n5095a", "n5100", "n5105", "n6210", "n6211");
private static final List<String> INTEL_GEN11_PENTIUM = List.of("6805", "j6426", "n6415", "n6000", "n6005");
@Nullable
private static GraphicsWorkarounds instance;
private final WeakReference<GpuDevice> gpuDevice;
private final boolean alwaysCreateFreshImmediateBuffer;
private GraphicsWorkarounds(GpuDevice device) {
this.gpuDevice = new WeakReference(device);
this.alwaysCreateFreshImmediateBuffer = isIntelGen11(device);
}
public static GraphicsWorkarounds get(GpuDevice device) {
GraphicsWorkarounds graphicsWorkarounds = instance;
if (graphicsWorkarounds == null || graphicsWorkarounds.gpuDevice.get() != device) {
instance = graphicsWorkarounds = new GraphicsWorkarounds(device);
}
return graphicsWorkarounds;
}
public boolean alwaysCreateFreshImmediateBuffer() {
return this.alwaysCreateFreshImmediateBuffer;
}
private static boolean isIntelGen11(GpuDevice device) {
String string = GLX._getCpuInfo().toLowerCase(Locale.ROOT);
String string2 = device.getRenderer().toLowerCase(Locale.ROOT);
if (!string.contains("intel") || !string2.contains("intel") || string2.contains("mesa")) {
return false;
} else if (string2.endsWith("gen11")) {
return true;
} else {
return !string2.contains("uhd graphics") && !string2.contains("iris")
? false
: string.contains("atom") && INTEL_GEN11_ATOM.stream().anyMatch(string::contains)
|| string.contains("celeron") && INTEL_GEN11_CELERON.stream().anyMatch(string::contains)
|| string.contains("pentium") && INTEL_GEN11_PENTIUM.stream().anyMatch(string::contains)
|| INTEL_GEN11_CORE.stream().anyMatch(string::contains);
}
}
}

View file

@ -1,7 +1,10 @@
package com.mojang.blaze3d.opengl;
import com.google.common.collect.Sets;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.opengl.Uniform.Sampler;
import com.mojang.blaze3d.opengl.Uniform.Ubo;
import com.mojang.blaze3d.opengl.Uniform.Utb;
import com.mojang.blaze3d.pipeline.RenderPipeline.UniformDescription;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.textures.TextureFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
@ -13,7 +16,7 @@ import java.util.Objects;
import java.util.Set;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.ShaderManager;
import net.minecraft.client.renderer.ShaderManager.CompilationException;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;
import org.lwjgl.opengl.GL31;
@ -33,10 +36,10 @@ public class GlProgram implements AutoCloseable {
this.debugLabel = debugLabel;
}
public static GlProgram link(GlShaderModule vertexShader, GlShaderModule fragmentShader, VertexFormat vertexFormat, String debugLabel) throws ShaderManager.CompilationException {
public static GlProgram link(GlShaderModule vertexShader, GlShaderModule fragmentShader, VertexFormat vertexFormat, String debugLabel) throws CompilationException {
int i = GlStateManager.glCreateProgram();
if (i <= 0) {
throw new ShaderManager.CompilationException("Could not create shader program (returned program ID " + i + ")");
throw new CompilationException("Could not create shader program (returned program ID " + i + ")");
} else {
int j = 0;
@ -49,22 +52,26 @@ public class GlProgram implements AutoCloseable {
GlStateManager.glAttachShader(i, fragmentShader.getShaderId());
GlStateManager.glLinkProgram(i);
int k = GlStateManager.glGetProgrami(i, 35714);
if (k == 0) {
String string = GlStateManager.glGetProgramInfoLog(i, 32768);
throw new ShaderManager.CompilationException(
String string = GlStateManager.glGetProgramInfoLog(i, 32768);
if (k != 0 && !string.contains("Failed for unknown reason")) {
if (!string.isEmpty()) {
LOGGER.info("Info log when linking program containing VS {} and FS {}. Log output: {}", vertexShader.getId(), fragmentShader.getId(), string);
}
return new GlProgram(i, debugLabel);
} else {
throw new CompilationException(
"Error encountered when linking program containing VS " + vertexShader.getId() + " and FS " + fragmentShader.getId() + ". Log output: " + string
);
} else {
return new GlProgram(i, debugLabel);
}
}
}
public void setupUniforms(List<RenderPipeline.UniformDescription> uniforms, List<String> samplers) {
public void setupUniforms(List<UniformDescription> uniforms, List<String> samplers) {
int i = 0;
int j = 0;
for (RenderPipeline.UniformDescription uniformDescription : uniforms) {
for (UniformDescription uniformDescription : uniforms) {
String string = uniformDescription.name();
Object var10000_1 = switch (uniformDescription.type()) {
@ -75,7 +82,7 @@ public class GlProgram implements AutoCloseable {
} else {
int l = i++;
GL31.glUniformBlockBinding(this.programId, k, l);
yield new Uniform.Ubo(l);
yield new Ubo(l);
}
}
case TEXEL_BUFFER -> {
@ -85,7 +92,7 @@ public class GlProgram implements AutoCloseable {
yield null;
} else {
int l = j++;
yield new Uniform.Utb(k, l, (TextureFormat)Objects.requireNonNull(uniformDescription.textureFormat()));
yield new Utb(k, l, (TextureFormat)Objects.requireNonNull(uniformDescription.textureFormat()));
}
}
};
@ -102,7 +109,7 @@ public class GlProgram implements AutoCloseable {
LOGGER.warn("{} shader program does not use sampler {} defined in the pipeline. This might be a bug.", this.debugLabel, string2);
} else {
int n = j++;
this.uniformsByName.put(string2, new Uniform.Sampler(m, n));
this.uniformsByName.put(string2, new Sampler(m, n));
}
}
@ -114,7 +121,7 @@ public class GlProgram implements AutoCloseable {
if (!samplers.contains(string) && BUILT_IN_UNIFORMS.contains(string)) {
int n = i++;
GL31.glUniformBlockBinding(this.programId, p, n);
this.uniformsByName.put(string, new Uniform.Ubo(n));
this.uniformsByName.put(string, new Ubo(n));
} else {
LOGGER.warn("Found unknown and unsupported uniform {} in {}", string, this.debugLabel);
}

View file

@ -2,6 +2,7 @@ package com.mojang.blaze3d.opengl;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.VertexFormatElement;
import com.mojang.blaze3d.vertex.VertexFormatElement.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -69,7 +70,7 @@ public abstract class VertexArrayCache {
case POSITION:
case GENERIC:
case UV:
if (vertexFormatElement.type() == VertexFormatElement.Type.FLOAT) {
if (vertexFormatElement.type() == Type.FLOAT) {
GlStateManager._vertexAttribPointer(
j, vertexFormatElement.count(), GlConst.toGl(vertexFormatElement.type()), false, i, vertexFormat.getOffset(vertexFormatElement)
);
@ -111,7 +112,6 @@ public abstract class VertexArrayCache {
if (vertexArray == null) {
int i = GlStateManager._glGenVertexArrays();
GlStateManager._glBindVertexArray(i);
ARBVertexAttribBinding.glBindVertexBuffer(0, buffer.handle, 0L, format.getVertexSize());
List<VertexFormatElement> list = format.getElements();
for (int j = 0; j < list.size(); j++) {
@ -121,7 +121,7 @@ public abstract class VertexArrayCache {
case POSITION:
case GENERIC:
case UV:
if (vertexFormatElement.type() == VertexFormatElement.Type.FLOAT) {
if (vertexFormatElement.type() == Type.FLOAT) {
ARBVertexAttribBinding.glVertexAttribFormat(
j, vertexFormatElement.count(), GlConst.toGl(vertexFormatElement.type()), false, format.getOffset(vertexFormatElement)
);
@ -141,6 +141,7 @@ public abstract class VertexArrayCache {
ARBVertexAttribBinding.glVertexAttribBinding(j, 0);
}
ARBVertexAttribBinding.glBindVertexBuffer(0, buffer.handle, 0L, format.getVertexSize());
VertexArrayCache.VertexArray vertexArray2 = new VertexArrayCache.VertexArray(i, format, buffer);
this.debugLabels.applyLabel(vertexArray2);
this.cache.put(format, vertexArray2);

View file

@ -428,13 +428,13 @@ public final class NativeImage implements AutoCloseable {
this.copyRect(this, xFrom, yFrom, xFrom + xToDelta, yFrom + yToDelta, width, height, mirrorX, mirrorY);
}
public void copyRect(NativeImage source, int xFrom, int yFrom, int xTo, int yTo, int width, int height, boolean mirrorX, boolean mirrorY) {
public void copyRect(NativeImage target, int xFrom, int yFrom, int xTo, int yTo, int width, int height, boolean mirrorX, boolean mirrorY) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int k = mirrorX ? width - 1 - j : j;
int l = mirrorY ? height - 1 - i : i;
int m = this.getPixelABGR(xFrom + j, yFrom + i);
source.setPixelABGR(xTo + k, yTo + l, m);
target.setPixelABGR(xTo + k, yTo + l, m);
}
}
}

View file

@ -3,6 +3,7 @@ package com.mojang.blaze3d.vertex;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.mojang.blaze3d.DontObfuscate;
import com.mojang.blaze3d.GraphicsWorkarounds;
import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice;
@ -16,13 +17,14 @@ import java.util.function.Supplier;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.Util;
import net.minecraft.Util.OS;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
@DontObfuscate
public class VertexFormat {
public static final int UNKNOWN_ELEMENT = -1;
private static final boolean USE_STAGING_BUFFER_WORKAROUND = Util.getPlatform() == Util.OS.WINDOWS && Util.isAarch64();
private static final boolean USE_STAGING_BUFFER_WORKAROUND = Util.getPlatform() == OS.WINDOWS && Util.isAarch64();
@Nullable
private static GpuBuffer UPLOAD_STAGING_BUFFER;
private final List<VertexFormatElement> elements;
@ -125,8 +127,8 @@ public class VertexFormat {
}
private GpuBuffer uploadToBufferWithWorkaround(@Nullable GpuBuffer gpuBuffer, ByteBuffer byteBuffer, int i, Supplier<String> supplier) {
GpuDevice gpuDevice = RenderSystem.getDevice();
if (USE_STAGING_BUFFER_WORKAROUND) {
GpuDevice gpuDevice = RenderSystem.getDevice();
if (gpuBuffer == null) {
gpuBuffer = gpuDevice.createBuffer(supplier, i, byteBuffer);
} else {
@ -141,6 +143,12 @@ public class VertexFormat {
}
return gpuBuffer;
} else if (GraphicsWorkarounds.get(gpuDevice).alwaysCreateFreshImmediateBuffer()) {
if (gpuBuffer != null) {
gpuBuffer.close();
}
return gpuDevice.createBuffer(supplier, i, byteBuffer);
} else {
return uploadToBuffer(gpuBuffer, byteBuffer, i, supplier);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/minecraft/structure/empty.nbt (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/minecraft/structure/end_city/ship.nbt (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/minecraft/structure/igloo/bottom.nbt (Stored with Git LFS)

Binary file not shown.

BIN
data/minecraft/structure/igloo/middle.nbt (Stored with Git LFS)

Binary file not shown.

BIN
data/minecraft/structure/igloo/top.nbt (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more