Render pass and state stack optimizations (#2124)

This commit is contained in:
Jason Mitchell authored and GitHub committed 2026-09-21 20:52:51 -07:00
1 parent 87c83f0645
commit 9dd60f6a75
151 files changed
+9242 -3156

No files matched your search

@@ -1,7 +1,9 @@
package net.coderbot.batchedentityrendering.impl;
import com.gtnewhorizons.angelica.rendering.RenderFailures;
import com.gtnewhorizons.angelica.compat.mojang.RenderLayer;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.StateSet;
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@@ -12,7 +14,6 @@ import net.coderbot.iris.pipeline.WorldRenderingPhase;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import org.joml.Vector4fc;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import java.util.ArrayList;
@@ -22,8 +23,6 @@ import java.util.Map;
/** Collects geometry into per-RenderLayer buffers during a pass and draws it all at endBatch, one state bracket per layer. Based on Iris's FullyBufferedMultiBufferSource */
public class AngelicaBufferSource implements Groupable {
public static final int SAVED_STATE_BITS = GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_CURRENT_BIT | GL11.GL_LIGHTING_BIT | GL11.GL_TEXTURE_BIT;
private static final int NUM_BUFFERS = 32;
public enum GroupIdKind { BLOCK_ENTITY, ENTITY }
@@ -43,7 +42,7 @@ public class AngelicaBufferSource implements Groupable {
private boolean prepared;
private final List<RenderLayer> order = new ArrayList<>();
private boolean stateSaved;
private int drawStateDepth = -1;
private boolean anyIdSet;
private GroupIdKind idKind = GroupIdKind.BLOCK_ENTITY;
@@ -113,7 +112,6 @@ public class AngelicaBufferSource implements Groupable {
}
}
affinities.clear();
stateSaved = false;
anyIdSet = false;
}
@@ -129,13 +127,18 @@ public class AngelicaBufferSource implements Groupable {
public void endBatchWithType(TransparencyType type, LayerDrawHook hook) {
ensurePrepared();
int keep = 0;
for (int i = 0, n = order.size(); i < n; i++) {
final RenderLayer layer = order.get(i);
if (getTransparencyType(layer) != type) {
order.set(keep++, layer);
continue;
try {
for (int i = 0, n = order.size(); i < n; i++) {
final RenderLayer layer = order.get(i);
if (getTransparencyType(layer) != type) {
order.set(keep++, layer);
continue;
}
drawLayer(layer, hook);
}
drawLayer(layer, hook);
} catch (Throwable t) {
discardAfterFailure(t);
throw t;
}
for (int i = order.size() - 1; i >= keep; i--) {
order.remove(i);
@@ -144,15 +147,20 @@ public class AngelicaBufferSource implements Groupable {
public void endBatch(LayerDrawHook hook) {
ensurePrepared();
for (int i = 0, n = order.size(); i < n; i++) {
drawLayer(order.get(i), hook);
try {
for (int i = 0, n = order.size(); i < n; i++) {
drawLayer(order.get(i), hook);
}
} catch (Throwable t) {
discardAfterFailure(t);
throw t;
}
order.clear();
finish();
}
public void pauseBatch() {
releaseAttribState();
restoreDrawState();
clearCurrentId();
}
@@ -161,10 +169,10 @@ public class AngelicaBufferSource implements Groupable {
finish();
}
private void releaseAttribState() {
if (stateSaved) {
GLStateManager.glPopAttrib();
stateSaved = false;
private void restoreDrawState() {
if (drawStateDepth >= 0) {
GLStateManager.popStateTo(drawStateDepth);
drawStateDepth = -1;
}
}
@@ -186,17 +194,42 @@ public class AngelicaBufferSource implements Groupable {
final boolean hasDynamic = segments != null && !segments.isEmpty();
final boolean hasRetained = hook != null && hook.hasDraws(layer);
if (!hasDynamic && !hasRetained) return;
if (!stateSaved) {
stateSaved = true;
GLStateManager.glPushAttrib(SAVED_STATE_BITS);
if (drawStateDepth < 0) {
drawStateDepth = GLStateManager.pushState(StateSet.BATCH);
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
}
layer.startDrawing();
if (hasDynamic) {
anyIdSet = true;
Throwable failure = null;
try {
if (hasDynamic) {
drawDynamic(segments);
}
if (hasRetained) {
anyIdSet = true;
hook.drawLayer(layer);
}
} catch (Throwable t) {
failure = t;
} finally {
try {
layer.endDrawing();
} catch (Throwable cleanup) {
failure = RenderFailures.suppress(failure, cleanup);
}
}
if (failure != null) RenderFailures.rethrow(failure);
}
private void drawDynamic(List<BufferSegment> segments) {
anyIdSet = true;
boolean matrixPushed = false;
SegmentedBufferBuilder.LayerBuffer bound = null;
boolean boundSetup = false;
Throwable failure = null;
try {
GLStateManager.glPushMatrix();
matrixPushed = true;
GLStateManager.glLoadIdentity();
SegmentedBufferBuilder.LayerBuffer bound = null;
final boolean entityKind = effectiveIdKind() == GroupIdKind.ENTITY;
int currentId = Integer.MIN_VALUE;
int currentColor = 0;
@@ -214,21 +247,37 @@ public class AngelicaBufferSource implements Groupable {
}
final SegmentedBufferBuilder.LayerBuffer owner = segment.getOwner();
if (owner != bound) {
if (bound != null) bound.finishDraw();
if (boundSetup) {
bound.finishDraw();
boundSetup = false;
}
bound = null;
owner.uploadForDraw();
owner.setupDraw();
bound = owner;
bound.uploadForDraw();
bound.setupDraw();
boundSetup = true;
}
bound.draw(segment.getFirstVertex(), segment.getVertexCount());
}
if (bound != null) bound.finishDraw();
GLStateManager.glPopMatrix();
} catch (Throwable t) {
failure = t;
} finally {
if (boundSetup) {
try {
bound.finishDraw();
} catch (Throwable cleanup) {
failure = RenderFailures.suppress(failure, cleanup);
}
}
if (matrixPushed) {
try {
GLStateManager.glPopMatrix();
} catch (Throwable cleanup) {
failure = RenderFailures.suppress(failure, cleanup);
}
}
}
if (hasRetained) {
anyIdSet = true;
hook.drawLayer(layer);
}
layer.endDrawing();
if (failure != null) RenderFailures.rethrow(failure);
}
private void clearSegmentLists() {
@@ -238,15 +287,44 @@ public class AngelicaBufferSource implements Groupable {
}
private void finish() {
releaseAttribState();
clearCurrentId();
clearSegmentLists();
final Throwable failure = cleanupAfterBatch(null);
if (failure != null) RenderFailures.rethrow(failure);
}
private Throwable cleanupAfterBatch(Throwable failure) {
try {
restoreDrawState();
} catch (Throwable t) {
failure = RenderFailures.suppress(failure, t);
}
try {
clearCurrentId();
} catch (Throwable t) {
failure = RenderFailures.suppress(failure, t);
}
try {
clearSegmentLists();
} catch (Throwable t) {
failure = RenderFailures.suppress(failure, t);
}
final long now = System.currentTimeMillis();
final long maxIdle = getTargetClearTime();
for (SegmentedBufferBuilder builder : builders) {
builder.resetAndReclaim(now, maxIdle);
for (int i = 0; i < builders.length; i++) {
try {
builders[i].resetAndReclaim(now, maxIdle);
} catch (Throwable t) {
failure = RenderFailures.suppress(failure, t);
}
}
affinities.clear();
renderOrderManager.reset();
prepared = false;
return failure;
}
private void discardAfterFailure(Throwable failure) {
order.clear();
cleanupAfterBatch(failure);
}
public void freeBuffers() {
@@ -324,13 +402,7 @@ public class AngelicaBufferSource implements Groupable {
}
static TransparencyType getTransparencyType(RenderLayer type) {
while (type instanceof WrappableRenderType wrappable) {
type = wrappable.unwrap();
}
if (type instanceof BlendingStateHolder holder) {
return holder.getTransparencyType();
}
return TransparencyType.GENERAL_TRANSPARENT;
return type.getTransparencyType();
}
@Override
@@ -1,10 +0,0 @@
package net.coderbot.batchedentityrendering.impl;
import com.gtnewhorizons.angelica.compat.mojang.RenderLayer;
public interface WrappableRenderType {
/**
* Returns the underlying wrapped RenderType. Might return itself if this RenderType doesn't wrap anything.
*/
RenderLayer unwrap();
}
@@ -7,9 +7,7 @@ import de.odysseus.ithaka.digraph.util.fas.FeedbackArcSet;
import de.odysseus.ithaka.digraph.util.fas.FeedbackArcSetPolicy;
import de.odysseus.ithaka.digraph.util.fas.FeedbackArcSetProvider;
import de.odysseus.ithaka.digraph.util.fas.SimpleFeedbackArcSetProvider;
import net.coderbot.batchedentityrendering.impl.BlendingStateHolder;
import net.coderbot.batchedentityrendering.impl.TransparencyType;
import net.coderbot.batchedentityrendering.impl.WrappableRenderType;
import com.gtnewhorizons.angelica.compat.mojang.RenderLayer;
import java.util.ArrayList;
@@ -33,21 +31,8 @@ public class GraphTranslucencyRenderOrderManager implements RenderOrderManager {
}
}
private static TransparencyType getTransparencyType(RenderLayer type) {
while (type instanceof WrappableRenderType) {
type = ((WrappableRenderType) type).unwrap();
}
if (type instanceof BlendingStateHolder blendingState) {
return blendingState.getTransparencyType();
}
// Default to "generally transparent" if we can't figure it out.
return TransparencyType.GENERAL_TRANSPARENT;
}
public void begin(RenderLayer renderType) {
TransparencyType transparencyType = getTransparencyType(renderType);
TransparencyType transparencyType = renderType.getTransparencyType();
Digraph<RenderLayer> graph = types.get(transparencyType);
graph.add(renderType);
@@ -1,8 +1,6 @@
package net.coderbot.batchedentityrendering.impl.ordering;
import net.coderbot.batchedentityrendering.impl.BlendingStateHolder;
import net.coderbot.batchedentityrendering.impl.TransparencyType;
import net.coderbot.batchedentityrendering.impl.WrappableRenderType;
import com.gtnewhorizons.angelica.compat.mojang.RenderLayer;
import java.util.ArrayList;
@@ -21,21 +19,8 @@ public class TranslucencyRenderOrderManager implements RenderOrderManager {
}
}
private static TransparencyType getTransparencyType(RenderLayer type) {
while (type instanceof WrappableRenderType) {
type = ((WrappableRenderType) type).unwrap();
}
if (type instanceof BlendingStateHolder) {
return ((BlendingStateHolder) type).getTransparencyType();
}
// Default to "generally transparent" if we can't figure it out.
return TransparencyType.GENERAL_TRANSPARENT;
}
public void begin(RenderLayer type) {
renderTypes.get(getTransparencyType(type)).add(type);
renderTypes.get(type.getTransparencyType()).add(type);
}
public void startGroup() {
@@ -1,10 +0,0 @@
package net.coderbot.iris.fantastic;
import com.gtnewhorizons.angelica.compat.mojang.RenderLayer;
import java.util.function.Function;
public interface WrappingMultiBufferSource {
void pushWrappingFunction(Function<RenderLayer, RenderLayer> wrappingFunction);
void popWrappingFunction();
void assertWrapStackEmpty();
}
@@ -52,13 +52,17 @@ public class AlphaTestStorage {
}
}
public static void deferAlphaTestToggle(boolean enabled) {
public static boolean deferAlphaTestToggle(boolean enabled) {
if (enabled == vanillaEnabled) return false;
vanillaEnabled = enabled;
return true;
}
public static void deferAlphaFunc(int function, float reference) {
public static boolean deferAlphaFunc(int function, float reference) {
if (function == vanillaFunction && Float.compare(reference, vanillaReference) == 0) return false;
vanillaFunction = function;
vanillaReference = reference;
return true;
}
public static void restoreAlphaTest() {
@@ -116,82 +116,83 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
@Override
public void drawScreen(int mouseX, int mouseY, float delta) {
GLStateManager.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
if(dirty) {
dirty = false;
this.initGui();
}
handleDroppedFiles();
if (this.mc.theWorld == null) {
super.drawDefaultBackground();
} else if (!this.guiHidden) {
this.drawGradientRect(0, 0, width, height, 0x4F232323, 0x4F232323);
}
if (!this.guiHidden) {
if (optionMenuOpen && this.shaderOptionList != null) {
this.shaderOptionList.drawScreen(mouseX, mouseY, delta);
this.shaderOptionList.drawSearchBox();
} else {
this.shaderPackList.drawScreen(mouseX, mouseY, delta);
try {
if(dirty) {
dirty = false;
this.initGui();
}
}
if (hoveredElement != null) {
hoveredElementCommentTimer++;
} else {
hoveredElementCommentTimer = 0;
}
handleDroppedFiles();
super.drawScreen(mouseX, mouseY, delta);
if (this.mc.theWorld == null) {
super.drawDefaultBackground();
} else if (!this.guiHidden) {
this.drawGradientRect(0, 0, width, height, 0x4F232323, 0x4F232323);
}
if (!this.guiHidden) {
drawCenteredString(this.fontRendererObj, this.title, (int) (this.width * 0.5), 8, 0xFFFFFF);
if (notificationDialog != null && notificationDialogTimer > 0) {
drawCenteredString(this.fontRendererObj, notificationDialog, (int) (this.width * 0.5), 21, 0xFFFFFF);
} else {
if (optionMenuOpen) {
drawCenteredString(this.fontRendererObj, configureTitle(), (int) (this.width * 0.5), 21, 0xFFFFFF);
if (!this.guiHidden) {
if (optionMenuOpen && this.shaderOptionList != null) {
this.shaderOptionList.drawScreen(mouseX, mouseY, delta);
this.shaderOptionList.drawSearchBox();
} else {
drawCenteredString(this.fontRendererObj, selectTitle(), (int) (this.width * 0.5), 21, 0xFFFFFF);
this.shaderPackList.drawScreen(mouseX, mouseY, delta);
}
}
// Draw the comment panel
if (this.isDisplayingComment()) {
final int panelHeight = Math.max(50, 18 + (this.hoveredElementCommentBody.size() * 10));
final int x = (int) (0.5 * this.width) - 157;
final int y = this.height - (panelHeight + 4);
// Draw panel
GuiUtil.drawPanel(x, y, COMMENT_PANEL_WIDTH, panelHeight);
// Draw text
this.fontRendererObj.drawStringWithShadow(this.hoveredElementCommentTitle.orElse(""), x + 4, y + 4, 0xFFFFFF);
for (int i = 0; i < this.hoveredElementCommentBody.size(); i++) {
this.fontRendererObj.drawStringWithShadow(this.hoveredElementCommentBody.get(i), x + 4, (y + 16) + (i * 10), 0xFFFFFF);
if (hoveredElement != null) {
hoveredElementCommentTimer++;
} else {
hoveredElementCommentTimer = 0;
}
super.drawScreen(mouseX, mouseY, delta);
if (!this.guiHidden) {
drawCenteredString(this.fontRendererObj, this.title, (int) (this.width * 0.5), 8, 0xFFFFFF);
if (notificationDialog != null && notificationDialogTimer > 0) {
drawCenteredString(this.fontRendererObj, notificationDialog, (int) (this.width * 0.5), 21, 0xFFFFFF);
} else {
if (optionMenuOpen) {
drawCenteredString(this.fontRendererObj, configureTitle(), (int) (this.width * 0.5), 21, 0xFFFFFF);
} else {
drawCenteredString(this.fontRendererObj, selectTitle(), (int) (this.width * 0.5), 21, 0xFFFFFF);
}
}
// Draw the comment panel
if (this.isDisplayingComment()) {
final int panelHeight = Math.max(50, 18 + (this.hoveredElementCommentBody.size() * 10));
final int x = (int) (0.5 * this.width) - 157;
final int y = this.height - (panelHeight + 4);
// Draw panel
GuiUtil.drawPanel(x, y, COMMENT_PANEL_WIDTH, panelHeight);
// Draw text
this.fontRendererObj.drawStringWithShadow(this.hoveredElementCommentTitle.orElse(""), x + 4, y + 4, 0xFFFFFF);
for (int i = 0; i < this.hoveredElementCommentBody.size(); i++) {
this.fontRendererObj.drawStringWithShadow(this.hoveredElementCommentBody.get(i), x + 4, (y + 16) + (i * 10), 0xFFFFFF);
}
}
}
}
// Render everything queued to drawScreen last
for (Runnable render : TOP_LAYER_RENDER_QUEUE) {
render.run();
}
TOP_LAYER_RENDER_QUEUE.clear();
// Render everything queued to drawScreen last
for (Runnable render : TOP_LAYER_RENDER_QUEUE) {
render.run();
}
TOP_LAYER_RENDER_QUEUE.clear();
if (this.developmentComponent != null) {
this.fontRendererObj.drawStringWithShadow(developmentComponent, 2, this.height - 10, 0xFFFFFF);
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 20, 0xFFFFFF);
} else if (this.updateComponent != null) {
this.fontRendererObj.drawStringWithShadow(updateComponent, 2, this.height - 10, 0xFFFFFF);
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 20, 0xFFFFFF);
} else {
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 10, 0xFFFFFF);
if (this.developmentComponent != null) {
this.fontRendererObj.drawStringWithShadow(developmentComponent, 2, this.height - 10, 0xFFFFFF);
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 20, 0xFFFFFF);
} else if (this.updateComponent != null) {
this.fontRendererObj.drawStringWithShadow(updateComponent, 2, this.height - 10, 0xFFFFFF);
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 20, 0xFFFFFF);
} else {
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 10, 0xFFFFFF);
}
} finally {
GLStateManager.glPopAttrib();
}
GLStateManager.glPopAttrib();
}
@Override
@@ -5,8 +5,6 @@ import net.coderbot.iris.Iris;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.ffp.FfpExtendedAttribs;
import com.gtnewhorizons.angelica.glsm.states.AlphaState;
import com.gtnewhorizons.angelica.glsm.states.BlendState;
import net.coderbot.iris.gl.shader.ProgramCreator;
import net.coderbot.iris.gl.state.StateUpdateNotifiers;
import net.coderbot.iris.pipeline.WorldRenderingPhase;
@@ -156,89 +154,6 @@ public class GbufferPrograms {
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + previousUnit);
}
public static long pushCutoutDefaults() {
final long saved = packCutoutState();
setCutoutDefaults();
return saved;
}
public static void popCutoutDefaults(long saved) {
if ((saved & ALPHA_ENABLED_BIT) != 0) {
GLStateManager.enableAlphaTest();
} else {
GLStateManager.disableAlphaTest();
}
GLStateManager.glAlphaFunc((int) ((saved >>> 32) & 0xFFFF), Float.intBitsToFloat((int) saved));
if ((saved & LIGHTMAP_ENABLED_BIT) == 0) {
final int previousUnit = GLStateManager.getActiveTextureUnitForServerState();
GLStateManager.glActiveTexture(GL13.GL_TEXTURE1);
GLStateManager.disableTexture();
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + previousUnit);
}
}
public static int pushBlendState() {
if (blendDepth == blendSaves.length) {
blendSaves = Arrays.copyOf(blendSaves, blendDepth * 2);
blendEnabledSaves = Arrays.copyOf(blendEnabledSaves, blendDepth * 2);
}
BlendState saved = blendSaves[blendDepth];
if (saved == null) {
saved = new BlendState();
blendSaves[blendDepth] = saved;
}
GLStateManager.getEffectiveBlendState(saved);
blendEnabledSaves[blendDepth] = GLStateManager.isEffectiveBlendEnabled();
return blendDepth++;
}
public static void popBlendState(int depth) {
blendDepth = depth;
final boolean enabled = blendEnabledSaves[depth];
if (enabled != GLStateManager.isEffectiveBlendEnabled()) {
if (enabled) {
GLStateManager.enableBlend();
} else {
GLStateManager.disableBlend();
}
}
final BlendState saved = blendSaves[depth];
GLStateManager.getEffectiveBlendState(blendScratch);
if (blendScratch.getSrcRgb() != saved.getSrcRgb() || blendScratch.getDstRgb() != saved.getDstRgb()
|| blendScratch.getSrcAlpha() != saved.getSrcAlpha() || blendScratch.getDstAlpha() != saved.getDstAlpha()) {
GLStateManager.tryBlendFuncSeparate(saved.getSrcRgb(), saved.getDstRgb(), saved.getSrcAlpha(), saved.getDstAlpha());
}
}
public static void popBlendStateTop() {
if (blendDepth > 0) {
popBlendState(blendDepth - 1);
}
}
private static BlendState[] blendSaves = new BlendState[4];
private static boolean[] blendEnabledSaves = new boolean[4];
private static int blendDepth;
private static final BlendState blendScratch = new BlendState();
private static final long ALPHA_ENABLED_BIT = 1L << 48;
private static final long LIGHTMAP_ENABLED_BIT = 1L << 49;
private static final AlphaState alphaScratch = new AlphaState();
private static long packCutoutState() {
GLStateManager.getEffectiveAlphaState(alphaScratch);
return (Float.floatToRawIntBits(alphaScratch.getReference()) & 0xFFFFFFFFL)
| ((long) (alphaScratch.getFunction() & 0xFFFF) << 32)
| (GLStateManager.isEffectiveAlphaTestEnabled() ? ALPHA_ENABLED_BIT : 0L)
| (GLStateManager.getTextures().getTextureUnitStates(1).isEnabled() ? LIGHTMAP_ENABLED_BIT : 0L);
}
public static void setBlockEntityDefaults() {
GLStateManager.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
FfpExtendedAttribs.setNeutralCurrentValues();
@@ -6,6 +6,7 @@ import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
import com.gtnewhorizons.angelica.compat.mojang.InteractionHand;
import com.gtnewhorizons.angelica.event.RenderHandEvent;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.StateSet;
import com.gtnewhorizons.angelica.mixins.interfaces.ItemRendererAccessor;
import com.gtnewhorizons.angelica.rendering.RenderingState;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
@@ -128,40 +129,47 @@ public class HandRenderer {
ACTIVE = true;
final int blendSave = GbufferPrograms.pushBlendState();
final long cutoutSave = GbufferPrograms.pushCutoutDefaults();
final boolean depthMaskBefore = GLStateManager.isEffectiveDepthMaskEnabled();
GLStateManager.disableBlend();
GLStateManager.defaultBlendFunc();
pipeline.setPhase(WorldRenderingPhase.HAND_SOLID);
GLStateManager.glPushMatrix();
GLStateManager.glDepthMask(true); // actually write to the depth buffer, it's normally disabled at this point
mc.mcProfiler.startSection("iris_hand");
final int stateDepth = GLStateManager.pushState(StateSet.HAND);
try {
setupGlState(gameRenderer, camera, tickDelta);
GbufferPrograms.setCutoutDefaults();
GbufferPrograms.setBlockEntityDefaults();
GLStateManager.disableBlend();
GLStateManager.defaultBlendFunc();
renderingSolid = true;
pipeline.setPhase(WorldRenderingPhase.HAND_SOLID);
mc.entityRenderer.enableLightmap(tickDelta);
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
mc.entityRenderer.disableLightmap(tickDelta);
boolean matrixPushed = false;
boolean profilerSectionStarted = false;
try {
GLStateManager.glPushMatrix();
matrixPushed = true;
GLStateManager.glDepthMask(true); // actually write to the depth buffer, it's normally disabled at this point
mc.mcProfiler.startSection("iris_hand");
profilerSectionStarted = true;
try {
setupGlState(gameRenderer, camera, tickDelta);
GbufferPrograms.setBlockEntityDefaults();
renderingSolid = true;
mc.entityRenderer.enableLightmap(tickDelta);
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
mc.entityRenderer.disableLightmap(tickDelta);
} finally {
renderingSolid = false;
if (profilerSectionStarted) mc.mcProfiler.endSection();
}
} finally {
if (matrixPushed) {
GLStateManager.glPopMatrix();
resetProjectionMatrix();
}
}
} finally {
renderingSolid = false;
mc.mcProfiler.endSection();
GLStateManager.glPopMatrix();
resetProjectionMatrix();
GLStateManager.glDepthMask(depthMaskBefore);
GbufferPrograms.popCutoutDefaults(cutoutSave);
GbufferPrograms.popBlendState(blendSave);
GLStateManager.popStateTo(stateDepth);
pipeline.setPhase(WorldRenderingPhase.NONE);
@@ -177,36 +185,43 @@ public class HandRenderer {
ACTIVE = true;
final int blendSave = GbufferPrograms.pushBlendState();
final long cutoutSave = GbufferPrograms.pushCutoutDefaults();
final boolean depthMaskBefore = GLStateManager.isEffectiveDepthMaskEnabled();
GLStateManager.enableBlend();
GLStateManager.defaultBlendFunc();
pipeline.setPhase(WorldRenderingPhase.HAND_TRANSLUCENT);
GLStateManager.glPushMatrix();
GLStateManager.glDepthMask(false);
mc.mcProfiler.startSection("iris_hand_translucent");
final int stateDepth = GLStateManager.pushState(StateSet.HAND);
try {
setupGlState(gameRenderer, camera, tickDelta);
GbufferPrograms.setCutoutDefaults();
GbufferPrograms.setBlockEntityDefaults();
GLStateManager.enableBlend();
GLStateManager.defaultBlendFunc();
mc.entityRenderer.enableLightmap(tickDelta);
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
mc.entityRenderer.disableLightmap(tickDelta);
pipeline.setPhase(WorldRenderingPhase.HAND_TRANSLUCENT);
boolean matrixPushed = false;
boolean profilerSectionStarted = false;
try {
GLStateManager.glPushMatrix();
matrixPushed = true;
GLStateManager.glDepthMask(false);
mc.mcProfiler.startSection("iris_hand_translucent");
profilerSectionStarted = true;
try {
setupGlState(gameRenderer, camera, tickDelta);
GbufferPrograms.setBlockEntityDefaults();
mc.entityRenderer.enableLightmap(tickDelta);
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
mc.entityRenderer.disableLightmap(tickDelta);
} finally {
if (profilerSectionStarted) mc.mcProfiler.endSection();
}
} finally {
if (matrixPushed) {
GLStateManager.glPopMatrix();
resetProjectionMatrix();
}
}
} finally {
mc.mcProfiler.endSection();
GLStateManager.glPopMatrix();
resetProjectionMatrix();
GLStateManager.glDepthMask(depthMaskBefore);
GbufferPrograms.popCutoutDefaults(cutoutSave);
GbufferPrograms.popBlendState(blendSave);
GLStateManager.popStateTo(stateDepth);
pipeline.setPhase(WorldRenderingPhase.NONE);
@@ -681,16 +681,10 @@ public class ShadowRenderer {
/** Flushes deferred shadow-pass geometry while GL_POLYGON_OFFSET_FILL is still enabled. */
private static void flushShadowModelParts() {
if (Tracy.ENABLED) Tracy.beginZone(Z_SHADOW_MODEL_PARTS);
final boolean alphaEnabled = GLStateManager.getAlphaTest().isEnabled();
final int alphaFunc = GLStateManager.getAlphaState().getFunction();
final float alphaRef = GLStateManager.getAlphaState().getReference();
try {
ModelPartBatcher.INSTANCE.flush();
PlayerReflectionCapture.flush();
} finally {
if (alphaEnabled) GLStateManager.enableAlphaTest();
else GLStateManager.disableAlphaTest();
GLStateManager.glAlphaFunc(alphaFunc, alphaRef);
if (Tracy.ENABLED) Tracy.endZone();
}
}