mirror of
https://github.com/neoforged/NeoForge.git
synced 2026-10-12 02:19:42 +00:00
Co-authored-by: XFactHD <[email protected]> Co-authored-by: Technici4n <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Co-authored-by: Matyrobbrt <[email protected]> Co-authored-by: Marc Hermans <[email protected]> Co-authored-by: Sara Freimer <[email protected]>
92 lines
5.6 KiB
Diff
92 lines
5.6 KiB
Diff
--- a/net/minecraft/client/gui/render/GuiRenderer.java
|
|
+++ b/net/minecraft/client/gui/render/GuiRenderer.java
|
|
@@ -88,7 +_,8 @@
|
|
private final Projection guiProjection = new Projection();
|
|
private final ProjectionMatrixBuffer guiProjectionMatrixBuffer = new ProjectionMatrixBuffer("gui");
|
|
private final FeatureRenderDispatcher featureRenderDispatcher;
|
|
- private final Map<Class<? extends PictureInPictureRenderState>, PictureInPictureRenderer<?>> pictureInPictureRenderers;
|
|
+ private final Map<Class<? extends PictureInPictureRenderState>, net.neoforged.neoforge.client.gui.PictureInPictureRendererPool<?>> pictureInPictureRendererPools;
|
|
+ private final Set<PictureInPictureRenderState> pictureInPictureRenderStatesScratch = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>();
|
|
private @Nullable GuiItemAtlas itemAtlas;
|
|
private int cachedGuiScale;
|
|
private final CubeMap cubeMap = new CubeMap(Identifier.withDefaultNamespace("textures/gui/title/background/panorama"));
|
|
@@ -97,16 +_,10 @@
|
|
private @Nullable TextureSetup previousTextureSetup = null;
|
|
private StagedVertexBuffer.@Nullable Draw previousDraw;
|
|
|
|
- public GuiRenderer(GuiRenderState renderState, FeatureRenderDispatcher featureRenderDispatcher, List<PictureInPictureRenderer<?>> pictureInPictureRenderers) {
|
|
+ public GuiRenderer(GuiRenderState renderState, FeatureRenderDispatcher featureRenderDispatcher, List<net.neoforged.neoforge.client.gui.PictureInPictureRendererRegistration<?>> pipRendererFactories) {
|
|
this.renderState = renderState;
|
|
this.featureRenderDispatcher = featureRenderDispatcher;
|
|
- Builder<Class<? extends PictureInPictureRenderState>, PictureInPictureRenderer<?>> builder = ImmutableMap.builder();
|
|
-
|
|
- for (PictureInPictureRenderer<?> pictureInPictureRenderer : pictureInPictureRenderers) {
|
|
- builder.put((Class<? extends PictureInPictureRenderState>)pictureInPictureRenderer.getRenderStateClass(), pictureInPictureRenderer);
|
|
- }
|
|
-
|
|
- this.pictureInPictureRenderers = builder.buildOrThrow();
|
|
+ this.pictureInPictureRendererPools = net.neoforged.neoforge.client.gui.PictureInPictureRendererPool.createPools(pipRendererFactories);
|
|
}
|
|
|
|
public void endFrame() {
|
|
@@ -135,6 +_,7 @@
|
|
this.renderState.reset();
|
|
this.firstDrawIndexAfterBlur = Integer.MAX_VALUE;
|
|
this.clearUnusedOversizedItemRenderers();
|
|
+ this.pictureInPictureRendererPools.values().forEach(net.neoforged.neoforge.client.gui.PictureInPictureRendererPool::clearUnusedRenderers);
|
|
if (SharedConstants.DEBUG_SHUFFLE_UI_RENDERING_ORDER) {
|
|
RenderPipeline.updateSortKeySeed();
|
|
TextureSetup.updateSortKeySeed();
|
|
@@ -229,6 +_,7 @@
|
|
ScreenRectangle scissorArea = elementState.scissorArea();
|
|
if (this.previousDraw == null
|
|
|| pipeline != this.previousPipeline
|
|
+ || pipeline.getPrimitiveTopology().connectedPrimitives // Neo: flush elements with connected primitives individually
|
|
|| this.scissorChanged(scissorArea, this.previousScissorArea)
|
|
|| !textureSetup.equals(this.previousTextureSetup)) {
|
|
this.previousPipeline = pipeline;
|
|
@@ -292,14 +_,31 @@
|
|
|
|
private void preparePictureInPicture() {
|
|
int guiScale = Minecraft.getInstance().gameRenderer.gameRenderState().windowRenderState.guiScale;
|
|
- this.renderState.forEachPictureInPicture(pictureInPictureState -> this.preparePictureInPictureState(pictureInPictureState, guiScale));
|
|
+ this.pictureInPictureRenderStatesScratch.clear();
|
|
+ this.renderState.forEachPictureInPicture(state -> {
|
|
+ if (this.preparePictureInPictureState(state, guiScale, true)) {
|
|
+ this.pictureInPictureRenderStatesScratch.add(state);
|
|
+ }
|
|
+ });
|
|
+ this.renderState.forEachPictureInPicture(state -> {
|
|
+ if (this.pictureInPictureRenderStatesScratch.add(state)) {
|
|
+ this.preparePictureInPictureState(state, guiScale, false);
|
|
+ }
|
|
+ });
|
|
+ this.pictureInPictureRenderStatesScratch.clear();
|
|
}
|
|
|
|
- private <T extends PictureInPictureRenderState> void preparePictureInPictureState(T picturesInPictureState, int guiScale) {
|
|
- PictureInPictureRenderer<T> renderer = (PictureInPictureRenderer<T>)this.pictureInPictureRenderers.get(picturesInPictureState.getClass());
|
|
+ private <T extends PictureInPictureRenderState> boolean preparePictureInPictureState(T picturesInPictureState, int guiScale, boolean firstPass) {
|
|
+ var pool = (net.neoforged.neoforge.client.gui.PictureInPictureRendererPool<T>)this.pictureInPictureRendererPools.get(picturesInPictureState.getClass());
|
|
+ if (pool == null) {
|
|
+ return false;
|
|
+ }
|
|
+ PictureInPictureRenderer<T> renderer = pool.get(picturesInPictureState, guiScale, firstPass);
|
|
if (renderer != null) {
|
|
renderer.prepare(picturesInPictureState, this.renderState, this.featureRenderDispatcher, guiScale);
|
|
+ return true;
|
|
}
|
|
+ return false;
|
|
}
|
|
|
|
private void submitBlitFromItemAtlas(GuiItemRenderState itemState, GuiItemAtlas.SlotView slotView) {
|
|
@@ -427,7 +_,7 @@
|
|
this.itemAtlas = null;
|
|
}
|
|
|
|
- this.pictureInPictureRenderers.values().forEach(PictureInPictureRenderer::close);
|
|
+ this.pictureInPictureRendererPools.values().forEach(net.neoforged.neoforge.client.gui.PictureInPictureRendererPool::close);
|
|
this.guiProjectionMatrixBuffer.close();
|
|
this.oversizedItemRenderers.values().forEach(PictureInPictureRenderer::close);
|
|
this.cubeMap.close();
|