Compare commits

..
Author SHA1 Message Date
Logan Phillips 4a05ea1bfe Adds fluid and gas culling 2026-11-26 23:35:42 -05:00
Jason Mitchell b3e9f02e95 Fix flickering GregTech ores with shader packs on Mac SDL GPU (#2382)
* Fix flickering GregTech ores with shader packs on Mac SDL GPU

* Release GPU objects in SDL GPU device tests
2026-11-26 16:07:27 -08:00
33 changed files with 538 additions and 725 deletions

No files matched your search

@@ -8,13 +8,21 @@ import java.util.List;
public final class ClipZRemap {
private static final String INJECTION_STD = "gl_Position.z = gl_Position.z * 0.5 + gl_Position.w * 0.5;\n";
private static final String PRECISE_POSITION = "precise gl_Position;\n";
private ClipZRemap() {}
public static boolean collectEdits(GLSLParser.Translation_unitContext root, List<Edit> edits) {
boolean preciseInserted = false;
for (GLSLParser.External_declarationContext external : root.external_declaration()) {
final GLSLParser.Function_definitionContext function = external.function_definition();
if (function == null || function.function_prototype().IDENTIFIER() == null) continue;
if (function == null) continue;
if (!preciseInserted) {
final int start = external.getStart().getStartIndex();
edits.add(new Edit(start, start - 1, PRECISE_POSITION));
preciseInserted = true;
}
if (function.function_prototype().IDENTIFIER() == null) continue;
if (!"main".equals(function.function_prototype().IDENTIFIER().getText())) continue;
final GLSLParser.Compound_statement_no_new_scopeContext body = function.compound_statement_no_new_scope();
if (body == null || body.RIGHT_BRACE() == null) return false;
@@ -0,0 +1,92 @@
package com.gtnewhorizons.angelica.sdlgpu;
import com.gtnewhorizons.angelica.sdlgpu.frame.ContextState;
import com.gtnewhorizons.angelica.sdlgpu.pipeline.PipelineCache;
import com.gtnewhorizons.angelica.sdlgpu.pipeline.PipelineStore;
import com.gtnewhorizons.angelica.sdlgpu.shader.ShaderManager;
import org.lwjgl.opengl.GL20;
import org.lwjgl.sdl.SDLError;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Consumer;
import javax.imageio.ImageIO;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.lwjgl.sdl.SDLGPU.SDL_GPU_SHADERSTAGE_FRAGMENT;
import static org.lwjgl.sdl.SDLGPU.SDL_GPU_SHADERSTAGE_VERTEX;
public final class GpuTestPrograms {
private GpuTestPrograms() {}
public static int link(ShaderManager sm, String vertex, String fragment) {
final int vs = sm.createShader(GL20.GL_VERTEX_SHADER);
sm.shaderSource(vs, vertex);
sm.compileShader(vs);
final int fs = sm.createShader(GL20.GL_FRAGMENT_SHADER);
sm.shaderSource(fs, fragment);
sm.compileShader(fs);
final int program = sm.createProgram();
sm.attachShader(program, vs);
sm.attachShader(program, fs);
sm.linkProgram(program);
final ShaderManager.ProgramObject po = sm.getProgram(program);
assertTrue(po != null && po.linked, "link failed: " + (po == null ? "no program" : po.infoLog));
final ShaderManager.ResourceCounts vr = po.vertexResources;
final ShaderManager.ResourceCounts fr = po.fragmentResources;
po.sdlVertexShader = sm.createSDLShader(po.vertexSpirv, SDL_GPU_SHADERSTAGE_VERTEX, vr.numSamplers(), vr.numUBOs(), vr.numStorageBuffers(), vr.numStorageTextures());
po.sdlFragmentShader = sm.createSDLShader(po.fragmentSpirv, SDL_GPU_SHADERSTAGE_FRAGMENT, fr.numSamplers(), fr.numUBOs(), fr.numStorageBuffers(), fr.numStorageTextures());
assertTrue(po.sdlVertexShader != 0 && po.sdlFragmentShader != 0, "SDL shader creation failed: " + SDLError.SDL_GetError());
return program;
}
public static String solidFragment(String rgb) {
return """
#version 460 core
layout(location = 0) out vec4 fragColor;
void main() { fragColor = vec4(%s, 1.0); }
""".formatted(rgb);
}
public static long pipeline(PipelineStore store, ShaderManager sm, int program, int colorFormat, int depthFormat, Consumer<PipelineCache> state) {
final ShaderManager.ProgramObject po = sm.getProgram(program);
final ContextState cs = new ContextState();
final PipelineCache cache = cs.pipeline;
cache.vertexShader = po.sdlVertexShader;
cache.fragmentShader = po.sdlFragmentShader;
cache.programId = program;
cache.maxFragOutputLocation = po.maxFragOutputLocation;
cache.setVertexInputs(po.vertexInputMask, po.vertexInputVecSize, po.vertexInputBaseType, po.vertexInputName, po.vertexInputSetId);
cache.setColorTargetFormats(new int[]{ colorFormat });
cache.setDrawBuffers(new int[]{ 0 });
cache.hasDepthTarget = true;
cache.depthTargetFormat = depthFormat;
state.accept(cache);
cache.markShaderDirty();
cache.markOutputDirty();
final long pipeline = cache.getOrCreatePipeline(store, cs);
assertTrue(pipeline != 0, "pipeline creation failed: " + SDLError.SDL_GetError());
return pipeline;
}
public static Path dumpPng(ByteBuffer rgba, int width, int height, String name) throws IOException {
final Path out = Path.of("build", "test-artifacts");
Files.createDirectories(out);
final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
final int i = (y * width + x) * 4;
img.setRGB(x, y, ((rgba.get(i) & 0xFF) << 16) | ((rgba.get(i + 1) & 0xFF) << 8) | (rgba.get(i + 2) & 0xFF));
}
}
final Path file = out.resolve(name + ".png").toAbsolutePath();
ImageIO.write(img, "png", file.toFile());
return file;
}
}
@@ -84,7 +84,7 @@ public final class SdlTestRig {
}
}
private static long realSdlDevice;
private static SdlTestRig realRig;
private static final int SHADER_FORMATS = SDL_GPU_SHADERFORMAT_SPIRV | SDL_GPU_SHADERFORMAT_MSL | SDL_GPU_SHADERFORMAT_DXBC | SDL_GPU_SHADERFORMAT_DXIL;
@@ -95,19 +95,19 @@ public final class SdlTestRig {
public static SdlTestRig acquireRealDevice() {
initSdlVideo();
realSdlDevice = SDL_CreateGPUDevice(SHADER_FORMATS, true, (CharSequence) null);
assertTrue(realSdlDevice != 0, "No SDL GPU device: " + SDLError.SDL_GetError());
final long handle = SDL_CreateGPUDevice(SHADER_FORMATS, true, (CharSequence) null);
assertTrue(handle != 0, "No SDL GPU device: " + SDLError.SDL_GetError());
final SdlTestRig rig = new SdlTestRig(realSdlDevice);
rig.frameManager.setResourceManager(rig.resourceManager);
return rig;
realRig = new SdlTestRig(handle);
realRig.frameManager.setResourceManager(realRig.resourceManager);
return realRig;
}
public static void releaseRealDevice() {
if (realSdlDevice != 0) {
SDL_WaitForGPUIdle(realSdlDevice);
SDL_DestroyGPUDevice(realSdlDevice);
realSdlDevice = 0;
}
if (realRig == null) return;
SDL_WaitForGPUIdle(realRig.sdlHandle);
realRig.resourceManager.shutdown();
SDL_DestroyGPUDevice(realRig.sdlHandle);
realRig = null;
}
}
@@ -1,16 +1,15 @@
package com.gtnewhorizons.angelica.sdlgpu.pipeline;
import com.gtnewhorizons.angelica.sdlgpu.GpuTestPrograms;
import com.gtnewhorizons.angelica.sdlgpu.RealDeviceExtension;
import com.gtnewhorizons.angelica.sdlgpu.SdlTestRig;
import com.gtnewhorizons.angelica.sdlgpu.frame.ContextState;
import com.gtnewhorizons.angelica.sdlgpu.glsm.GlsmSdlHeadlessRig;
import com.gtnewhorizons.angelica.sdlgpu.shader.ShaderManager;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.lwjgl.opengl.GL20;
import org.lwjgl.sdl.SDLError;
import org.lwjgl.sdl.SDL_GPUColorTargetInfo;
import org.lwjgl.sdl.SDL_GPUDepthStencilTargetInfo;
import org.lwjgl.system.MemoryStack;
@@ -49,13 +48,7 @@ class StencilMaskGpuTest {
"}",
"");
private static final String FILL_FRAGMENT = String.join("\n",
"#version 460 core",
"layout(location = 0) out vec4 fragColor;",
"void main() {",
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);",
"}",
"");
private static final String FILL_FRAGMENT = GpuTestPrograms.solidFragment("1.0, 0.0, 0.0");
@BeforeAll
static void setUp() throws Exception {
@@ -76,56 +69,28 @@ class StencilMaskGpuTest {
fillPipeline = createPipeline(FILL_FRAGMENT, false);
}
@AfterAll
static void tearDown() {
if (store != null) store.shutdown();
if (sm != null) sm.shutdown();
}
private static long createPipeline(String fragmentSource, boolean writesMask) {
final int vs = sm.createShader(GL20.GL_VERTEX_SHADER);
sm.shaderSource(vs, GlsmSdlHeadlessRig.FULLSCREEN_VERTEX);
sm.compileShader(vs);
final int fs = sm.createShader(GL20.GL_FRAGMENT_SHADER);
sm.shaderSource(fs, fragmentSource);
sm.compileShader(fs);
final int prog = sm.createProgram();
sm.attachShader(prog, vs);
sm.attachShader(prog, fs);
sm.linkProgram(prog);
final ShaderManager.ProgramObject po = sm.getProgram(prog);
assertTrue(po != null && po.linked, "link failed: " + (po == null ? "no program" : po.infoLog));
po.sdlVertexShader = sm.createSDLShader(po.vertexSpirv, SDL_GPU_SHADERSTAGE_VERTEX, po.vertexResources.numSamplers(), po.vertexResources.numUBOs(), po.vertexResources.numStorageBuffers(), po.vertexResources.numStorageTextures());
po.sdlFragmentShader = sm.createSDLShader(po.fragmentSpirv, SDL_GPU_SHADERSTAGE_FRAGMENT, po.fragmentResources.numSamplers(), po.fragmentResources.numUBOs(), po.fragmentResources.numStorageBuffers(), po.fragmentResources.numStorageTextures());
assertTrue(po.sdlVertexShader != 0 && po.sdlFragmentShader != 0, "SDL shader creation failed");
final ContextState cs = new ContextState();
final PipelineCache cache = cs.pipeline;
cache.vertexShader = po.sdlVertexShader;
cache.fragmentShader = po.sdlFragmentShader;
cache.programId = prog;
cache.maxFragOutputLocation = po.maxFragOutputLocation;
cache.shaderInputMask = po.vertexInputMask;
cache.shaderInputVecSize = po.vertexInputVecSize;
cache.shaderInputBaseType = po.vertexInputBaseType;
cache.shaderInputName = po.vertexInputName;
cache.setColorTargetFormats(new int[]{ colorFormat });
cache.setDrawBuffers(new int[]{ 0 });
cache.hasDepthTarget = true;
cache.depthTargetFormat = depthFormat;
cache.depthTestEnabled = false;
cache.depthWriteEnabled = false;
cache.stencilTestEnabled = true;
cache.stencilCompareMask = 0xFF;
cache.stencilWriteMask = writesMask ? 0xFF : 0x00;
final int prog = GpuTestPrograms.link(sm, GlsmSdlHeadlessRig.FULLSCREEN_VERTEX, fragmentSource);
final int compareOp = writesMask ? SDL_GPU_COMPAREOP_ALWAYS : SDL_GPU_COMPAREOP_EQUAL;
final int passOp = writesMask ? SDL_GPU_STENCILOP_REPLACE : SDL_GPU_STENCILOP_KEEP;
cache.stencilFrontCompareOp = compareOp;
cache.stencilBackCompareOp = compareOp;
cache.stencilFrontPassOp = passOp;
cache.stencilBackPassOp = passOp;
cache.markShaderDirty();
cache.markOutputDirty();
assertTrue(cache.effectiveStencilTestEnabled(), "stencil must survive the depth-format gate");
final long pipeline = cache.getOrCreatePipeline(store, cs);
assertTrue(pipeline != 0, "pipeline creation failed: " + SDLError.SDL_GetError());
return pipeline;
return GpuTestPrograms.pipeline(store, sm, prog, colorFormat, depthFormat, cache -> {
cache.depthTestEnabled = false;
cache.depthWriteEnabled = false;
cache.stencilTestEnabled = true;
cache.stencilCompareMask = 0xFF;
cache.stencilWriteMask = writesMask ? 0xFF : 0x00;
cache.stencilFrontCompareOp = compareOp;
cache.stencilBackCompareOp = compareOp;
cache.stencilFrontPassOp = passOp;
cache.stencilBackPassOp = passOp;
assertTrue(cache.effectiveStencilTestEnabled(), "stencil must survive the depth-format gate");
});
}
private static void render(int secondPassStencilLoad) {
@@ -3,7 +3,6 @@ package com.gtnewhorizons.angelica.sdlgpu.resource;
import com.gtnewhorizons.angelica.sdlgpu.RealDeviceExtension;
import com.gtnewhorizons.angelica.sdlgpu.SdlTestRig;
import com.gtnewhorizons.angelica.sdlgpu.device.Device;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -30,11 +29,6 @@ class BufferSizeGpuExactnessTest {
resourceManager = rig.resourceManager;
}
@AfterAll
static void tearDown() {
if (resourceManager != null) resourceManager.shutdown();
}
@ParameterizedTest(name = "{0}")
@CsvSource({"sub-bucket,9001,1000", "bucket boundary,9002,4096"})
void createdBufferReportsRequestedSize(String name, int glId, long size) {
@@ -0,0 +1,186 @@
package com.gtnewhorizons.angelica.sdlgpu.shader;
import com.gtnewhorizons.angelica.sdlgpu.GpuTestPrograms;
import com.gtnewhorizons.angelica.sdlgpu.RealDeviceExtension;
import com.gtnewhorizons.angelica.sdlgpu.SdlTestRig;
import com.gtnewhorizons.angelica.sdlgpu.pipeline.PipelineCache;
import com.gtnewhorizons.angelica.sdlgpu.pipeline.PipelineStore;
import org.joml.Matrix4f;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.lwjgl.sdl.SDL_GPUColorTargetInfo;
import org.lwjgl.sdl.SDL_GPUDepthStencilTargetInfo;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.lwjgl.sdl.SDLGPU.*;
@ExtendWith(RealDeviceExtension.class)
@Tag("sdl-gpu-device")
class CoplanarDepthGpuTest {
private static final int SIZE = 256;
private static final int GRID = 32;
private static final int UBO_BYTES = 4 * 64 + 2 * 16;
private static final double CAM_X = 1475.7192986248613, CAM_Y = 70.62, CAM_Z = -935.8161276616005;
private static final String HEADER = """
#version 460 core
layout(std140) uniform Mats { mat4 proj; mat4 view; mat4 viewInv; mat4 mv; vec4 params; vec4 region; };
vec3 _vert_position;
void _vert_init() {
const ivec2 corner[6] = ivec2[](ivec2(0, 0), ivec2(1, 0), ivec2(1, 1), ivec2(0, 0), ivec2(1, 1), ivec2(0, 1));
int g = int(params.w);
int q = gl_VertexID / 6;
int c = gl_VertexID % 6;
vec2 uv = vec2(float(q % g + corner[c].x), float(q / g + corner[c].y)) / params.w;
vec3 packed = floor(vec3(uv.x * 16.0, 1.37 + uv.y * 3.1, 9.0 + uv.y * 7.0) * 2048.0);
_vert_position = packed * (1.0 / 2048.0) + vec3(params.z);
}
vec4 _celeritas_getVertexPosition() { return vec4(_vert_position + region.xyz, 1.0); }
""";
private static final String TERRAIN_VERTEX = HEADER + """
out vec3 vWorld;
void main() {
_vert_init();
vec4 position = viewInv * (mv * _celeritas_getVertexPosition());
vWorld = position.xyz;
gl_Position = proj * (view * position);
}
""";
private static final String WATER_VERTEX = HEADER + """
out vec3 vWorld;
out vec3 vView;
out float vWave;
out vec3 vNormal;
void main() {
_vert_init();
vec4 position = viewInv * (mv * _celeritas_getVertexPosition());
vWorld = position.xyz;
float wave = sin(position.x * 0.7 + params.y) * cos(position.z * 0.3 + params.y) * params.x;
if (params.x > 0.0) position.y += wave;
vWave = wave;
vView = (view * position).xyz;
vNormal = normalize(mat3(view) * vec3(0.0, 1.0, 0.0) + vec3(wave));
gl_Position = proj * (view * position);
}
""";
private static SdlTestRig rig;
private static ShaderManager sm;
private static PipelineStore store;
private static long colorTexture;
private static int colorFormat;
private static long depthTexture;
private static int depthFormat;
private static long terrainPipeline;
private static long waterPipeline;
@BeforeAll
static void setUp() {
rig = RealDeviceExtension.rig();
sm = new ShaderManager(rig.device);
store = new PipelineStore(rig.device);
final RealDeviceExtension.Target color = RealDeviceExtension.colorTarget(9600, SIZE, SIZE);
colorTexture = color.texture();
colorFormat = color.sdlFormat();
PipelineCache.setSwapchainFormats(new int[]{ colorFormat });
final RealDeviceExtension.Target depth = RealDeviceExtension.depthStencilTarget(9601, SIZE, SIZE);
depthTexture = depth.texture();
depthFormat = depth.sdlFormat();
terrainPipeline = createPipeline(TERRAIN_VERTEX, GpuTestPrograms.solidFragment("1.0, 0.0, 0.0"), SDL_GPU_COMPAREOP_LESS, true);
waterPipeline = createPipeline(WATER_VERTEX, GpuTestPrograms.solidFragment("0.0, 1.0, 0.0"), SDL_GPU_COMPAREOP_EQUAL, false);
}
@AfterAll
static void tearDown() {
if (store != null) store.shutdown();
if (sm != null) sm.shutdown();
}
private static long createPipeline(String vertexSource, String fragmentSource, int compareOp, boolean depthWrite) {
final int prog = GpuTestPrograms.link(sm, vertexSource, fragmentSource);
assertEquals(1, sm.getProgram(prog).vertexResources.numUBOs(), "the matrix block must be the only vertex UBO, pushed at slot 0");
return GpuTestPrograms.pipeline(store, sm, prog, colorFormat, depthFormat, cache -> {
cache.depthTestEnabled = true;
cache.depthWriteEnabled = depthWrite;
cache.depthCompareOp = compareOp;
});
}
private static void writeMats(ByteBuffer ubo) {
final Matrix4f proj = new Matrix4f().perspective((float) Math.toRadians(70.0), 1.0f, 0.05f, 512.0f);
final Matrix4f view = new Matrix4f().rotationX(0.35f).rotateY((float) Math.PI - 0.2f);
proj.get(0, ubo);
view.get(64, ubo);
view.invert(new Matrix4f()).get(128, ubo);
view.get(192, ubo);
ubo.putFloat(256, 0.0f).putFloat(260, 0.25f).putFloat(264, -0.37f).putFloat(268, GRID);
ubo.putFloat(272, (float) (1472.0 - CAM_X)).putFloat(276, (float) (64.0 - CAM_Y));
}
private static void drawAndRead(ByteBuffer ubo, ByteBuffer pixels) {
try (MemoryStack stack = MemoryStack.stackPush()) {
final long cb = SDL_AcquireGPUCommandBuffer(rig.device.getDevice());
assertTrue(cb != 0, "no command buffer");
final SDL_GPUColorTargetInfo.Buffer color = SDL_GPUColorTargetInfo.calloc(1, stack);
color.get(0).texture(colorTexture).load_op(SDL_GPU_LOADOP_CLEAR).store_op(SDL_GPU_STOREOP_STORE);
final SDL_GPUDepthStencilTargetInfo ds = SDL_GPUDepthStencilTargetInfo.calloc(stack)
.texture(depthTexture)
.load_op(SDL_GPU_LOADOP_CLEAR).store_op(SDL_GPU_STOREOP_DONT_CARE).clear_depth(1.0f)
.stencil_load_op(SDL_GPU_LOADOP_CLEAR).stencil_store_op(SDL_GPU_STOREOP_DONT_CARE);
SDL_PushGPUVertexUniformData(cb, 0, ubo);
final long pass = SDL_BeginGPURenderPass(cb, color, ds);
assertTrue(pass != 0, "no render pass");
SDL_BindGPUGraphicsPipeline(pass, terrainPipeline);
SDL_DrawGPUPrimitives(pass, GRID * GRID * 6, 1, 0, 0);
SDL_BindGPUGraphicsPipeline(pass, waterPipeline);
SDL_DrawGPUPrimitives(pass, GRID * GRID * 6, 1, 0, 0);
SDL_EndGPURenderPass(pass);
pixels.clear();
rig.resourceManager.downloadFromTexture(cb, colorTexture, 0, 0, SIZE, SIZE, 0, pixels);
}
}
@Test
void secondProgramMatchesFirstProgramDepthOnCoplanarGeometry() throws IOException {
final ByteBuffer ubo = MemoryUtil.memCalloc(UBO_BYTES);
final ByteBuffer pixels = MemoryUtil.memAlloc(SIZE * SIZE * 4);
try {
int mismatched = 0, covered = 0;
Path firstBad = null;
writeMats(ubo);
for (double chunkZ : new double[]{ 0, 16, 64, 256 }) {
ubo.putFloat(280, (float) (-944.0 + chunkZ - CAM_Z));
drawAndRead(ubo, pixels);
int red = 0;
for (int i = 0; i < SIZE * SIZE * 4; i += 4) {
if ((pixels.get(i) & 0xFF) > 128) red++;
else if ((pixels.get(i + 1) & 0xFF) > 128) covered++;
}
if (red > 0 && firstBad == null) firstBad = GpuTestPrograms.dumpPng(pixels, SIZE, SIZE, "coplanar_depth_dz" + (int) chunkZ);
mismatched += red;
covered += red;
}
assertTrue(covered > 4 * SIZE, "the plane must cover the target, covered=" + covered);
assertEquals(0, mismatched, "depth EQUAL failed on " + mismatched + "/" + covered + " pixels drawn by both programs; first failing view: " + firstBad);
} finally {
MemoryUtil.memFree(ubo);
MemoryUtil.memFree(pixels);
}
}
}
@@ -1,8 +1,10 @@
package com.gtnewhorizons.angelica.sdlgpu.shader;
import com.gtnewhorizons.angelica.sdlgpu.GpuTestPrograms;
import com.gtnewhorizons.angelica.sdlgpu.RealDeviceExtension;
import com.gtnewhorizons.angelica.sdlgpu.SdlTestRig;
import com.gtnewhorizons.angelica.sdlgpu.glsm.GlsmSdlHeadlessRig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -10,7 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.lwjgl.sdl.SDL_GPUColorTargetDescription;
import org.lwjgl.sdl.SDL_GPUColorTargetInfo;
@@ -25,7 +26,6 @@ import org.lwjgl.system.MemoryUtil;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -48,6 +48,11 @@ class FragmentStorageTextureReadGpuTest {
sm = new ShaderManager(rig.device);
}
@AfterAll
static void tearDown() {
if (sm != null) sm.shutdown();
}
private static String fragment(int samplerCount) {
final StringBuilder sb = new StringBuilder();
sb.append("#version 460 core\n");
@@ -69,8 +74,7 @@ class FragmentStorageTextureReadGpuTest {
return (x == y) ? 255 - z * 16 : z * 32 + x * 2 + y;
}
private int createVoxelTexture() {
final int glId = 9001;
private int createVoxelTexture(int glId) {
final long handle = rig.resourceManager.createTexture(glId, GL12.GL_TEXTURE_3D, GL30.GL_R16UI, VOL, VOL, VOL, 1);
assertTrue(handle != 0, "voxel texture creation failed");
final ByteBuffer data = MemoryUtil.memAlloc(VOL * VOL * VOL * 2);
@@ -95,25 +99,15 @@ class FragmentStorageTextureReadGpuTest {
}
private int linkProgram(int samplerCount) {
final int vs = sm.createShader(GL20.GL_VERTEX_SHADER);
sm.shaderSource(vs, GlsmSdlHeadlessRig.FULLSCREEN_VERTEX);
sm.compileShader(vs);
final int fs = sm.createShader(GL20.GL_FRAGMENT_SHADER);
sm.shaderSource(fs, fragment(samplerCount));
sm.compileShader(fs);
final int prog = sm.createProgram();
sm.attachShader(prog, vs);
sm.attachShader(prog, fs);
sm.linkProgram(prog);
final int prog = GpuTestPrograms.link(sm, GlsmSdlHeadlessRig.FULLSCREEN_VERTEX, fragment(samplerCount));
final ShaderManager.ProgramObject po = sm.getProgram(prog);
assertTrue(po != null && po.linked, "link failed: " + (po == null ? "no program" : po.infoLog));
assertEquals(samplerCount, po.fragmentResources.numSamplers(), "production sampler count");
assertEquals(1, po.fragmentResources.numStorageTextures(), "production storage texture count");
return prog;
}
private void runCase(int samplerCount) throws IOException {
final int voxelGlId = createVoxelTexture();
final int voxelGlId = createVoxelTexture(9000 + samplerCount);
final long voxelHandle = rig.resourceManager.getTextureHandle(voxelGlId);
final int targetGlId = 9100 + samplerCount;
@@ -132,13 +126,6 @@ class FragmentStorageTextureReadGpuTest {
System.out.println("[GpuReadTest] S=" + samplerCount
+ " VS=" + po.vertexResources + " FS=" + po.fragmentResources);
final ShaderManager.ResourceCounts vr = po.vertexResources;
po.sdlVertexShader = sm.createSDLShader(po.vertexSpirv, SDL_GPU_SHADERSTAGE_VERTEX, vr.numSamplers(), vr.numUBOs(), vr.numStorageBuffers(), vr.numStorageTextures());
final ShaderManager.ResourceCounts fr = po.fragmentResources;
po.sdlFragmentShader = sm.createSDLShader(po.fragmentSpirv, SDL_GPU_SHADERSTAGE_FRAGMENT, fr.numSamplers(), fr.numUBOs(), fr.numStorageBuffers(), fr.numStorageTextures());
assertTrue(po.sdlVertexShader != 0, "SDL vertex shader creation failed");
assertTrue(po.sdlFragmentShader != 0, "SDL fragment shader creation failed");
final long pipeline;
try (MemoryStack stack = MemoryStack.stackPush()) {
final SDL_GPUColorTargetDescription.Buffer colorDesc = SDL_GPUColorTargetDescription.calloc(1, stack);
@@ -189,13 +176,14 @@ class FragmentStorageTextureReadGpuTest {
assertTrue(SDL_SubmitGPUCommandBuffer(cb), "draw submit failed");
SDL_WaitForGPUIdle(rig.device.getDevice());
}
SDL_ReleaseGPUGraphicsPipeline(rig.device.getDevice(), pipeline);
final ByteBuffer pixels = MemoryUtil.memAlloc(TARGET * TARGET * 4);
try {
final long cb = SDL_AcquireGPUCommandBuffer(rig.device.getDevice());
assertTrue(cb != 0, "no readback command buffer");
rig.resourceManager.downloadFromTexture(cb, targetHandle, 0, 0, TARGET, TARGET, 0, pixels);
final Path png = dumpPng(pixels, samplerCount);
final Path png = GpuTestPrograms.dumpPng(pixels, TARGET, TARGET, "storage_read_s" + samplerCount);
// SDL's Y-flip means the readback may be row-inverted vs gl_FragCoord; either orientation
// is a fixed convention, not this bug - accept whichever matches.
final int direct = countMismatches(pixels, false, null);
@@ -229,22 +217,6 @@ class FragmentStorageTextureReadGpuTest {
return mismatches;
}
private static Path dumpPng(ByteBuffer rgba, int samplerCount) throws IOException {
final Path out = Path.of("build", "test-artifacts");
Files.createDirectories(out);
final java.awt.image.BufferedImage img = new java.awt.image.BufferedImage(TARGET, TARGET, java.awt.image.BufferedImage.TYPE_INT_RGB);
for (int y = 0; y < TARGET; y++) {
for (int x = 0; x < TARGET; x++) {
final int i = (y * TARGET + x) * 4;
img.setRGB(x, y, ((rgba.get(i) & 0xFF) << 16) | ((rgba.get(i + 1) & 0xFF) << 8) | (rgba.get(i + 2) & 0xFF));
}
}
final Path file = out.resolve("storage_read_s" + samplerCount + ".png").toAbsolutePath();
javax.imageio.ImageIO.write(img, "png", file.toFile());
System.out.println("[GpuReadTest] wrote " + file);
return file;
}
@ParameterizedTest(name = "{0} samplers")
@ValueSource(ints = {0, 2})
void fragmentImageLoadReadsCorrectTexels(int samplerCount) throws IOException {
@@ -291,6 +291,55 @@ class MslCrossCompileTest {
assertUniqueBufferSlots(msl);
}
private static final String POSITION_HEAD = """
#version 460 core
layout(std140) uniform Mats { mat4 proj; mat4 view; mat4 viewInv; mat4 mv; vec4 ab; };
in vec3 a_Position;
out float vOut;
""";
static Stream<Arguments> positionVertexShapes() {
return Stream.of(
Arguments.of("chain through a temporary", "proj|view|viewInv|mv", POSITION_HEAD + """
void main() {
vec4 position = viewInv * (mv * vec4(a_Position, 1.0));
vOut = ab.x * ab.y;
gl_Position = proj * (view * position);
}
"""),
Arguments.of("declared invariant", "proj|view", POSITION_HEAD + """
invariant gl_Position;
void main() {
vOut = ab.x * ab.y;
gl_Position = proj * (view * vec4(a_Position, 1.0));
}
"""),
Arguments.of("already precise", "proj|view", POSITION_HEAD + """
precise gl_Position;
void main() {
vOut = ab.x * ab.y;
gl_Position = proj * (view * vec4(a_Position, 1.0));
}
"""),
Arguments.of("helper writes gl_Position", "proj|view", POSITION_HEAD + """
void place(vec4 p) { gl_Position = proj * (view * p); }
void main() {
vOut = ab.x * ab.y;
place(viewInv * (mv * vec4(a_Position, 1.0)));
}
"""));
}
@ParameterizedTest(name = "{0}")
@MethodSource("positionVertexShapes")
void positionMathIsContractionFreeAndOtherMathIsNot(String name, String exactMatrices, String glsl) {
final String transformed = ShaderManager.applyPrewarmTransformsFull(glsl, GL20.GL_VERTEX_SHADER, null, null).source();
final String msl = crossCompile(transformed, Shaderc.shaderc_vertex_shader, GL20.GL_VERTEX_SHADER, false).code();
assertTrue(msl.contains("spvFMulMatrixVector") && msl.contains("[[clang::optnone]]"), "gl_Position math must go through the optnone fma helpers:\n" + msl);
assertFalse(Pattern.compile("\\.(" + exactMatrices + ") \\*").matcher(msl).find(), "a plain multiply by " + exactMatrices + " is left on the gl_Position chain:\n" + msl);
assertTrue(Pattern.compile("\\.ab\\.x \\* \\w+\\.ab\\.y").matcher(msl).find(), "math not feeding gl_Position must stay contractible:\n" + msl);
}
private static void assertUniqueBufferSlots(String msl) {
final Set<Integer> seen = new HashSet<>();
int from = 0;
@@ -1,70 +0,0 @@
package com.gtnewhorizons.angelica.api.particles;
import net.coderbot.iris.layer.GbufferPrograms;
import net.minecraft.client.particle.EntityFX;
import java.util.Arrays;
/** Particle size and shader hooks for mods that scale or draw their own particles */
public final class ParticleRendering {
private ParticleRendering() {}
/** Size factor for a particle, 1 for unchanged */
@FunctionalInterface
public interface RenderScale {
float of(EntityFX fx);
}
private static final RenderScale[] NO_SCALES = new RenderScale[0];
// Copy on write so the per particle read is one volatile load
private static volatile RenderScale[] renderScales = NO_SCALES;
/**
* Scales particles the instancer batches from their fields, without calling {@code renderParticle}. Particles that
* go through {@code renderParticle} need scaling there instead. Every source sees every batched particle and the
* factors multiply, so return 1 for particles that aren't yours.
*/
public static synchronized void addRenderScale(RenderScale source) {
for (RenderScale existing : renderScales) {
if (existing == source) return;
}
final RenderScale[] next = Arrays.copyOf(renderScales, renderScales.length + 1);
next[next.length - 1] = source;
renderScales = next;
}
public static synchronized void removeRenderScale(RenderScale source) {
final RenderScale[] old = renderScales;
for (int i = 0; i < old.length; i++) {
if (old[i] != source) continue;
final RenderScale[] next = new RenderScale[old.length - 1];
System.arraycopy(old, 0, next, 0, i);
System.arraycopy(old, i + 1, next, i, old.length - i - 1);
renderScales = next.length == 0 ? NO_SCALES : next;
return;
}
}
/** Product of every {@link #addRenderScale} source for this particle */
public static float renderScale(EntityFX fx) {
final RenderScale[] sources = renderScales;
if (sources.length == 0) return 1;
float scale = 1;
for (RenderScale source : sources) scale *= source.of(fx);
return scale;
}
/**
* Binds the pack's particle program for particles drawn outside the effect renderer. Nests, pass the token to
* {@link #endParticleDraw}. No-op without a shaderpack.
*/
public static int beginParticleDraw() {
return GbufferPrograms.beginParticles();
}
public static void endParticleDraw(int token) {
GbufferPrograms.endParticles(token);
}
}
@@ -1,4 +0,0 @@
@API(owner = "angelica", provides = "angelica|particles", apiVersion = "1")
package com.gtnewhorizons.angelica.api.particles;
import cpw.mods.fml.common.API;
@@ -1,18 +0,0 @@
package com.gtnewhorizons.angelica.api.shadows;
/**
* Draws extra geometry into the shaderpack shadow map. {@code RenderWorldLastEvent} geometry never reaches it, and TESRs
* only do when the pack shadows block entities. Register with {@link ShadowCasters#register}.
*/
@FunctionalInterface
public interface ShadowCaster {
/**
* Called once per shadow pass per stage, with the shadow modelview loaded and the block entity shadow program bound.
* Positions are camera relative. Restore any GL state you change.
*
* @param stage {@link ShadowStage#SOLID} with the other solid shadows, {@link ShadowStage#TRANSLUCENT} after
* translucent terrain for geometry that should tint light rather than block it
*/
void renderShadow(ShadowStage stage, double cameraX, double cameraY, double cameraZ, float partialTicks);
}
@@ -1,57 +0,0 @@
package com.gtnewhorizons.angelica.api.shadows;
import com.gtnewhorizons.angelica.AngelicaMod;
import net.coderbot.iris.pipeline.ShadowRenderer;
import java.util.concurrent.CopyOnWriteArrayList;
/** {@link ShadowCaster} registry. Render thread only. */
public final class ShadowCasters {
private static final CopyOnWriteArrayList<ShadowCaster> CASTERS = new CopyOnWriteArrayList<>();
private ShadowCasters() {}
public static void register(ShadowCaster caster) {
CASTERS.addIfAbsent(caster);
}
public static void unregister(ShadowCaster caster) {
CASTERS.remove(caster);
}
/** True while the shaderpack shadow pass is drawing */
public static boolean isRenderingShadows() {
return ShadowRenderer.ACTIVE;
}
/**
* The pack's {@code shadowBlockEntities}. A caster drawing its own block entities should skip them when this is
* false. Only valid during the shadow pass.
*/
public static boolean shadowsBlockEntities() {
return ShadowRenderer.BLOCK_ENTITIES;
}
/** True when the shadow pass draws light emitting block entities, even with {@link #shadowsBlockEntities} off */
public static boolean shadowsLightBlockEntities() {
return ShadowRenderer.LIGHT_BLOCK_ENTITIES;
}
public static boolean hasCasters() {
return !CASTERS.isEmpty();
}
/** Called by the shadow renderer. A caster that throws is removed. */
public static void renderAll(ShadowStage stage, double cameraX, double cameraY, double cameraZ,
float partialTicks) {
for (ShadowCaster caster : CASTERS) {
try {
caster.renderShadow(stage, cameraX, cameraY, cameraZ, partialTicks);
} catch (Throwable t) {
AngelicaMod.LOGGER.error("Shadow caster {} threw, removing it", caster, t);
CASTERS.remove(caster);
}
}
}
}
@@ -1,8 +0,0 @@
package com.gtnewhorizons.angelica.api.shadows;
public enum ShadowStage {
/** After the shadow pass's entities and block entities */
SOLID,
/** After translucent terrain, only when the pack draws translucent shadows */
TRANSLUCENT
}
@@ -1,4 +0,0 @@
@API(owner = "angelica", provides = "angelica|shadows", apiVersion = "1")
package com.gtnewhorizons.angelica.api.shadows;
import cpw.mods.fml.common.API;
@@ -1,105 +0,0 @@
package com.gtnewhorizons.angelica.api.terrain;
import com.gtnewhorizons.angelica.rendering.celeritas.VertexArrayQuadView;
import com.gtnewhorizons.angelica.rendering.celeritas.light.LightDataCache;
import com.gtnewhorizons.angelica.rendering.celeritas.light.VanillaDiffuseProvider;
import net.minecraft.client.Minecraft;
import net.minecraft.world.IBlockAccess;
import org.embeddedt.embeddium.impl.model.light.LightPipeline;
import org.embeddedt.embeddium.impl.model.light.data.LightDataAccess;
import org.embeddedt.embeddium.impl.model.light.data.QuadLightData;
import org.embeddedt.embeddium.impl.model.light.flat.FlatLightPipeline;
import org.embeddedt.embeddium.impl.model.light.smooth.SmoothLightPipeline;
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFlags;
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
import org.embeddedt.embeddium.impl.util.QuadUtil;
/**
* Per vertex AO and lightmap for block quads, using the chunk mesher's light pipelines over any block access.
* <p>
* Not thread safe, use one per thread. Light data is cached per 16 block region and doesn't see world changes, so call
* {@link #reset} before each bake.
*/
public final class TerrainLighter {
private final LightDataCache cache = new LightDataCache();
private final SmoothLightPipeline smooth;
private final FlatLightPipeline flat;
private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad();
private final VertexArrayQuadView quad = new VertexArrayQuadView(vertices);
private final QuadLightData out = new QuadLightData();
private int regionX = Integer.MIN_VALUE, regionY, regionZ;
// Last fluid quad, to detect the flipped back face vanilla emits right after it
private ModelQuadFacing fluidLightFace;
private final float[] fluidXyz = new float[12];
private static final int[] REVERSED = { 0, 3, 2, 1 };
public TerrainLighter(IBlockAccess world) {
cache.setWorld(world);
smooth = new SmoothLightPipeline(cache, VanillaDiffuseProvider.INSTANCE, true);
flat = new FlatLightPipeline(cache, VanillaDiffuseProvider.INSTANCE, true);
}
/** Drops cached light data */
public void reset() {
regionX = Integer.MIN_VALUE;
fluidLightFace = null;
}
/**
* Lights one quad of the block at x, y, z.
*
* @param xyz corners as x y z in vertex order, in the block access's coordinates
* @param shade multiply in directional face shading, false for AO only
* @param fluid the block is a fluid (see {@link TerrainRendering#isFluid}). Pass its quads in emit order. The
* mesher gives fluids no AO, so only use the light
* @param brightness out, per vertex AO (times shading if requested), 0 to 1
* @param light out, per vertex lightmap, {@code sky << 16 | block}, each 0-240
*/
public void light(float[] xyz, int x, int y, int z, boolean shade, boolean fluid, float[] brightness,
int[] light) {
final int rx = x & ~15, ry = y & ~15, rz = z & ~15;
if (rx != regionX || ry != regionY || rz != regionZ) {
regionX = rx;
regionY = ry;
regionZ = rz;
cache.reset(rx, ry, rz);
}
smooth.reset();
flat.reset();
for (int i = 0; i < 4; i++) {
vertices[i].x = xyz[i * 3];
vertices[i].y = xyz[i * 3 + 1];
vertices[i].z = xyz[i * 3 + 2];
}
// The mesher lights a fluid's flipped back face from the front face's side
final boolean flippedCopy = fluid && fluidLightFace != null && isReversedFluidQuad(xyz);
quad.setup(QuadUtil.calculateNormal(vertices), x, y, z, fluid ? ModelQuadFlags.IS_VANILLA_SHADED : 0,
flippedCopy ? fluidLightFace : null);
// Same rule as the mesher: smooth lighting on and the block isn't a light source
final boolean smoothLighting = Minecraft.getMinecraft().gameSettings.ambientOcclusion != 0
&& LightDataAccess.unpackLU(cache.get(x, y, z)) == 0;
final LightPipeline pipeline = smoothLighting ? smooth : flat;
pipeline.calculate(quad, x, y, z, out, quad.getCullFace(), quad.getLightFace(), shade, true);
System.arraycopy(out.br, 0, brightness, 0, 4);
System.arraycopy(out.lm, 0, light, 0, 4);
if (fluid && !flippedCopy) {
fluidLightFace = quad.getLightFace();
System.arraycopy(xyz, 0, fluidXyz, 0, 12);
} else if (!fluid) {
fluidLightFace = null;
}
}
private boolean isReversedFluidQuad(float[] xyz) {
for (int i = 0; i < 4; i++) {
final int src = REVERSED[i] * 3;
if (xyz[i * 3] != fluidXyz[src] || xyz[i * 3 + 1] != fluidXyz[src + 1]
|| xyz[i * 3 + 2] != fluidXyz[src + 2]) {
return false;
}
}
return true;
}
}
@@ -1,230 +0,0 @@
package com.gtnewhorizons.angelica.api.terrain;
import com.gtnewhorizons.angelica.AngelicaMod;
import com.gtnewhorizons.angelica.api.shaders.ShaderPacks;
import com.gtnewhorizons.angelica.glsm.ffp.FfpExtendedAttribs;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import com.gtnewhorizons.angelica.rendering.BlockMaterialAttribute;
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
import com.prupe.mcpatcher.mal.block.RenderBlocksUtils;
import me.jellysquid.mods.sodium.client.gui.options.named.MipmapGeneration;
import net.coderbot.iris.block_rendering.BlockMaterialMapping;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.gl.shader.ProgramCreator;
import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.pipeline.WorldRenderingPhase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockDynamicLiquid;
import net.minecraft.block.BlockStaticLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import org.embeddedt.embeddium.impl.render.chunk.terrain.material.parameters.AlphaCutoffParameter;
import java.util.Map;
/**
* For mods that bake block geometry outside the chunk renderer and want it to match terrain, including under a
* shaderpack (terrain programs, block.properties materials, the pack's AO and directional shading).
* <p>
* Begin/end pairs nest and are render thread only. Call the end in a finally block.
*/
public final class TerrainRendering {
private static int terrainDrawDepth;
private static boolean terrainDrawPushed;
private TerrainRendering() {}
/**
* Uses the pack's terrain program until {@link #endTerrainDraw} instead of the current phase's. The outermost call
* picks the program. No-op without a shaderpack.
*
* @param translucent true for render pass 1, false for solid and cutout
*/
public static void beginTerrainDraw(boolean translucent) {
if (terrainDrawDepth++ > 0) return;
terrainDrawPushed = ShaderPacks.isInUse();
if (terrainDrawPushed) {
GbufferPrograms.pushOverridePhase(translucent ? WorldRenderingPhase.TERRAIN_TRANSLUCENT : WorldRenderingPhase.TERRAIN_CUTOUT);
}
}
public static void endTerrainDraw() {
if (terrainDrawDepth == 0) return;
if (--terrainDrawDepth > 0) return;
if (terrainDrawPushed) GbufferPrograms.popOverridePhase();
terrainDrawPushed = false;
}
/** Called at the start of each frame. Closes a terrain draw that was never ended. */
public static void resetForFrame() {
if (terrainDrawDepth == 0) return;
AngelicaMod.LOGGER.warn("A terrain draw was never ended, ending it");
if (terrainDrawPushed) GbufferPrograms.popOverridePhase();
terrainDrawPushed = false;
terrainDrawDepth = 0;
}
/** True when the pack wants AO in vertex color alpha instead of multiplied into the color */
public static boolean usesSeparateAo() {
return ShaderPacks.isInUse() && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
}
/**
* True when the chunk mesher relights terrain with the pipeline {@link TerrainLighter} uses. Only faces marked by
* {@link #isSmoothLit} (and fluids under a pack) are relit, the rest keep their baked light.
*/
public static boolean usesTerrainLighting() {
return ShaderPacks.isInUse() || BlockRenderingSettings.INSTANCE.shouldUseSeparateAo()
|| ClientProxy.options().quality.useCeleritasSmoothLighting;
}
/**
* Alpha cutoff terrain uses for a render pass without a shaderpack. Pass 0 is 0.5 (vanilla uses 0.1), pass 1
* follows the mipmap setting.
*/
public static float getAlphaCutoff(int pass) {
return pass == 0 ? AlphaCutoffParameter.HALF.cutoff() : MipmapGeneration.alphaFloorCutoff().cutoff();
}
/** True when the pack does its own directional shading, so terrain is baked without vanilla's face shading */
public static boolean disablesDirectionalShading() {
return ShaderPacks.isInUse() && BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading();
}
/**
* Forge render pass the pack moves this block to (e.g. {@code layer.translucent}), -1 if not moved or no pack. The
* mesher only draws a moved block in that pass.
*/
public static int getRenderPassOverride(Block block) {
if (!ShaderPacks.isInUse()) return -1;
final Map<Block, BlockRenderLayer> overrides = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
if (overrides == null) return -1;
final BlockRenderLayer layer = overrides.get(block);
return layer == null ? -1 : layer.toVanillaPass();
}
/** The pack's block.properties id, -1 if unmapped or no pack */
public static int getBlockMaterialId(Block block, int metadata) {
return ShaderPacks.isInUse() ? BlockMaterialAttribute.blockMaterialId(block, metadata) : -1;
}
/**
* The block.properties id the mesher gives this block at this position. Unlike the plain lookup it falls back to a
* fluid's still or flowing twin, applies snowy entries and resolves double plant tops. -1 if unmapped or no pack.
*/
public static int getBlockMaterialId(IBlockAccess world, Block block, int metadata, int x, int y, int z) {
if (!ShaderPacks.isInUse()) return -1;
if (isFluid(block)) {
int id = BlockMaterialAttribute.blockMaterialId(block, metadata);
if (id == -1) {
Block twin = null;
if (block instanceof BlockStaticLiquid) twin = Block.getBlockById(Block.getIdFromBlock(block) - 1);
else if (block instanceof BlockDynamicLiquid) twin = Block.getBlockById(Block.getIdFromBlock(block) + 1);
if (twin != null) id = BlockMaterialAttribute.blockMaterialId(twin, metadata);
}
return id;
}
int effectiveMeta = metadata;
if (BlockRenderingSettings.INSTANCE.hasSnowyEntries()
&& BlockRenderingSettings.INSTANCE.getSnowyBlocks().contains(block)
&& RenderBlocksUtils.isSnowCovered(world, x, y, z)) {
effectiveMeta |= BlockMaterialMapping.SNOWY_META_BIT;
} else if (block instanceof BlockDoublePlant doublePlant && BlockDoublePlant.func_149887_c(metadata)) {
effectiveMeta = 0x8 | (doublePlant.func_149885_e(world, x, y, z) & 7);
}
return BlockMaterialAttribute.blockMaterialId(block, effectiveMeta);
}
/** Water or lava material, what the mesher treats as a fluid for lighting and material ids */
public static boolean isFluid(Block block) {
final Material material = block.getMaterial();
return material == Material.water || material == Material.lava;
}
/**
* Makes RenderBlocks draw into this tessellator like it does for the chunk mesher. Blocks that would take vanilla's
* smooth lighting path are drawn flat and marked (see {@link #isSmoothLit}) so they can be relit with
* {@link TerrainLighter}. Only applies when {@link #usesTerrainLighting} would. Turn it off in a finally block.
*/
public static void setMeshing(Tessellator tessellator, boolean meshing) {
((StateAwareTessellator) tessellator).angelica$setCeleritasMeshing(meshing);
}
/** True while the vertices being added are from a face the mesher would relight (see {@link #setMeshing}) */
public static boolean isSmoothLit(Tessellator tessellator) {
return ((StateAwareTessellator) tessellator).angelica$isAppliedAo();
}
/** True while the vertices being added should get no directional shading */
public static boolean hasNoDirectionalShading(Tessellator tessellator) {
return ((StateAwareTessellator) tessellator).angelica$isNoDirectionalShading();
}
/**
* Attribute location of mc_Entity. Two shorts per vertex, the material id and 0 (1 for fluids). Only bind it while a
* shaderpack is in use.
*/
public static int getMaterialAttributeLocation() {
return ProgramCreator.MC_ENTITY;
}
/**
* Attribute location of mc_midTexCoord, the centre of the vertex's sprite. Two floats per vertex. Only bind it while
* a shaderpack is in use, between {@link #beginOwnExtendedAttributes} and {@link #endOwnExtendedAttributes}.
*/
public static int getMidTexCoordAttributeLocation() {
return ProgramCreator.MC_MID_TEX_COORD;
}
/** Attribute location of at_tangent, four floats per vertex (w is handedness). Same rules as mc_midTexCoord. */
public static int getTangentAttributeLocation() {
return ProgramCreator.AT_TANGENT;
}
/**
* Stops Angelica generating mc_midTexCoord and at_tangent for draws until {@link #endOwnExtendedAttributes}, for
* draws that supply their own.
*/
public static void beginOwnExtendedAttributes() {
FfpExtendedAttribs.beginInternalDraw();
}
public static void endOwnExtendedAttributes() {
FfpExtendedAttribs.endInternalDraw();
}
/**
* Records the sprites used on this thread until closed. Angelica only animates sprites drawn this frame, so call
* {@link SpriteCapture#markUsed} each frame the baked geometry is drawn. Close on the same thread.
*/
public static SpriteCapture captureSprites() {
return new SpriteCapture(AnimationsRenderUtils.captureSprites());
}
/** See {@link #captureSprites}. */
public static final class SpriteCapture implements AutoCloseable {
private final AnimationsRenderUtils.SpriteCapture capture;
private SpriteCapture(AnimationsRenderUtils.SpriteCapture capture) {
this.capture = capture;
}
/** Marks the recorded sprites as drawn this frame */
public void markUsed() {
capture.markUsed();
}
/** Stops recording, keeping what was recorded */
@Override
public void close() {
capture.close();
}
}
}
@@ -1,4 +0,0 @@
@API(owner = "angelica", provides = "angelica|terrain", apiVersion = "1")
package com.gtnewhorizons.angelica.api.terrain;
import cpw.mods.fml.common.API;
@@ -1,50 +0,0 @@
package com.gtnewhorizons.angelica.api.world;
import com.gtnewhorizons.angelica.AngelicaMod;
import net.minecraftforge.client.MinecraftForgeClient;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Draw hook inside the world pass for mod geometry. {@code RenderWorldLastEvent} fires after the pack's composite and
* final passes, so geometry drawn there gets none of its lighting, fog or shadows.
* <p>
* Drawers run right after block entities, once per Forge render pass, with the block entity program bound like a TESR.
* The modelview is the camera's, so draw relative to {@code TileEntityRendererDispatcher.staticPlayerX/Y/Z}. Restore any
* GL state you change. Render thread only.
*/
public final class WorldDrawStage {
@FunctionalInterface
public interface Drawer {
/** @param pass Forge render pass, 0 for solid and cutout, 1 for translucent */
void draw(int pass, float partialTicks);
}
private static final CopyOnWriteArrayList<Drawer> drawers = new CopyOnWriteArrayList<>();
private WorldDrawStage() {}
public static void register(Drawer drawer) {
drawers.addIfAbsent(drawer);
}
public static void unregister(Drawer drawer) {
drawers.remove(drawer);
}
/** Called by the world renderer after block entities. A drawer that throws is removed. */
public static void run(float partialTicks) {
if (drawers.isEmpty()) return;
final int pass = MinecraftForgeClient.getRenderPass();
for (Drawer drawer : drawers) {
try {
drawer.draw(pass, partialTicks);
} catch (Throwable t) {
drawers.remove(drawer);
AngelicaMod.LOGGER.error("World drawer {} threw, removing it", drawer, t);
}
}
}
}
@@ -1,4 +0,0 @@
@API(owner = "angelica", provides = "angelica|world", apiVersion = "1")
package com.gtnewhorizons.angelica.api.world;
import cpw.mods.fml.common.API;
@@ -505,6 +505,8 @@ public enum Mixins implements IMixins {
, "celeritas.biome_blending.MixinBlockLiquid"
, "celeritas.biome_blending.MixinWorld"
, "celeritas.biome_blending.MixinRenderBlocks"
, "celeritas.terrain.MixinRenderBlocks_HiddenFluidTops"
, "celeritas.terrain.MixinRenderBlockFluid_HiddenFluidTops"
, "celeritas.threading.MixinForgeHooksClient"
, "celeritas.threading.MixinChunkJobTyped"
, "celeritas.terrain.MixinChunk"
@@ -15,15 +15,6 @@ public interface StateAwareTessellator {
void angelica$setAppliedAo(boolean flag);
void angelica$setNoDirectionalShading(boolean flag);
/// The state the next vertex gets. False for tessellators that don't track it.
default boolean angelica$isAppliedAo() {
return false;
}
default boolean angelica$isNoDirectionalShading() {
return false;
}
/// Sets whether we're doing terrain meshing as part of celeritas -- collects additional information.
///
/// Enables per-vertex AO state collection into [#angelica$getVertexStates()].
@@ -3,7 +3,6 @@ package com.gtnewhorizons.angelica.rendering.celeritas;
import java.util.Collection;
import java.util.List;
import com.gtnewhorizons.angelica.api.world.WorldDrawStage;
import com.gtnewhorizons.angelica.compat.bop.FogBiomeCache;
import com.gtnewhorizons.angelica.render.CloudRenderer;
import net.minecraft.client.Minecraft;
@@ -541,8 +540,6 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
try {
final int rendered = renderBlockEntities(partialTicks);
if (Tracy.ENABLED) Tracy.plotInt(P_BLOCK_ENTITIES_RENDERED, rendered);
// Inside the block entity phase so the pack lights mod geometry
WorldDrawStage.run(partialTicks);
} finally {
if (Iris.enabled) GbufferPrograms.endBlockEntities();
}
@@ -0,0 +1,72 @@
package com.gtnewhorizons.angelica.rendering.celeritas;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.BlockFluidBase;
public final class HiddenFluidTops {
public static final int SEARCH_RADIUS = 2;
private static final int SEARCH_WIDTH = 2 * SEARCH_RADIUS + 1;
private static final int BLOCKED = 0;
private static final int COVERED = 1;
private static final int OPEN = 2;
private static final int[] STEP_X = {1, -1, 0, 0};
private static final int[] STEP_Z = {0, 0, 1, -1};
private HiddenFluidTops() {}
public static boolean isTopHidden(IBlockAccess world, Block fluid, int x, int y, int z, int topOffset) {
if (world.getBlock(x, y, z) != fluid) return false;
if (!isFullLevel(world, fluid, x, y, z) || !world.getBlock(x, y + topOffset, z).isOpaqueCube()) return false;
return !hasOpeningNearby(world, fluid, x, y, z, topOffset);
}
private static boolean hasOpeningNearby(IBlockAccess world, Block fluid, int x, int y, int z, int topOffset) {
int covered = 1 << (SEARCH_RADIUS + SEARCH_RADIUS * SEARCH_WIDTH);
int checked = 0;
int blocked = 0;
int unchecked;
while ((unchecked = covered & ~checked) != 0) {
final int cell = Integer.numberOfTrailingZeros(unchecked);
checked |= 1 << cell;
final int cellX = cell % SEARCH_WIDTH;
final int cellZ = cell / SEARCH_WIDTH;
for (int step = 0; step < 4; step++) {
final int nextX = cellX + STEP_X[step];
final int nextZ = cellZ + STEP_Z[step];
if (nextX < 0 || nextZ < 0 || nextX >= SEARCH_WIDTH || nextZ >= SEARCH_WIDTH) continue;
final int bit = 1 << (nextX + nextZ * SEARCH_WIDTH);
if (((covered | blocked) & bit) != 0) continue;
final int kind = classify(world, fluid, x + nextX - SEARCH_RADIUS, y, z + nextZ - SEARCH_RADIUS, topOffset);
if (kind == OPEN) return true;
if (kind == COVERED) {
covered |= bit;
} else {
blocked |= bit;
}
}
}
return false;
}
private static int classify(IBlockAccess world, Block fluid, int x, int y, int z, int topOffset) {
final Block block = world.getBlock(x, y, z);
if (block.isOpaqueCube()) return BLOCKED;
if (!isSameFluid(fluid, block)) return OPEN;
final Block blockOnTop = world.getBlock(x, y + topOffset, z);
if (isSameFluid(fluid, blockOnTop)) return BLOCKED;
return blockOnTop.isOpaqueCube() && isFullLevel(world, fluid, x, y, z) ? COVERED : OPEN;
}
private static boolean isSameFluid(Block fluid, Block other) {
if (fluid instanceof BlockLiquid) return other instanceof BlockLiquid && other.getMaterial() == fluid.getMaterial();
return other == fluid;
}
private static boolean isFullLevel(IBlockAccess world, Block fluid, int x, int y, int z) {
final int meta = world.getBlockMetadata(x, y, z);
return fluid instanceof BlockFluidBase forgeFluid ? meta == forgeFluid.getMaxRenderHeightMeta() : meta == 0;
}
}
@@ -1,6 +1,5 @@
package com.gtnewhorizons.angelica.rendering.particles;
import com.gtnewhorizons.angelica.api.particles.ParticleRendering;
import com.gtnewhorizons.angelica.rendering.RenderFailures;
import com.gtnewhorizons.angelica.client.rendering.DeferredDrawBatcher;
import com.gtnewhorizons.angelica.glsm.GLSMAttribStack;
@@ -139,8 +138,6 @@ public final class ParticleInstancer {
STATE.sample();
SCRATCH.brightness = runTessellator.brightness;
if (!descriptor.describe(fx, partialTicks, SCRATCH, STATE)) return;
// Mod size factor, the capture path below gets it through renderParticle
SCRATCH.half *= ParticleRendering.renderScale(fx);
runTessellator.color = SCRATCH.colorABGR;
runTessellator.hasColor = true;
@@ -585,6 +585,17 @@ public class SodiumGameOptionPages {
.build());
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
.setName(I18n.format("sodium.options.use_hidden_fluid_culling.name"))
.setTooltip(I18n.format("sodium.options.use_hidden_fluid_culling.tooltip"))
.setControl(TickBoxControl::new)
.setImpact(OptionImpact.LOW)
.setBinding((opts, value) -> opts.performance.useHiddenFluidCulling = value, opts -> opts.performance.useHiddenFluidCulling)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build())
.build());
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, angelicaOpts)
.setName(I18n.format("options.angelica.parallelAtlasDecode"))
@@ -254,6 +254,7 @@ public class SodiumGameOptions {
public boolean sectionGatedTesrCulling = true;
public boolean useFogOcclusion = true;
public boolean useBlockFaceCulling = true;
public boolean useHiddenFluidCulling = true;
public boolean useCompactVertexFormat = true;
public TranslucencyMode translucencyMode = TranslucencyMode.FAST;
public Boolean translucencySorting;
@@ -1,8 +1,6 @@
package net.coderbot.iris.pipeline;
import com.google.common.collect.ImmutableList;
import com.gtnewhorizons.angelica.api.shadows.ShadowCasters;
import com.gtnewhorizons.angelica.api.shadows.ShadowStage;
import com.gtnewhorizons.angelica.compat.mojang.Camera;
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
@@ -101,8 +99,6 @@ public class ShadowRenderer {
public static final List<List<TileEntity>> visibleTileEntities = new ArrayList<>();
public static final List<List<TileEntity>> globalTileEntities = new ArrayList<>();
public static boolean ACTIVE = false;
// Pack's block entity shadow settings for the current pass, read by ShadowCasters
public static boolean BLOCK_ENTITIES = true, LIGHT_BLOCK_ENTITIES = true;
public static Frustrum FRUSTUM;
@@ -873,24 +869,6 @@ public class ShadowRenderer {
profiler.endSection();
}
private void renderShadowCasters(ShadowStage stage, MatrixStack modelView, double cameraX, double cameraY, double cameraZ, float partialTicks) {
if (!ShadowCasters.hasCasters()) return;
try (GLDebug.Scope s = GLDebug.scope("shadow:casters")) {
GLSMMatrices.glPushMatrix();
MODELVIEW_BUFFER.clear().rewind();
modelView.peek().getModel().get(MODELVIEW_BUFFER);
GLSMMatrices.glLoadMatrix(MODELVIEW_BUFFER);
GbufferPrograms.beginBlockEntities();
GbufferPrograms.setBlockEntityDefaults();
try {
ShadowCasters.renderAll(stage, cameraX, cameraY, cameraZ, partialTicks);
} finally {
GbufferPrograms.endBlockEntities();
GLSMMatrices.glPopMatrix();
}
}
}
public void renderShadows(EntityRenderer levelRenderer, Camera playerCamera) {
final Minecraft mc = Minecraft.getMinecraft();
final RenderGlobal rg = mc.renderGlobal;
@@ -911,8 +889,6 @@ public class ShadowRenderer {
}
ACTIVE = true;
BLOCK_ENTITIES = shouldRenderBlockEntities;
LIGHT_BLOCK_ENTITIES = shouldRenderLightBlockEntities;
CURRENT_TARGETS = this.targets;
// ACTIVE routes clipRenderersByFrustum into the shadow path; a leak would send every main pass there.
try {
@@ -1051,9 +1027,6 @@ public class ShadowRenderer {
}
}
// Not gated on shadowBlockEntities, casters can stand in for terrain
renderShadowCasters(ShadowStage.SOLID, modelView, entityX, entityY, entityZ, tickDelta);
profiler.endStartSection("iris_shadow_draw_entities");
// NB: Don't try to draw the translucent parts of entities afterwards. It'll cause problems since some
@@ -1071,7 +1044,6 @@ public class ShadowRenderer {
try (GLDebug.Scope s = GLDebug.scope("shadow:translucent")) {
rg.sortAndRender(mc.renderViewEntity, 1, playerCamera.getPartialTicks());
}
renderShadowCasters(ShadowStage.TRANSLUCENT, modelView, entityX, entityY, entityZ, tickDelta);
}
// Note: Apparently tripwire isn't rendered in the shadow pass.
@@ -91,6 +91,8 @@ sodium.options.animate_only_visible_textures.name=Animate Only Visible Textures
sodium.options.animate_only_visible_textures.tooltip=If enabled, only animated textures determined to be visible will be updated. This can provide a significant boost to frame rates on some hardware, especially with heavier resource packs. If you experience issues with some textures not being animated, try disabling this option.
sodium.options.translucency_mode.name=Translucency Sorting
sodium.options.translucency_mode.tooltip=Fast sorts translucent terrain (water, stained glass, ice) and translucent tile entities back to front so overlapping layers draw correctly. Fancy also draws translucent terrain, translucent tile entities, particles, weather and clouds into separate layers that blend correctly over one another; it uses more video memory and GPU time and has no effect with a shader pack. Off is fastest but causes layering artifacts. Changing this reloads chunks.
sodium.options.use_hidden_fluid_culling.name=Fluid & Gas Culling
sodium.options.use_hidden_fluid_culling.tooltip=Culls quads from fluids and gases that the player can't typically see.
sodium.options.block_entities_before_translucent_terrain.name=Tile Entities Before Translucent Terrain
sodium.options.block_entities_before_translucent_terrain.tooltip=If enabled, translucent tile entities are drawn before translucent terrain (water, stained glass, ice), so that the latter does not hide the former behind it. Tile Entities in front of terrain may hide the terrain, and glows in front of terrain may appear behind it. Always on with Fancy translucency sorting.
sodium.options.cpu_render_ahead_limit.name=CPU Render-Ahead Limit
@@ -0,0 +1,32 @@
package com.gtnewhorizons.angelica.mixins.early.celeritas.terrain;
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
import com.gtnewhorizons.angelica.experimental.surround.Surround;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
import com.gtnewhorizons.angelica.rendering.celeritas.HiddenFluidTops;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.RenderBlockFluid;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(value = RenderBlockFluid.class, remap = false)
public class MixinRenderBlockFluid_HiddenFluidTops {
@Surround(method = "renderWorldBlock",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IBlockAccess;getBlock(III)Lnet/minecraft/block/Block;", ordinal = 0, remap = true),
remap = false)
private void angelica$checkFluidTop() {}
@Surround.Return
private Block angelica$hideFluidTop(Block blockOnTop, IBlockAccess world, int x, int topY, int z,
@Surround.Local(argsOnly = true) Block fluid, @Surround.Local(argsOnly = true, ordinal = 1) int y) {
if (blockOnTop != fluid && ClientProxy.options().performance.useHiddenFluidCulling
&& ((StateAwareTessellator) TessellatorManager.get()).angelica$isCeleritasMeshing()
&& HiddenFluidTops.isTopHidden(world, fluid, x, y, z, topY - y)) {
return fluid;
}
return blockOnTop;
}
}
@@ -0,0 +1,30 @@
package com.gtnewhorizons.angelica.mixins.early.celeritas.terrain;
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
import com.gtnewhorizons.angelica.experimental.surround.Surround;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
import com.gtnewhorizons.angelica.rendering.celeritas.HiddenFluidTops;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(RenderBlocks.class)
public class MixinRenderBlocks_HiddenFluidTops {
@Surround(method = "renderBlockLiquid", at = @At(value = "INVOKE",
target = "Lnet/minecraft/block/Block;shouldSideBeRendered(Lnet/minecraft/world/IBlockAccess;IIII)Z", ordinal = 0))
private void angelica$checkFluidTop() {}
@Surround.Return
private boolean angelica$hideFluidTop(boolean renderTop, Block fluid, IBlockAccess world, int x, int y, int z, int side) {
if (renderTop && ClientProxy.options().performance.useHiddenFluidCulling
&& ((StateAwareTessellator) TessellatorManager.get()).angelica$isCeleritasMeshing()
&& HiddenFluidTops.isTopHidden(world, fluid, x, y - 1, z, 1)) {
return false;
}
return renderTop;
}
}
@@ -15,6 +15,7 @@ import com.gtnewhorizons.angelica.rendering.RenderingState;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasSetup;
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasWorldRenderer;
import com.gtnewhorizons.angelica.rendering.celeritas.HiddenFluidTops;
import com.gtnewhorizons.angelica.rendering.tesr.ModelPartBatcher;
import com.gtnewhorizons.angelica.rendering.tesr.TesrBatchRenderer;
import com.gtnewhorizons.angelica.rendering.translucency.TranslucencyLayers;
@@ -263,6 +264,12 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
this.celeritas$renderer.scheduleRebuildForBlockArea(minX, minY, minZ, maxX, maxY, maxZ, false);
}
@Redirect(method = "markBlockForUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;markBlocksForUpdate(IIIIII)V"))
private void celeritas$scheduleBlockChangeRebuild(RenderGlobal self, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
final int extraMargin = ClientProxy.options().performance.useHiddenFluidCulling ? HiddenFluidTops.SEARCH_RADIUS - 1 : 0;
this.celeritas$renderer.scheduleRebuildForBlockArea(minX - extraMargin, minY, minZ - extraMargin, maxX + extraMargin, maxY, maxZ + extraMargin, false);
}
@Unique
public void angelica$reload() {
CeleritasSetup.ensureInitialized();
@@ -103,16 +103,6 @@ public class MixinTessellator implements StateAwareTessellator, BiomeBlendTessel
this.angelica$noDirectionalShading = flag;
}
@Override
public boolean angelica$isAppliedAo() {
return this.appliedAo;
}
@Override
public boolean angelica$isNoDirectionalShading() {
return this.angelica$noDirectionalShading;
}
@Override
public int[] angelica$getVertexStates() {
return this.vertexStates.elements();
@@ -1,6 +1,5 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import com.gtnewhorizons.angelica.api.terrain.TerrainRendering;
import com.gtnewhorizons.angelica.compat.mojang.Camera;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.experimental.surround.Surround;
@@ -56,8 +55,6 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
SystemTimeUniforms.TIMER.beginFrame(System.nanoTime());
Program.unbind();
// Close any terrain draw a mod left open last frame
TerrainRendering.resetForFrame();
mc.mcProfiler.startSection("iris_prepare_pipeline");
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimensionName());