Skip to content

Commit

Permalink
Variable renames for BufferBuilderStorage -> RenderBuffers
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbot16 committed Sep 12, 2021
1 parent 2e4b5fe commit 58da156
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.coderbot.batchedentityrendering.impl;

public class BatchingDebugMessageHelper {
public static String getDebugMessage(DrawCallTrackingBufferBuilderStorage drawTracker) {
public static String getDebugMessage(DrawCallTrackingRenderBuffers drawTracker) {
int drawCalls = drawTracker.getDrawCalls();
int renderTypes = drawTracker.getRenderTypes();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.coderbot.batchedentityrendering.impl;

public interface DrawCallTrackingBufferBuilderStorage {
public interface DrawCallTrackingRenderBuffers {
int getDrawCalls();
int getRenderTypes();
void resetDrawCounts();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.coderbot.batchedentityrendering.impl;

public interface MemoryTrackingBufferBuilderStorage {
public interface MemoryTrackingRenderBuffers {
int getEntityBufferAllocatedSize();
int getMiscBufferAllocatedSize();
int getMaxBegins();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.coderbot.batchedentityrendering.impl;

public interface ExtendedBufferStorage {
public interface RenderBuffersExt {
void beginLevelRendering();
void endLevelRendering();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.coderbot.batchedentityrendering.mixin;

import net.coderbot.batchedentityrendering.impl.BatchingDebugMessageHelper;
import net.coderbot.batchedentityrendering.impl.DrawCallTrackingBufferBuilderStorage;
import net.coderbot.batchedentityrendering.impl.DrawCallTrackingRenderBuffers;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.DebugScreenOverlay;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -17,7 +17,7 @@ public abstract class MixinDebugScreenOverlay {
private void batchedentityrendering$appendStats(CallbackInfoReturnable<List<String>> cir) {
List<String> messages = cir.getReturnValue();

DrawCallTrackingBufferBuilderStorage drawTracker = (DrawCallTrackingBufferBuilderStorage) Minecraft.getInstance().renderBuffers();
DrawCallTrackingRenderBuffers drawTracker = (DrawCallTrackingRenderBuffers) Minecraft.getInstance().renderBuffers();

// blank line separator
messages.add("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3d;
import net.coderbot.batchedentityrendering.impl.DrawCallTrackingBufferBuilderStorage;
import net.coderbot.batchedentityrendering.impl.ExtendedBufferStorage;
import net.coderbot.batchedentityrendering.impl.DrawCallTrackingRenderBuffers;
import net.coderbot.batchedentityrendering.impl.RenderBuffersExt;
import net.coderbot.batchedentityrendering.impl.Groupable;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.util.profiling.ProfilerFiller;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -38,11 +35,11 @@ public class MixinLevelRenderer {

@Inject(method = "renderLevel", at = @At("HEAD"))
private void batchedentityrendering$beginLevelRender(PoseStack poseStack, float f, long l, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, CallbackInfo ci) {
if (renderBuffers instanceof DrawCallTrackingBufferBuilderStorage) {
((DrawCallTrackingBufferBuilderStorage) renderBuffers).resetDrawCounts();
if (renderBuffers instanceof DrawCallTrackingRenderBuffers) {
((DrawCallTrackingRenderBuffers) renderBuffers).resetDrawCounts();
}

((ExtendedBufferStorage) renderBuffers).beginLevelRendering();
((RenderBuffersExt) renderBuffers).beginLevelRendering();
MultiBufferSource provider = renderBuffers.bufferSource();

if (provider instanceof Groupable) {
Expand Down Expand Up @@ -72,7 +69,7 @@ public class MixinLevelRenderer {

@Inject(method = "renderLevel", at = @At("RETURN"))
private void batchedentityrendering$endLevelRender(PoseStack poseStack, float f, long l, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, CallbackInfo ci) {
((ExtendedBufferStorage) renderBuffers).endLevelRendering();
((RenderBuffersExt) renderBuffers).endLevelRendering();
groupable = null;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.coderbot.batchedentityrendering.mixin;

import net.coderbot.batchedentityrendering.impl.DrawCallTrackingBufferBuilderStorage;
import net.coderbot.batchedentityrendering.impl.ExtendedBufferStorage;
import net.coderbot.batchedentityrendering.impl.DrawCallTrackingRenderBuffers;
import net.coderbot.batchedentityrendering.impl.RenderBuffersExt;
import net.coderbot.batchedentityrendering.impl.FullyBufferedMultiBufferSource;
import net.coderbot.batchedentityrendering.impl.MemoryTrackingBuffer;
import net.coderbot.batchedentityrendering.impl.MemoryTrackingBufferBuilderStorage;
import net.coderbot.batchedentityrendering.impl.MemoryTrackingRenderBuffers;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.OutlineBufferSource;
import net.minecraft.client.renderer.RenderBuffers;
Expand All @@ -17,7 +17,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(RenderBuffers.class)
public class MixinRenderBuffers implements ExtendedBufferStorage, MemoryTrackingBufferBuilderStorage, DrawCallTrackingBufferBuilderStorage {
public class MixinRenderBuffers implements RenderBuffersExt, MemoryTrackingRenderBuffers, DrawCallTrackingRenderBuffers {
@Unique
private final FullyBufferedMultiBufferSource buffered = new FullyBufferedMultiBufferSource();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.coderbot.iris.mixin.fantastic;

import net.coderbot.batchedentityrendering.impl.ExtendedBufferStorage;
import net.coderbot.batchedentityrendering.impl.RenderBuffersExt;
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -15,7 +15,7 @@
import java.util.SortedMap;

@Mixin(RenderBuffers.class)
public class MixinRenderBuffers implements ExtendedBufferStorage {
public class MixinRenderBuffers implements RenderBuffersExt {
@Shadow
@Final
private SortedMap<RenderType, BufferBuilder> fixedBuffers;
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.mojang.math.Vector3f;
import com.mojang.math.Vector4f;
import net.coderbot.batchedentityrendering.impl.BatchingDebugMessageHelper;
import net.coderbot.batchedentityrendering.impl.DrawCallTrackingBufferBuilderStorage;
import net.coderbot.batchedentityrendering.impl.ExtendedBufferStorage;
import net.coderbot.batchedentityrendering.impl.DrawCallTrackingRenderBuffers;
import net.coderbot.batchedentityrendering.impl.RenderBuffersExt;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gl.program.Program;
import net.coderbot.iris.gl.program.ProgramBuilder;
Expand Down Expand Up @@ -80,7 +80,7 @@ public class ShadowRenderer implements ShadowMapRenderer {
private final float sunPathRotation;

private final RenderBuffers buffers;
private final ExtendedBufferStorage extendedBufferStorage;
private final RenderBuffersExt renderBuffersExt;

private final RenderTargets gbufferRenderTargets;
private final AbstractTexture normals;
Expand Down Expand Up @@ -162,10 +162,10 @@ public ShadowRenderer(WorldRenderingPipeline pipeline, ProgramSource shadow, Pac

this.buffers = new RenderBuffers();

if (this.buffers instanceof ExtendedBufferStorage) {
this.extendedBufferStorage = (ExtendedBufferStorage) buffers;
if (this.buffers instanceof RenderBuffersExt) {
this.renderBuffersExt = (RenderBuffersExt) buffers;
} else {
this.extendedBufferStorage = null;
this.renderBuffersExt = null;
}

configureSamplingSettings(shadowDirectives);
Expand Down Expand Up @@ -482,12 +482,12 @@ public void renderShadows(LevelRendererAccessor levelRenderer, Camera playerCame
//
// Note: We must use a separate BuilderBufferStorage object here, or else very weird things will happen during
// rendering.
if (extendedBufferStorage != null) {
extendedBufferStorage.beginLevelRendering();
if (renderBuffersExt != null) {
renderBuffersExt.beginLevelRendering();
}

if (buffers instanceof DrawCallTrackingBufferBuilderStorage) {
((DrawCallTrackingBufferBuilderStorage) buffers).resetDrawCounts();
if (buffers instanceof DrawCallTrackingRenderBuffers) {
((DrawCallTrackingRenderBuffers) buffers).resetDrawCounts();
}

MultiBufferSource.BufferSource provider = buffers.bufferSource();
Expand Down Expand Up @@ -568,8 +568,8 @@ public void renderShadows(LevelRendererAccessor levelRenderer, Camera playerCame
// NB: If we want to render anything after translucent terrain, we need to uncomment this line!
// setupShadowProgram();

if (extendedBufferStorage != null) {
extendedBufferStorage.endLevelRendering();
if (renderBuffersExt != null) {
renderBuffersExt.endLevelRendering();
}

debugStringTerrain = ((LevelRenderer) levelRenderer).getChunkStatistics();
Expand Down Expand Up @@ -612,8 +612,8 @@ public void addDebugText(List<String> messages) {
messages.add("[Iris] Shadow Entities: " + getEntitiesDebugString());
messages.add("[Iris] Shadow Block Entities: " + getBlockEntitiesDebugString());

if (buffers instanceof DrawCallTrackingBufferBuilderStorage) {
DrawCallTrackingBufferBuilderStorage drawCallTracker = (DrawCallTrackingBufferBuilderStorage) buffers;
if (buffers instanceof DrawCallTrackingRenderBuffers) {
DrawCallTrackingRenderBuffers drawCallTracker = (DrawCallTrackingRenderBuffers) buffers;
messages.add("[Iris] Shadow Entity Batching: " + BatchingDebugMessageHelper.getDebugMessage(drawCallTracker));
}
}
Expand Down

0 comments on commit 58da156

Please sign in to comment.