Re-added patch to enable stencil buffer in net.minecraft.client.shader.Framebuffer

Add test for the stencil buffer feature. Only tests that it doesn't crash when enabling, for now. - giga
This commit is contained in:
Funwayguy 2020-03-02 08:45:03 +01:00 committed by David Quintana
parent 765da1aca8
commit ec7d9d4179
3 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,46 @@
--- a/net/minecraft/client/shader/Framebuffer.java
+++ b/net/minecraft/client/shader/Framebuffer.java
@@ -100,8 +100,14 @@
GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, FramebufferConstants.field_227594_c_, 3553, this.field_147617_g, 0);
if (this.field_147619_e) {
GlStateManager.func_227730_i_(FramebufferConstants.field_227593_b_, this.field_147624_h);
+ if (!stencilEnabled) {
GlStateManager.func_227678_b_(FramebufferConstants.field_227593_b_, 33190, this.field_147622_a, this.field_147620_b);
GlStateManager.func_227693_c_(FramebufferConstants.field_227592_a_, FramebufferConstants.field_227595_d_, FramebufferConstants.field_227593_b_, this.field_147624_h);
+ } else {
+ GlStateManager.func_227678_b_(FramebufferConstants.field_227593_b_, org.lwjgl.opengl.EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, this.field_147622_a, this.field_147620_b);
+ GlStateManager.func_227693_c_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, FramebufferConstants.field_227593_b_, this.field_147624_h);
+ GlStateManager.func_227693_c_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, FramebufferConstants.field_227593_b_, this.field_147624_h);
+ }
}
this.func_147611_b();
@@ -254,4 +260,28 @@
GlStateManager.func_227658_a_(i, p_216493_1_);
this.func_147609_e();
}
+
+ /*================================ FORGE START ================================================*/
+ private boolean stencilEnabled = false;
+ /**
+ * Attempts to enabled 8 bits of stencil buffer on this FrameBuffer.
+ * Modders must call this directly to set things up.
+ * This is to prevent the default cause where graphics cards do not support stencil bits.
+ */
+ public void enableStencil()
+ {
+ if(stencilEnabled) return;
+ stencilEnabled = true;
+ this.func_216491_a(field_147621_c, field_147618_d, net.minecraft.client.Minecraft.field_142025_a);
+ }
+
+ /**
+ * Returns wither or not this FBO has been successfully initialized with stencil bits.
+ * If not, and a modder wishes it to be, they must call enableStencil.
+ */
+ public boolean isStencilEnabled()
+ {
+ return this.stencilEnabled;
+ }
+ /*================================ FORGE END ================================================*/
}

View file

@ -0,0 +1,18 @@
package net.minecraftforge.debug.client.rendering;
import net.minecraft.client.Minecraft;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@Mod("stencil_enable_test")
public class StencilEnableTest {
public StencilEnableTest() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
}
private void clientSetup(FMLClientSetupEvent event) {
Minecraft.getInstance().getFramebuffer().enableStencil();
}
}

View file

@ -69,6 +69,8 @@ loaderVersion="[28,)"
modId="composite_model_test"
[[mods]]
modId="music_disc_test"
[[mods]]
modId="stencil_enable_test"
[[dependencies.global_loot_test]]
modId="forge"
mandatory=true