Class PictureInPictureRendererPool<T extends PictureInPictureRenderState>
java.lang.Object
net.neoforged.neoforge.client.gui.PictureInPictureRendererPool<T>
- All Implemented Interfaces:
AutoCloseable
@Internal
public class PictureInPictureRendererPool<T extends PictureInPictureRenderState>
extends Object
implements AutoCloseable
Pools
PictureInPictureRenderer for a single type of PictureInPictureRenderState and tries
to reuse renderers on subsequent frames.
Vanilla only ever uses one PIP renderer per PIP state type. This can lead to crashes or visual artifacts, since the backing render target textures are stored within the renderer, and if two or more of the same type of state are submitted in one frame, the states will begin interfering with each other.
We solve this by using one renderer per distinct PictureInPictureRenderState state per frame,
and use this class to pool them for reuse in subsequent frames.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MultiBufferSource.BufferSourceprivate final PictureInPictureRendererRegistration<T> private it.unimi.dsi.fastutil.objects.Object2ObjectMap<T, PictureInPictureRenderer<T>> private it.unimi.dsi.fastutil.objects.Object2ObjectMap<T, PictureInPictureRenderer<T>> -
Constructor Summary
ConstructorsConstructorDescriptionPictureInPictureRendererPool(PictureInPictureRendererRegistration<T> factory, MultiBufferSource.BufferSource buffers) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()static Map<Class<? extends PictureInPictureRenderState>, PictureInPictureRendererPool<?>> createPools(MultiBufferSource.BufferSource bufferSource, List<PictureInPictureRendererRegistration<?>> pipRendererFactories) @Nullable PictureInPictureRenderer<T>
-
Field Details
-
factory
-
buffers
-
renderersLastFrame
private it.unimi.dsi.fastutil.objects.Object2ObjectMap<T extends PictureInPictureRenderState,PictureInPictureRenderer<T extends PictureInPictureRenderState>> renderersLastFrame -
renderersThisFrame
private it.unimi.dsi.fastutil.objects.Object2ObjectMap<T extends PictureInPictureRenderState,PictureInPictureRenderer<T extends PictureInPictureRenderState>> renderersThisFrame
-
-
Constructor Details
-
PictureInPictureRendererPool
public PictureInPictureRendererPool(PictureInPictureRendererRegistration<T> factory, MultiBufferSource.BufferSource buffers)
-
-
Method Details
-
get
@Nullable public @Nullable PictureInPictureRenderer<T> get(T state, int guiScale, boolean firstPass) -
clearUnusedRenderers
public void clearUnusedRenderers() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
createPools
public static Map<Class<? extends PictureInPictureRenderState>,PictureInPictureRendererPool<?>> createPools(MultiBufferSource.BufferSource bufferSource, List<PictureInPictureRendererRegistration<?>> pipRendererFactories)
-