aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com')
-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
2 files changed, 42 insertions, 42 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) {