From 7eb31a920506f7c25ed3ce79ac44dcf06d3fca82 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 30 Mar 2023 20:48:20 +0200 Subject: Graph GLSL: Enable 'discard' in fragment shader w/o GLRendererQuirks.GLSLBuggyDiscard to avoid overdraw of such regions. Historically we disabled `discard` due to an old NV tegra2 compiler bug, which caused the compiler to freeze. Today we no more seem to have this GLSL compiler issue, i.e. GLRendererQuirks.GLSLBuggyDiscard never gets set. --- .../com/jogamp/graph/curve/opengl/RegionRenderer.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java') diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java index b24cc3230..a9fca4c72 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -40,6 +40,7 @@ import jogamp.graph.curve.opengl.shader.AttributeNames; import jogamp.graph.curve.opengl.shader.UniformNames; import com.jogamp.opengl.GLExtensions; +import com.jogamp.opengl.GLRendererQuirks; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.TextureSequence; @@ -374,12 +375,13 @@ public final class RegionRenderer { private static final String SHADER_SRC_SUB = ""; private static final String SHADER_BIN_SUB = "bin"; - private static String GLSL_USE_COLOR_CHANNEL = "#define USE_COLOR_CHANNEL 1\n"; - private static String GLSL_USE_COLOR_TEXTURE = "#define USE_COLOR_TEXTURE 1\n"; - private static String GLSL_DEF_SAMPLE_COUNT = "#define SAMPLE_COUNT "; - private static String GLSL_CONST_SAMPLE_COUNT = "const float sample_count = "; - private static String GLSL_MAIN_BEGIN = "void main (void)\n{\n"; + private static final String GLSL_USE_COLOR_CHANNEL = "#define USE_COLOR_CHANNEL 1\n"; + private static final String GLSL_USE_COLOR_TEXTURE = "#define USE_COLOR_TEXTURE 1\n"; + private static final String GLSL_DEF_SAMPLE_COUNT = "#define SAMPLE_COUNT "; + private static final String GLSL_CONST_SAMPLE_COUNT = "const float sample_count = "; + private static final String GLSL_MAIN_BEGIN = "void main (void)\n{\n"; private static final String gcuTexture2D = "gcuTexture2D"; + private static final String GLSL_USE_DISCARD = "#define USE_DISCARD 1\n"; private String getVersionedShaderName() { return "curverenderer01"; @@ -587,6 +589,10 @@ public final class RegionRenderer { // GLSL append from here on posFp = -1; + if( !gl.getContext().hasRendererQuirk(GLRendererQuirks.GLSLBuggyDiscard) ) { + posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_DISCARD); + } + if( hasColorChannel ) { posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_CHANNEL); posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_CHANNEL); -- cgit v1.2.3