mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-27 13:28:00 +01:00
Keeping up
- Contraptions always use ArrayModelRenderer - De-duplicate UI framebuffer swapping code - Unbind VAO between contraption structure drawing and engine drawing - Bump flywheel build
This commit is contained in:
parent
5ad0d1d704
commit
a3476fd54c
6 changed files with 32 additions and 60 deletions
|
@ -19,7 +19,7 @@ parchment_version = 2021.10.31
|
||||||
|
|
||||||
# dependency versions
|
# dependency versions
|
||||||
registrate_version = MC1.18-1.0.21
|
registrate_version = MC1.18-1.0.21
|
||||||
flywheel_version = 1.18-0.3.0.1
|
flywheel_version = 1.18-0.3.0.3
|
||||||
jei_version = 9.0.0.40
|
jei_version = 9.0.0.40
|
||||||
|
|
||||||
# curseforge information
|
# curseforge information
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||||
|
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
||||||
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
||||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||||
import com.jozufozu.flywheel.util.TextureBinder;
|
import com.jozufozu.flywheel.util.TextureBinder;
|
||||||
|
@ -55,11 +56,13 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
|
||||||
renderedContraption.doRenderLayer(layer, structureShader);
|
renderedContraption.doRenderLayer(layer, structureShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlVertexArray.unbind();
|
||||||
|
|
||||||
if (Backend.getInstance().canUseInstancing()) {
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
RenderLayer renderLayer = event.getLayer();
|
RenderLayer renderLayer = event.getLayer();
|
||||||
if (renderLayer != null) {
|
if (renderLayer != null) {
|
||||||
for (RenderedContraption renderer : visible) {
|
for (RenderedContraption renderer : visible) {
|
||||||
renderer.materialManager.render(event, event.buffers.bufferSource());
|
renderer.engine.render(event, event.buffers.bufferSource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
||||||
|
|
||||||
private final ContraptionLighter<?> lighter;
|
private final ContraptionLighter<?> lighter;
|
||||||
|
|
||||||
public final InstancingEngine<ContraptionProgram> materialManager;
|
public final InstancingEngine<ContraptionProgram> engine;
|
||||||
public final ContraptionInstanceManager kinetics;
|
public final ContraptionInstanceManager kinetics;
|
||||||
|
|
||||||
private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>();
|
private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>();
|
||||||
|
@ -47,12 +47,12 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
||||||
public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
|
public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
|
||||||
super(contraption, renderWorld);
|
super(contraption, renderWorld);
|
||||||
this.lighter = contraption.makeLighter();
|
this.lighter = contraption.makeLighter();
|
||||||
this.materialManager = InstancingEngine.builder(CreateContexts.CWORLD)
|
this.engine = InstancingEngine.builder(CreateContexts.CWORLD)
|
||||||
.setGroupFactory(ContraptionGroup.forContraption(this))
|
.setGroupFactory(ContraptionGroup.forContraption(this))
|
||||||
.setIgnoreOriginCoordinate(true)
|
.setIgnoreOriginCoordinate(true)
|
||||||
.build();
|
.build();
|
||||||
this.kinetics = new ContraptionInstanceManager(this, materialManager);
|
this.kinetics = new ContraptionInstanceManager(this, engine);
|
||||||
this.materialManager.addListener(this.kinetics);
|
this.engine.addListener(this.kinetics);
|
||||||
|
|
||||||
buildLayers();
|
buildLayers();
|
||||||
if (Backend.getInstance().canUseInstancing()) {
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
|
@ -113,7 +113,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
||||||
|
|
||||||
lighter.delete();
|
lighter.delete();
|
||||||
|
|
||||||
materialManager.delete();
|
engine.delete();
|
||||||
kinetics.invalidate();
|
kinetics.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,13 +129,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
||||||
for (RenderType layer : blockLayers) {
|
for (RenderType layer : blockLayers) {
|
||||||
Supplier<IModel> layerModel = () -> new WorldModel(renderWorld, layer, contraption.getBlocks().values(), layer + "_" + contraption.entity.getId());
|
Supplier<IModel> layerModel = () -> new WorldModel(renderWorld, layer, contraption.getBlocks().values(), layer + "_" + contraption.entity.getId());
|
||||||
|
|
||||||
ModelRenderer renderer;
|
renderLayers.put(layer, new ArrayModelRenderer(layerModel));
|
||||||
if (Backend.getInstance().compat.vertexArrayObjectsSupported())
|
|
||||||
renderer = new ArrayModelRenderer(layerModel);
|
|
||||||
else
|
|
||||||
renderer = new ModelRenderer(layerModel);
|
|
||||||
|
|
||||||
renderLayers.put(layer, renderer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,8 @@ import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.util.TriConsumer;
|
import org.apache.logging.log4j.util.TriConsumer;
|
||||||
import org.lwjgl.opengl.GL20;
|
|
||||||
import org.lwjgl.opengl.GL30;
|
import org.lwjgl.opengl.GL30;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
|
||||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
|
||||||
import com.mojang.blaze3d.platform.GlConst;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
@ -98,29 +93,13 @@ public abstract class ConfigScreen extends AbstractSimiScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareFrame() {
|
protected void prepareFrame() {
|
||||||
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
|
UIRenderHelper.swapAndBlitColor(minecraft.getMainRenderTarget(), UIRenderHelper.framebuffer);
|
||||||
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
|
|
||||||
|
|
||||||
GlCompat functions = Backend.getInstance().compat;
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.frameBufferId);
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.frameBufferId);
|
|
||||||
functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
|
||||||
|
|
||||||
functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, thisBuffer.frameBufferId);
|
|
||||||
RenderSystem.clear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
|
RenderSystem.clear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void endFrame() {
|
protected void endFrame() {
|
||||||
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
|
UIRenderHelper.swapAndBlitColor(UIRenderHelper.framebuffer, minecraft.getMainRenderTarget());
|
||||||
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
|
|
||||||
|
|
||||||
GlCompat functions = Backend.getInstance().compat;
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.frameBufferId);
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.frameBufferId);
|
|
||||||
functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
|
||||||
|
|
||||||
functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, mainBuffer.frameBufferId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,13 +6,8 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL20;
|
|
||||||
import org.lwjgl.opengl.GL30;
|
import org.lwjgl.opengl.GL30;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
|
||||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
|
||||||
import com.mojang.blaze3d.platform.GlConst;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.simibubi.create.foundation.gui.element.BoxElement;
|
import com.simibubi.create.foundation.gui.element.BoxElement;
|
||||||
|
@ -214,31 +209,16 @@ public class ConfirmationScreen extends AbstractSimiScreen {
|
||||||
this.fillGradient(ms, 0, 0, this.width, this.height, 0x70101010, 0x80101010);
|
this.fillGradient(ms, 0, 0, this.width, this.height, 0x70101010, 0x80101010);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareFrame() {
|
protected void prepareFrame() {
|
||||||
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
|
UIRenderHelper.swapAndBlitColor(minecraft.getMainRenderTarget(), UIRenderHelper.framebuffer);
|
||||||
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
|
|
||||||
|
|
||||||
GlCompat functions = Backend.getInstance().compat;
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.frameBufferId);
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.frameBufferId);
|
|
||||||
functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
|
||||||
|
|
||||||
functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, thisBuffer.frameBufferId);
|
|
||||||
RenderSystem.clear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
|
RenderSystem.clear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void endFrame() {
|
protected void endFrame() {
|
||||||
RenderTarget thisBuffer = UIRenderHelper.framebuffer;
|
UIRenderHelper.swapAndBlitColor(UIRenderHelper.framebuffer, minecraft.getMainRenderTarget());
|
||||||
RenderTarget mainBuffer = minecraft.getMainRenderTarget();
|
|
||||||
|
|
||||||
GlCompat functions = Backend.getInstance().compat;
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.frameBufferId);
|
|
||||||
functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.frameBufferId);
|
|
||||||
functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
|
||||||
|
|
||||||
functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, mainBuffer.frameBufferId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,7 +2,12 @@ package com.simibubi.create.foundation.gui;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL20;
|
||||||
|
import org.lwjgl.opengl.GL30;
|
||||||
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||||
|
import com.mojang.blaze3d.platform.GlConst;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
|
@ -252,6 +257,17 @@ public class UIRenderHelper {
|
||||||
poseStack.mulPoseMatrix(Matrix4f.createScaleMatrix(1, -1, 1));
|
poseStack.mulPoseMatrix(Matrix4f.createScaleMatrix(1, -1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch from src to dst, after copying the contents of src to dst.
|
||||||
|
*/
|
||||||
|
public static void swapAndBlitColor(RenderTarget src, RenderTarget dst) {
|
||||||
|
GlStateManager._glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, src.frameBufferId);
|
||||||
|
GlStateManager._glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, dst.frameBufferId);
|
||||||
|
GlStateManager._glBlitFrameBuffer(0, 0, src.viewWidth, src.viewHeight, 0, 0, dst.viewWidth, dst.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
||||||
|
|
||||||
|
GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, dst.frameBufferId);
|
||||||
|
}
|
||||||
|
|
||||||
public static class CustomRenderTarget extends RenderTarget {
|
public static class CustomRenderTarget extends RenderTarget {
|
||||||
|
|
||||||
public CustomRenderTarget(boolean pUseDepth) {
|
public CustomRenderTarget(boolean pUseDepth) {
|
||||||
|
|
Loading…
Reference in a new issue