mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 09:26:11 -04:00
option to disable compressed font textures
That can workaround issues on some gpus
This commit is contained in:
parent
dc575601a9
commit
803cdcc552
@ -20,7 +20,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.FontTextureArray
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayProperties
|
||||
|
||||
class DummyFontTextureArray(context: RenderContext) : FontTextureArray(context, 1024) {
|
||||
class DummyFontTextureArray(context: RenderContext) : FontTextureArray(context, 1024, false) {
|
||||
override fun load(latch: AbstractLatch) {
|
||||
for (texture in textures) {
|
||||
texture.renderData = DummyTextureRenderData
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.config.profile.profiles.rendering.textures
|
||||
|
||||
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
|
||||
import de.bixilon.minosoft.config.profile.delegate.primitive.IntDelegate
|
||||
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfile
|
||||
|
||||
@ -22,4 +23,10 @@ class TexturesC(profile: RenderingProfile) {
|
||||
* Weather to use mipmaps for all static textures
|
||||
*/
|
||||
var mipmaps by IntDelegate(profile, 4, arrayOf(0..4))
|
||||
|
||||
/**
|
||||
* Font texture can be compressed on the gpu which massively reduces vram usage.
|
||||
* It may not work with all drivers well, so disable it when font is just black.
|
||||
*/
|
||||
var compressedFont by BooleanDelegate(profile, true)
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||
abstract class FontTextureArray(
|
||||
val context: RenderContext,
|
||||
val resolution: Int,
|
||||
val compressed: Boolean,
|
||||
) : TextureArray {
|
||||
protected val textures: MutableSet<Texture> = mutableSetOf()
|
||||
private val lock = SimpleLock()
|
||||
|
@ -35,7 +35,8 @@ import java.nio.ByteBuffer
|
||||
|
||||
class OpenGLFontTextureArray(
|
||||
context: RenderContext,
|
||||
) : FontTextureArray(context, RESOLUTION) {
|
||||
compressed: Boolean,
|
||||
) : FontTextureArray(context, RESOLUTION, compressed) {
|
||||
val index = context.system.unsafeCast<OpenGLRenderSystem>().textureBindingIndex++
|
||||
private var handle = -1
|
||||
private var textureIndex = 0
|
||||
@ -43,9 +44,10 @@ class OpenGLFontTextureArray(
|
||||
|
||||
override fun upload(latch: AbstractLatch?) {
|
||||
this.handle = OpenGLTextureUtil.createTextureArray(0)
|
||||
val format = if (compressed) GL_COMPRESSED_LUMINANCE_ALPHA else GL_RGBA8
|
||||
// glTexParameteriv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_RGBA, intArrayOf(GL_LUMINANCE, GL_LUMINANCE, GL_LUMINANCE, GL_LUMINANCE)) // TODO: not working?
|
||||
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_LUMINANCE_ALPHA, RESOLUTION, RESOLUTION, textures.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, null as ByteBuffer?)
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, format, RESOLUTION, RESOLUTION, textures.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, null as ByteBuffer?)
|
||||
|
||||
for (texture in textures) {
|
||||
val renderData = texture.renderData as OpenGLTextureData
|
||||
|
@ -19,8 +19,8 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager
|
||||
import de.bixilon.minosoft.gui.rendering.system.opengl.texture.dynamic.OpenGLDynamicTextureArray
|
||||
|
||||
class OpenGLTextureManager(val context: RenderContext) : TextureManager() {
|
||||
private val mipmaps = context.connection.profiles.rendering.textures.mipmaps
|
||||
override val static = OpenGLTextureArray(context, true, mipmaps)
|
||||
override val dynamic = OpenGLDynamicTextureArray(context, context.system.unsafeCast(), resolution = 64, mipmaps = mipmaps)
|
||||
override val font = OpenGLFontTextureArray(context)
|
||||
private val config = context.connection.profiles.rendering.textures
|
||||
override val static = OpenGLTextureArray(context, true, config.mipmaps)
|
||||
override val dynamic = OpenGLDynamicTextureArray(context, context.system.unsafeCast(), resolution = 64, mipmaps = config.mipmaps)
|
||||
override val font = OpenGLFontTextureArray(context, config.compressedFont)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user