rendering: animations: fix debug texture bug with mesa drivers

This commit is contained in:
Bixilon 2021-06-19 13:03:45 +02:00
parent 2ca3e66ac7
commit c00dbb101b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 14 additions and 8 deletions

View File

@ -175,7 +175,7 @@ class WorldRenderer(
}
override fun postInit() {
check(renderWindow.textures.animator.animatedTextures.size < TextureArray.MAX_ANIMATED_TEXTURE) { "Can not have more than ${TextureArray.MAX_ANIMATED_TEXTURE} animated textures!" }
check(renderWindow.textures.animator.animatedTextures.size < TextureArray.MAX_ANIMATED_TEXTURES) { "Can not have more than ${TextureArray.MAX_ANIMATED_TEXTURES} animated textures!" }
chunkShader = Shader(
renderWindow = renderWindow,
resourceLocation = ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "chunk"),

View File

@ -162,6 +162,10 @@ class Shader(
glUniformBlockBinding(programId, glGetUniformBlockIndex(programId, uniformName), bindingIndex)
}
fun getLog(): String {
return glGetShaderInfoLog(programId)
}
companion object {
private val DEFAULT_DEFINES: Map<String, (renderWindow: RenderWindow) -> Any?> = mapOf(
@ -173,7 +177,7 @@ class Shader(
}
},
"ANIMATED_TEXTURE_COUNT" to {
MMath.clamp(it.textures.animator.animatedTextures.size, 1, TextureArray.MAX_ANIMATED_TEXTURE)
MMath.clamp(it.textures.animator.animatedTextures.size, 1, TextureArray.MAX_ANIMATED_TEXTURES)
}
)
private var currentShaderInUse: Shader? = null // ToDo: This is not safe todo

View File

@ -27,7 +27,7 @@ import java.io.FileNotFoundException
import java.nio.ByteBuffer
class Texture(
data class Texture(
val resourceLocation: ResourceLocation,
) {
var arrayId = -1

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.textures
import de.bixilon.minosoft.gui.rendering.textures.properties.AnimationFrame
class TextureAnimation(
data class TextureAnimation(
val texture: Texture,
) {
var currentFrameIndex = 0

View File

@ -25,9 +25,7 @@ import de.matthiasmann.twl.utils.PNGDecoder
import glm_.vec2.Vec2
import glm_.vec2.Vec2i
import org.lwjgl.BufferUtils
import org.lwjgl.opengl.GL30.*
import org.lwjgl.opengl.GL31.GL_UNIFORM_BUFFER
import org.lwjgl.opengl.GL31.glBindBuffer
import org.lwjgl.opengl.GL31.*
import java.nio.ByteBuffer
class TextureArray(val allTextures: MutableMap<ResourceLocation, Texture>) {
@ -327,6 +325,7 @@ class TextureArray(val allTextures: MutableMap<ResourceLocation, Texture>) {
shader.use()
shader.setUniformBuffer(bufferName, 0)
glBindBufferBase(GL_UNIFORM_BUFFER, 0, animatedBufferDataId)
}
private fun uploadAnimatedStorageBuffer() {
@ -337,7 +336,7 @@ class TextureArray(val allTextures: MutableMap<ResourceLocation, Texture>) {
}
companion object {
const val MAX_ANIMATED_TEXTURE = 4096 // 16kb / 4 (ints per animation)
const val MAX_ANIMATED_TEXTURES = 1024 // 16kb / 4 (ints per animation) / 4 bytes per int
val TEXTURE_RESOLUTION_ID_MAP = arrayOf(16, 32, 64, 128, 256, 512, 1024) // A 12x12 texture will be saved in texture id 0 (in 0 are only 16x16 textures). Animated textures get split
const val TEXTURE_MAX_RESOLUTION = 1024
const val MAX_MIPMAP_LEVELS = 5

View File

@ -103,6 +103,9 @@ object Log {
ChatComponent.of(stringWriter.toString(), ignoreJson = true)
}
is String -> {
if (message.isBlank()) {
return
}
if (formatting.isNotEmpty()) {
ChatComponent.of(message.format(*formatting), ignoreJson = true)
} else {