mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-05-24 18:24:14 +00:00
Ignore shader loading errors
Another go at fixing #2127. In a892739f8eb87fb078dedae07d8c8614b9d6da4b we set the precision on the Tbo uniform. However, this is stripped in the shader pre-processing Pojav/gl4es does, and so has no effect. As a (terrible) workaround, we now just ignore shader loading errors. This probably does leak memory (we'll never clean up the program), but there's not much we can do about that.
This commit is contained in:
parent
b42bc0a01a
commit
1b8344d0a3
@ -47,6 +47,8 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -63,6 +65,8 @@ import java.util.function.Supplier;
|
||||
* @see ModRegistry The common registry for actual game objects.
|
||||
*/
|
||||
public final class ClientRegistry {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClientRegistry.class);
|
||||
|
||||
private ClientRegistry() {
|
||||
}
|
||||
|
||||
@ -182,7 +186,18 @@ public final class ClientRegistry {
|
||||
}
|
||||
|
||||
public static void registerShaders(ResourceProvider resources, BiConsumer<ShaderInstance, Consumer<ShaderInstance>> load) throws IOException {
|
||||
RenderTypes.registerShaders(resources, load);
|
||||
RenderTypes.registerShaders(resources, (name, create, onLoaded) -> {
|
||||
ShaderInstance shader;
|
||||
try {
|
||||
shader = create.get();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to load {}", name, e);
|
||||
onLoaded.accept(null);
|
||||
return;
|
||||
}
|
||||
|
||||
load.accept(shader, onLoaded);
|
||||
});
|
||||
}
|
||||
|
||||
private record UnclampedPropertyFunction(
|
||||
|
@ -16,11 +16,11 @@ import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import org.apache.commons.io.function.IOSupplier;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@ -68,9 +68,12 @@ public class RenderTypes {
|
||||
return Objects.requireNonNull(GameRenderer.getRendertypeTextShader(), "Text shader has not been registered");
|
||||
}
|
||||
|
||||
public static void registerShaders(ResourceProvider resources, BiConsumer<ShaderInstance, Consumer<ShaderInstance>> load) throws IOException {
|
||||
load.accept(
|
||||
new MonitorTextureBufferShader(
|
||||
public interface ShaderLoader {
|
||||
void tryLoad(String name, IOSupplier<ShaderInstance> create, Consumer<@Nullable ShaderInstance> accept) throws IOException;
|
||||
}
|
||||
|
||||
public static void registerShaders(ResourceProvider resources, ShaderLoader load) throws IOException {
|
||||
load.tryLoad("monitor shader", () -> new MonitorTextureBufferShader(
|
||||
resources,
|
||||
ComputerCraftAPI.MOD_ID + "/monitor_tbo",
|
||||
MONITOR_TBO.format()
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define FONT_HEIGHT 9.0
|
||||
|
||||
uniform sampler2D Sampler0; // Font
|
||||
uniform mediump usamplerBuffer Tbo;
|
||||
uniform usamplerBuffer Tbo;
|
||||
|
||||
layout(std140) uniform MonitorData {
|
||||
vec3 Palette[16];
|
||||
|
Loading…
x
Reference in New Issue
Block a user