aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorphil <[email protected]>2016-12-20 10:42:23 +1300
committerphil <[email protected]>2016-12-20 10:42:23 +1300
commit1d97bad7e361449748ec2c17b29463aa95b58faf (patch)
tree8c02cc6276b2f6a955437827d85503c729c91fba /src/main
parentde203c933dd32e11929808e84b7a904ab584f6f9 (diff)
Jogl2es2Pipeline: determining the presence of data structures in shaders
simplified And made faster
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/jogamp/java3d/Jogl2es2Context.java16
-rw-r--r--src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java20
2 files changed, 22 insertions, 14 deletions
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Context.java b/src/main/java/org/jogamp/java3d/Jogl2es2Context.java
index 2f5b0cd..cb41505 100644
--- a/src/main/java/org/jogamp/java3d/Jogl2es2Context.java
+++ b/src/main/java/org/jogamp/java3d/Jogl2es2Context.java
@@ -416,6 +416,7 @@ public class Jogl2es2Context extends JoglContext
public static class glFrontMaterialLocs
{
+ public boolean present = false;
public int lightEnabled = -1;
public int ambient = -1;
public int diffuse = -1;
@@ -423,9 +424,9 @@ public class Jogl2es2Context extends JoglContext
public int specular = -1;
public int shininess = -1;
- public boolean present()
+ public void setPresent()
{
- return lightEnabled != -1 || ambient != -1 || diffuse != -1 || emission != -1 || specular != -1 || shininess != -1;
+ present = lightEnabled != -1 || ambient != -1 || diffuse != -1 || emission != -1 || specular != -1 || shininess != -1;
}
}
// struct lightSource
@@ -517,12 +518,6 @@ public class Jogl2es2Context extends JoglContext
public int spotCutoff = -1;
public int spotExponent = -1;
public int spotDirection = -1;
-
- public boolean present()
- {
- return position != -1 || diffuse != -1 || specular != -1 || constantAttenuation != -1 || linearAttenuation != -1
- || quadraticAttenuation != -1 || spotCutoff != -1 || spotExponent != -1 || spotDirection != -1;
- }
}
// in the shader as follows
@@ -583,6 +578,7 @@ public class Jogl2es2Context extends JoglContext
public static class fogDataLocs
{
+ public boolean present = false;
public int fogEnabled = -1;
public int expColor = -1;
public int expDensity = -1;
@@ -590,9 +586,9 @@ public class Jogl2es2Context extends JoglContext
public int linearStart = -1;
public int linearEnd = -1;
- public boolean present()
+ public void setPresent()
{
- return fogEnabled != -1 || expColor != -1 || expDensity != -1 || linearColor != -1 || linearStart != -1 || linearEnd != -1;
+ present = fogEnabled != -1 || expColor != -1 || expDensity != -1 || linearColor != -1 || linearStart != -1 || linearEnd != -1;
}
}
}
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
index 31b1517..a3311a2 100644
--- a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
+++ b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
@@ -3127,7 +3127,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// the front material structure
- if (locs.glFrontMaterial.present())
+ if (locs.glFrontMaterial.present)
{
//note != not equals
if (locs.glFrontMaterial.lightEnabled != -1 && (shaderProgramId != ctx.prevShaderProgram
@@ -3331,7 +3331,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// Fog
- if (locs.fogData.present())
+ if (locs.fogData.present && locs.fogData.fogEnabled != -1)
{
if (!MINIMISE_NATIVE_CALLS_FFP || shaderProgramId != ctx.prevShaderProgram
|| ctx.gl_state.fogData.fogEnabled != ctx.fogData.fogEnabled)
@@ -3416,6 +3416,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
locs.fogData.linearColor = gl.glGetUniformLocation(shaderProgramId, "fogData.linearColor");
locs.fogData.linearStart = gl.glGetUniformLocation(shaderProgramId, "fogData.linearStart");
locs.fogData.linearEnd = gl.glGetUniformLocation(shaderProgramId, "fogData.linearEnd");
+ locs.fogData.setPresent();
locs.glFrontMaterial.lightEnabled = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.lightEnabled");
locs.glFrontMaterial.ambient = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.ambient");
@@ -3423,14 +3424,19 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
locs.glFrontMaterial.emission = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.emission");
locs.glFrontMaterial.specular = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.specular");
locs.glFrontMaterial.shininess = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.shininess");
+ locs.glFrontMaterial.setPresent();
locs.numberOfLights = gl.glGetUniformLocation(shaderProgramId, "numberOfLights");
// lights, notice the vertex attribute is made of a string concat
+ // notice we stop once the light loc is not found, as that is the max the shader will accept
for (int i = 0; i < locs.glLightSource.length; i++)
{
+ int position = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].position");
+ if (position != -1)
+ {
locs.glLightSource[i] = new glLightSourceLocs();
- locs.glLightSource[i].position = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].position");
+ locs.glLightSource[i].position = position;
locs.glLightSource[i].diffuse = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].diffuse");
locs.glLightSource[i].specular = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].specular");
locs.glLightSource[i].constantAttenuation = gl.glGetUniformLocation(shaderProgramId,
@@ -3440,10 +3446,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
locs.glLightSource[i].quadraticAttenuation = gl.glGetUniformLocation(shaderProgramId,
"glLightSource[" + i + "].quadraticAttenuation");
locs.glLightSource[i].spotCutoff = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].spotCutoff");
- locs.glLightSource[i].spotExponent = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].spotExponent");
+ locs.glLightSource[i].spotExponent = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].spotExponent");
locs.glLightSource[i].spotDirection = gl.glGetUniformLocation(shaderProgramId,
"glLightSource[" + i + "].spotDirection");
}
+ else
+ {
+ break;
+ }
+ }
///////ATTRIBUTES!!!!!!!!///////////////////
locs.glVertex = gl.glGetAttribLocation(shaderProgramId, "glVertex");