Merge branch 'refs/heads/fix-shader-building-mesa'

This commit is contained in:
Moritz Zwerger 2024-04-23 17:46:55 +02:00
commit af79d23851
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
8 changed files with 27 additions and 9 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger * Copyright (C) 2020-2024 Moritz Zwerger
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* *
@ -37,4 +37,10 @@ class AdvancedC(profile: RenderingProfile) {
* Requires rendering restart to apply * Requires rendering restart to apply
*/ */
var preferQuads by BooleanDelegate(profile, false) var preferQuads by BooleanDelegate(profile, false)
/**
* This option makes shader uniform errors just warnings and does not crash it. This only helps if there is a driver bug or the included shader does not follow
* the specs strictly. Not recommended to enable.
*/
var allowUniformErrors by BooleanDelegate(profile, false)
} }

View File

@ -68,7 +68,8 @@ class FogManager(
if (state.enabled != enabled) { if (state.enabled != enabled) {
state.revision++ state.revision++
} }
if (!state.enabled) return state.enabled = enabled
if (!enabled) return
val options = getOptions(effects!!) val options = getOptions(effects!!)
if (this.options == options) { if (this.options == options) {

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger * Copyright (C) 2020-2024 Moritz Zwerger
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* *
@ -54,5 +54,4 @@ class ShaderUniform<T>(
upload() upload()
} }
} }
} }

View File

@ -28,6 +28,9 @@ import de.bixilon.minosoft.gui.rendering.exceptions.ShaderLoadingException
import de.bixilon.minosoft.gui.rendering.system.base.buffer.uniform.UniformBuffer import de.bixilon.minosoft.gui.rendering.system.base.buffer.uniform.UniformBuffer
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
import de.bixilon.minosoft.gui.rendering.system.base.shader.code.glsl.GLSLShaderCode import de.bixilon.minosoft.gui.rendering.system.base.shader.code.glsl.GLSLShaderCode
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntArrayList
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
import org.lwjgl.opengl.GL11.GL_FALSE import org.lwjgl.opengl.GL11.GL_FALSE
@ -129,7 +132,11 @@ class OpenGLNativeShader(
val location = uniformLocations.getOrPut(uniformName) { val location = uniformLocations.getOrPut(uniformName) {
val location = glGetUniformLocation(handler, uniformName) val location = glGetUniformLocation(handler, uniformName)
if (location < 0) { if (location < 0) {
throw IllegalArgumentException("No uniform named $uniformName in $this, maybe you use something that has been optimized out? Check your shader code!") val error = "No uniform named $uniformName in $this, maybe you use something that has been optimized out? Check your shader code!"
if (!context.profile.advanced.allowUniformErrors) {
throw IllegalArgumentException(error)
}
Log.log(LogMessageType.RENDERING, LogLevels.WARN, error)
} }
return@getOrPut location return@getOrPut location
} }

View File

@ -21,6 +21,7 @@ uniform vec3 uCameraRight;
uniform vec3 uCameraUp; uniform vec3 uCameraUp;
out vec4 finTintColor; out vec4 finTintColor;
out vec3 finFragmentPosition;
in Vertex in Vertex
{ {
@ -41,8 +42,9 @@ in Vertex
void emit(vec3 offset, vec2 uv) { void emit(vec3 offset, vec2 uv) {
vec3 pointPosition = gl_in[0].gl_Position.xyz; vec3 pointPosition = gl_in[0].gl_Position.xyz;
finFragmentPosition = pointPosition + (offset * ginVertex[0].scale);
gl_Position = uViewProjectionMatrix * vec4(pointPosition + offset * ginVertex[0].scale, 1.0); gl_Position = uViewProjectionMatrix * vec4(finFragmentPosition, 1.0f);
finAnimationUV = uv; finAnimationUV = uv;
EmitVertex(); EmitVertex();

View File

@ -23,7 +23,8 @@ uniform vec4 uTintColor;
void main() { void main() {
applyTexel(); applyDefaults();
foutColor *= uTintColor; foutColor *= uTintColor;
discard_alpha(); discard_alpha();
applyTexel();
} }

View File

@ -23,6 +23,7 @@ uniform vec4 uTintColor;
#include "minosoft:animation" #include "minosoft:animation"
void main() { void main() {
applyDefaults();
foutColor.rgb *= uTintColor.rgb;
applyTexel(); applyTexel();
foutColor *= uTintColor;
} }

View File

@ -24,6 +24,7 @@ uniform vec4 uTintColor;
#include "minosoft:animation" #include "minosoft:animation"
void main() { void main() {
applyTexel(); applyDefaults();
foutColor *= uTintColor; foutColor *= uTintColor;
applyTexel();
} }