-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use vanilla render path and log warning when incompatible VertexConsu…
…mer is detected (#1842) Co-authored-by: JellySquid <[email protected]>
- Loading branch information
1 parent
1ad18d2
commit 5b57419
Showing
6 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/me/jellysquid/mods/sodium/client/render/vertex/VertexConsumerTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package me.jellysquid.mods.sodium.client.render.vertex; | ||
|
||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; | ||
import it.unimi.dsi.fastutil.objects.ReferenceSet; | ||
import me.jellysquid.mods.sodium.client.SodiumClientMod; | ||
import net.minecraft.client.render.VertexConsumer; | ||
|
||
public class VertexConsumerTracker { | ||
private static final ReferenceSet<Class<? extends VertexConsumer>> BAD_CONSUMERS = new ReferenceOpenHashSet<>(); | ||
|
||
public static void logBadConsumer(VertexConsumer consumer) { | ||
if(BAD_CONSUMERS.add(consumer.getClass())) { | ||
SodiumClientMod.logger().warn("Some Sodium optimizations are being bypassed to prevent crashes with a mod that is implementing " + consumer.getClass().getName()); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/me/jellysquid/mods/sodium/client/render/vertex/VertexConsumerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package me.jellysquid.mods.sodium.client.render.vertex; | ||
|
||
import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; | ||
import net.minecraft.client.render.VertexConsumer; | ||
|
||
public class VertexConsumerUtils { | ||
/** | ||
* Attempt to convert a {@link VertexConsumer} into a {@link VertexBufferWriter}. If this fails, return null | ||
* and log a message. | ||
* @param consumer the consumer to convert | ||
* @return a {@link VertexBufferWriter}, or null if the consumer does not support this | ||
*/ | ||
public static VertexBufferWriter convertOrLog(VertexConsumer consumer) { | ||
VertexBufferWriter writer = VertexBufferWriter.tryOf(consumer); | ||
if(writer == null) { | ||
VertexConsumerTracker.logBadConsumer(consumer); | ||
} | ||
return writer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters