From ca14c6b3d5e53f6eda31ab6112b6b1705c5b31e5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 9 Apr 2012 05:36:33 +0200 Subject: ShaderUtil: isProgramValid() -> isProgramLinkStatusValid() + isProgramExecStatusValid() isProgramValid() was testing whether the linkx status is valid and whether the executable environment is valid for the shader, see glValidateProgram(). glValidateProgram() may fail on some implementations in some circumstances (APX2500 and Tegra2) and indeed require all resources are set for execution of the shader program (glDraw*). This is not a requirement for issueing useProgram(), hence removed this test and made it available explicit for debugging purposes: isProgramExecStatusValid(). --- .../com/jogamp/opengl/util/glsl/ShaderProgram.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java') diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java index 22c582865..14ea7d2b8 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java @@ -214,7 +214,7 @@ public class ShaderProgram { gl.glLinkProgram(shaderProgram); - programLinked = ShaderUtil.isProgramValid(gl, shaderProgram, System.err); + programLinked = ShaderUtil.isProgramLinkStatusValid(gl, shaderProgram, System.err); if ( programLinked && shaderWasInUse ) { useProgram(gl, true); } @@ -250,7 +250,7 @@ public class ShaderProgram { // Link the program gl.glLinkProgram(shaderProgram); - programLinked = ShaderUtil.isProgramValid(gl, shaderProgram, System.err); + programLinked = ShaderUtil.isProgramLinkStatusValid(gl, shaderProgram, System.err); return programLinked; } @@ -284,9 +284,17 @@ public class ShaderProgram { return toString(null).toString(); } + /** + * Performs {@link GL2ES2#glValidateProgram(int)} via {@link ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream)}. + * @see ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream) + **/ + public synchronized boolean validateProgram(GL2ES2 gl, PrintStream verboseOut) { + return ShaderUtil.isProgramExecStatusValid(gl, shaderProgram, verboseOut); + } + public synchronized void useProgram(GL2ES2 gl, boolean on) { - if(!programLinked) throw new GLException("Program is not linked"); - if(programInUse==on) return; + if(!programLinked) { throw new GLException("Program is not linked"); } + if(programInUse==on) { return; } gl.glUseProgram(on?shaderProgram:0); programInUse = on; } -- cgit v1.2.3