2025-11-24 22:52:51 +03:00

65 lines
2.0 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* it.unimi.dsi.fastutil.ints.Int2IntMap
* it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap
* it.unimi.dsi.fastutil.ints.IntIterator
* org.jspecify.annotations.Nullable
*/
package com.mojang.blaze3d.opengl;
import com.mojang.blaze3d.opengl.DirectStateAccess;
import com.mojang.blaze3d.opengl.GlStateManager;
import com.mojang.blaze3d.opengl.GlTexture;
import com.mojang.blaze3d.textures.GpuTexture;
import com.mojang.blaze3d.textures.GpuTextureView;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntIterator;
import org.jspecify.annotations.Nullable;
public class GlTextureView
extends GpuTextureView {
private boolean closed;
private final Int2IntMap fboCache = new Int2IntOpenHashMap();
protected GlTextureView(GlTexture texture, int baseMipLevel, int mipLevels) {
super(texture, baseMipLevel, mipLevels);
texture.addViews();
}
@Override
public boolean isClosed() {
return this.closed;
}
@Override
public void close() {
if (!this.closed) {
this.closed = true;
this.texture().removeViews();
IntIterator intIterator = this.fboCache.values().iterator();
while (intIterator.hasNext()) {
int fbo = (Integer)intIterator.next();
GlStateManager._glDeleteFramebuffers(fbo);
}
}
}
public int getFbo(DirectStateAccess dsa, @Nullable GpuTexture depth) {
int depthid = depth == null ? 0 : ((GlTexture)depth).id;
return this.fboCache.computeIfAbsent(depthid, ignored -> {
int fbo = dsa.createFrameBufferObject();
dsa.bindFrameBufferTextures(fbo, this.texture().id, depthid, this.baseMipLevel(), 0);
return fbo;
});
}
@Override
public GlTexture texture() {
return (GlTexture)super.texture();
}
}