aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java16
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java68
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java2
4 files changed, 45 insertions, 45 deletions
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;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
index 51f62a886..bd4ba45c4 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
@@ -45,13 +45,11 @@ public class ShaderUtil {
static abstract class Impl {
public abstract String getShaderInfoLog(GL gl, int shaderObj);
public abstract String getProgramInfoLog(GL gl, int programObj);
- public abstract boolean isShaderStatusValid(GL gl, int shaderObj, int name);
public abstract boolean isShaderStatusValid(GL gl, int shaderObj, int name, PrintStream verboseOut);
- public abstract boolean isShaderStatusValid(GL gl, IntBuffer shaders, int name);
public abstract boolean isShaderStatusValid(GL gl, IntBuffer shaders, int name, PrintStream verboseOut);
public abstract boolean isProgramStatusValid(GL gl, int programObj, int name);
- public abstract boolean isProgramValid(GL gl, int programObj);
- public abstract boolean isProgramValid(GL gl, int programObj, PrintStream verboseOut);
+ public abstract boolean isProgramLinkStatusValid(GL gl, int programObj, PrintStream verboseOut);
+ public abstract boolean isProgramExecStatusValid(GL gl, int programObj, PrintStream verboseOut);
public abstract void createShader(GL gl, int type, IntBuffer shaders);
public abstract Set<Integer> getShaderBinaryFormats(GL gl);
public abstract boolean isShaderCompilerAvailable(GL gl);
@@ -103,10 +101,6 @@ public class ShaderUtil {
return new String(infoLogBytes, 0, charsWritten[0]);
}
- public boolean isShaderStatusValid(GL _gl, int shaderObj, int name) {
- return isShaderStatusValid(_gl, shaderObj, name, null);
- }
-
public boolean isShaderStatusValid(GL _gl, int shaderObj, int name, PrintStream verboseOut) {
GL2ES2 gl = _gl.getGL2ES2();
int[] ires = new int[1];
@@ -119,10 +113,6 @@ public class ShaderUtil {
return res;
}
- public boolean isShaderStatusValid(GL _gl, IntBuffer shaders, int name) {
- return isShaderStatusValid(_gl, shaders, name, null);
- }
-
public boolean isShaderStatusValid(GL _gl, IntBuffer shaders, int name, PrintStream verboseOut) {
boolean res = true;
for (int i = shaders.position(); i < shaders.limit(); i++) {
@@ -139,11 +129,7 @@ public class ShaderUtil {
return ires[0]==1;
}
- public boolean isProgramValid(GL _gl, int programObj) {
- return isProgramValid(_gl, programObj, null);
- }
-
- public boolean isProgramValid(GL _gl, int programObj, PrintStream verboseOut) {
+ public boolean isProgramLinkStatusValid(GL _gl, int programObj, PrintStream verboseOut) {
GL2ES2 gl = _gl.getGL2ES2();
if(!gl.glIsProgram(programObj)) {
if(null!=verboseOut) {
@@ -157,15 +143,17 @@ public class ShaderUtil {
}
return false;
}
- if ( !gl.isGLES2() || isShaderCompilerAvailable(gl) ) {
- // failed on APX2500 (ES2.0, no compiler) for valid programs
- gl.glValidateProgram(programObj);
- if(!isProgramStatusValid(gl, programObj, GL2ES2.GL_VALIDATE_STATUS)) {
- if(null!=verboseOut) {
- verboseOut.println("Program validation failed: "+programObj+"\n\t"+ getProgramInfoLog(gl, programObj));
- }
- return false;
+ return true;
+ }
+
+ public boolean isProgramExecStatusValid(GL _gl, int programObj, PrintStream verboseOut) {
+ GL2ES2 gl = _gl.getGL2ES2();
+ gl.glValidateProgram(programObj);
+ if(!isProgramStatusValid(gl, programObj, GL2ES2.GL_VALIDATE_STATUS)) {
+ if(null!=verboseOut) {
+ verboseOut.println("Program validation failed: "+programObj+"\n\t"+ getProgramInfoLog(gl, programObj));
}
+ return false;
}
return true;
}
@@ -379,18 +367,10 @@ public class ShaderUtil {
return getImpl(gl).getProgramInfoLog(gl, programObj);
}
- public static boolean isShaderStatusValid(GL gl, int shaderObj, int name) {
- return getImpl(gl).isShaderStatusValid(gl, shaderObj, name);
- }
-
public static boolean isShaderStatusValid(GL gl, int shaderObj, int name, PrintStream verboseOut) {
return getImpl(gl).isShaderStatusValid(gl, shaderObj, name, verboseOut);
}
- public static boolean isShaderStatusValid(GL gl, IntBuffer shaders, int name) {
- return getImpl(gl).isShaderStatusValid(gl, shaders, name);
- }
-
public static boolean isShaderStatusValid(GL gl, IntBuffer shaders, int name, PrintStream verboseOut) {
return getImpl(gl).isShaderStatusValid(gl, shaders, name, verboseOut);
}
@@ -399,12 +379,24 @@ public class ShaderUtil {
return getImpl(gl).isProgramStatusValid(gl, programObj, name);
}
- public static boolean isProgramValid(GL gl, int programObj) {
- return getImpl(gl).isProgramValid(gl, programObj);
+ public static boolean isProgramLinkStatusValid(GL gl, int programObj, PrintStream verboseOut) {
+ return getImpl(gl).isProgramLinkStatusValid(gl, programObj, verboseOut);
}
-
- public static boolean isProgramValid(GL gl, int programObj, PrintStream verboseOut) {
- return getImpl(gl).isProgramValid(gl, programObj, verboseOut);
+
+ /**
+ * Performs {@link GL2ES2#glValidateProgram(int)}
+ * <p>
+ * One shall only call this method while debugging and only if all required
+ * resources by the shader are set.
+ * </p>
+ * <p>
+ * Note: It is possible that a working shader program will fail validation.
+ * This has been experienced on NVidia APX2500 and Tegra2.
+ * </p>
+ * @see GL2ES2#glValidateProgram(int)
+ **/
+ public static boolean isProgramExecStatusValid(GL gl, int programObj, PrintStream verboseOut) {
+ return getImpl(gl).isProgramExecStatusValid(gl, programObj, verboseOut);
}
public static void createShader(GL gl, int type, IntBuffer shaders) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
index 2f6025a63..685ceeb2a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
@@ -126,7 +126,7 @@ public class TestTransformFeedbackVaryingsBug407NEWT extends UITestCase {
boolean error = false;
- if(!ShaderUtil.isProgramValid(gl, myShader.shaderProgram, pbaos)) {
+ if(!ShaderUtil.isProgramLinkStatusValid(gl, myShader.shaderProgram, pbaos)) {
System.out.println("Error (unexpected link error) - testGlTransformFeedbackVaryings_WhenVarNameOK:postLink: "+baos.toString());
error = true;
}
@@ -164,7 +164,7 @@ public class TestTransformFeedbackVaryingsBug407NEWT extends UITestCase {
boolean error = false;
- if(!ShaderUtil.isProgramValid(gl, myShader.shaderProgram, pbaos)) {
+ if(!ShaderUtil.isProgramLinkStatusValid(gl, myShader.shaderProgram, pbaos)) {
System.out.println("GOOD (expected link error) - testGlTransformFeedbackVaryings_WhenVarNameWrong:postLink: "+baos.toString());
// should be invalid, due to wrong var name
} else {
diff --git a/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java b/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java
index 047b04815..989de6c7e 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java
@@ -90,7 +90,7 @@ public class GLSLSimpleProgram {
if(link) {
gl.glLinkProgram(shaderProgram);
- if(!ShaderUtil.isProgramValid(gl, shaderProgram, pbaos)) {
+ if(!ShaderUtil.isProgramLinkStatusValid(gl, shaderProgram, pbaos)) {
System.out.println("Error (GLSL link error): "+baos.toString());
Assert.assertTrue(false);
}