Skip to content

Commit

Permalink
Force render types with no depth test to be last
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jan 17, 2025
1 parent 576adff commit 624e76c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static boolean shouldSortOnUpload(RenderType type) {

public VertexConsumer getBuffer(RenderType renderType) {
try {
ByteBufferBuilderHolder buffer = buffers.computeIfAbsent(renderType, (r) -> new ByteBufferBuilderHolder(new ByteBufferBuilder(512 * 2024)));
ByteBufferBuilderHolder buffer = buffers.computeIfAbsent(renderType, (r) -> new ByteBufferBuilderHolder(new ByteBufferBuilder(renderType.bufferSize())));

buffer.wasUsed();
BufferBuilder builder = builders.computeIfAbsent(renderType, (t) -> new BufferBuilder(buffer.getBuffer(), renderType.mode(), renderType.format()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
public interface CompositeStateAccessor {
@Accessor("transparencyState")
RenderStateShard.TransparencyStateShard getTransparency();

@Accessor("depthTestState")
RenderStateShard.DepthTestStateShard getDepth();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ private MixinCompositeRenderType(String name, VertexFormat vertexFormat, VertexF
@Inject(method = INIT, at = @At("RETURN"))
private void batchedentityrendering$onCompositeInit(String string, VertexFormat vertexFormat, VertexFormat.Mode mode, int i, boolean bl, boolean bl2, CompositeState compositeState, CallbackInfo ci) {
RenderStateShard.TransparencyStateShard transparency = ((CompositeStateAccessor) (Object) compositeState).getTransparency();
RenderStateShard.DepthTestStateShard depth = ((CompositeStateAccessor) (Object) compositeState).getDepth();

if ("water_mask".equals(name)) {
if ("water_mask".equals(name) || depth == RenderStateShard.NO_DEPTH_TEST) {
transparencyType = TransparencyType.WATER_MASK;
} else if ("lines".equals(name)) {
transparencyType = TransparencyType.LINES;
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/iris.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ accessible class com/mojang/blaze3d/platform/GlStateManager$TextureState
accessible class com/mojang/blaze3d/platform/GlStateManager$ColorMask
accessible class com/mojang/blaze3d/platform/GlStateManager$DepthState
accessible class net/minecraft/client/renderer/RenderStateShard$TransparencyStateShard
accessible class net/minecraft/client/renderer/RenderStateShard$DepthTestStateShard
accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
accessible class net/minecraft/client/renderer/RenderType$CompositeState
accessible class net/minecraft/client/renderer/FogRenderer$FogData
Expand Down

0 comments on commit 624e76c

Please sign in to comment.