aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share/javax
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2007-03-30 18:40:14 +0000
committerKevin Rushforth <[email protected]>2007-03-30 18:40:14 +0000
commit9b3fbbb7fcc6ac43d7df7d4aa785b6122c26a667 (patch)
tree329d074bbcacbff90236d8693c1b6091c4d3cfb3 /src/classes/share/javax
parent47740959525d6d650a9a2d25be5f327909c211c2 (diff)
Fixed issue 471: Performance degradation with shader attribute object setValue()
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@806 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/share/javax')
-rw-r--r--src/classes/share/javax/media/j3d/RenderBin.java21
-rw-r--r--src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java15
-rw-r--r--src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java4
-rw-r--r--src/classes/share/javax/media/j3d/ShaderAttributeRetained.java5
-rw-r--r--src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java21
-rw-r--r--src/classes/share/javax/media/j3d/ShaderConstants.java38
6 files changed, 64 insertions, 40 deletions
diff --git a/src/classes/share/javax/media/j3d/RenderBin.java b/src/classes/share/javax/media/j3d/RenderBin.java
index 56d77fe..76ad4b6 100644
--- a/src/classes/share/javax/media/j3d/RenderBin.java
+++ b/src/classes/share/javax/media/j3d/RenderBin.java
@@ -2407,17 +2407,16 @@ class RenderBin extends J3dStructure implements ObjectUpdate {
}
if (start >= 0) {
-
-
+ // Issue 471 - Don't check ATTRIBUTE_VALUE_UPDATE, there is no need
+ // to do anything to the shader bins when a value changes.
boolean spUpdate =
- ((component & ShaderAppearanceRetained.SHADER_PROGRAM) != 0);
+ ((component & ShaderConstants.SHADER_PROGRAM) != 0);
boolean sasUpdate =
- (((component & ShaderAppearanceRetained.SHADER_ATTRIBUTE_SET) != 0) ||
- ((component & ShaderAttributeSetRetained.ATTRIBUTE_SET_PUT) != 0) ||
- ((component & ShaderAttributeSetRetained.ATTRIBUTE_SET_REMOVE) != 0) ||
- ((component & ShaderAttributeSetRetained.ATTRIBUTE_SET_CLEAR) != 0) ||
- ((component & ShaderAttributeRetained.SHADER_ATTRIBUTE_VALUE_UPDATE) != 0));
-
+ (((component & ShaderConstants.SHADER_ATTRIBUTE_SET) != 0) ||
+ ((component & ShaderConstants.ATTRIBUTE_SET_PUT) != 0) ||
+ ((component & ShaderConstants.ATTRIBUTE_SET_REMOVE) != 0) ||
+ ((component & ShaderConstants.ATTRIBUTE_SET_CLEAR) != 0));
+
if (spUpdate) {
/* TODO : JADA - Sole user logic is incomplete. Will disable for JavaOne */
//if (false && (sApp.mirror.changedFrequent & component) != 0) {
@@ -2499,9 +2498,9 @@ class RenderBin extends J3dStructure implements ObjectUpdate {
}
}
}
-
+
}
-
+
void processFogChanged(Object[] args) {
FogRetained fog = (FogRetained)args[0];
diff --git a/src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java b/src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java
index a03754f..5709ade 100644
--- a/src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java
+++ b/src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java
@@ -32,9 +32,6 @@ class ShaderAppearanceRetained extends AppearanceRetained {
protected ShaderAttributeSetRetained shaderAttributeSet = null;
protected boolean isMirror = false; // For Debugging.
- static final int SHADER_PROGRAM = 0x0800;
- static final int SHADER_ATTRIBUTE_SET = 0x1000;
-
/**
* Set the shader program object to the specified object.
* @param shaderProgram object that specifies the desired shader program
@@ -56,7 +53,7 @@ class ShaderAppearanceRetained extends AppearanceRetained {
((ShaderProgramRetained)sp.retained).copyMirrorUsers(this);
}
- sendMessage(SHADER_PROGRAM,
+ sendMessage(ShaderConstants.SHADER_PROGRAM,
(sp != null ? ((ShaderProgramRetained)sp.retained).mirror : null));
}
@@ -102,7 +99,7 @@ class ShaderAppearanceRetained extends AppearanceRetained {
}
// System.out.println(" -- testing needed!");
- sendMessage(SHADER_ATTRIBUTE_SET,
+ sendMessage(ShaderConstants.SHADER_ATTRIBUTE_SET,
(sas != null ?
((ShaderAttributeSetRetained)sas.retained).mirror : null));
@@ -209,10 +206,10 @@ class ShaderAppearanceRetained extends AppearanceRetained {
// System.out.println("ShaderAppearanceRetained : updateMirrorObject() this " + this);
super.updateMirrorObject(component, value);
ShaderAppearanceRetained mirrorApp = (ShaderAppearanceRetained)mirror;
- if ((component & SHADER_PROGRAM) != 0) {
+ if ((component & ShaderConstants.SHADER_PROGRAM) != 0) {
mirrorApp.shaderProgram = (ShaderProgramRetained)value;
}
- else if ((component & SHADER_ATTRIBUTE_SET) != 0) {
+ else if ((component & ShaderConstants.SHADER_ATTRIBUTE_SET) != 0) {
mirrorApp.shaderAttributeSet = (ShaderAttributeSetRetained)value;
}
@@ -359,9 +356,9 @@ class ShaderAppearanceRetained extends AppearanceRetained {
int mask = 0;
if (bit == ShaderAppearance.ALLOW_SHADER_PROGRAM_WRITE)
- mask = SHADER_PROGRAM;
+ mask = ShaderConstants.SHADER_PROGRAM;
else if (bit == ShaderAppearance.ALLOW_SHADER_ATTRIBUTE_SET_WRITE)
- mask = SHADER_ATTRIBUTE_SET;
+ mask = ShaderConstants.SHADER_ATTRIBUTE_SET;
if (mask != 0)
diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java
index b539c50..df2f254 100644
--- a/src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java
+++ b/src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java
@@ -80,7 +80,7 @@ abstract class ShaderAttributeObjectRetained extends ShaderAttributeRetained {
void setValue(Object value) {
initValue(value);
AttrWrapper valueWrapper = createAttrWrapper(value, this.classType);
- sendMessage(SHADER_ATTRIBUTE_VALUE_UPDATE, valueWrapper);
+ sendMessage(ShaderConstants.ATTRIBUTE_VALUE_UPDATE, valueWrapper);
}
/**
@@ -112,7 +112,7 @@ abstract class ShaderAttributeObjectRetained extends ShaderAttributeRetained {
//System.out.println("ShaderAttributeObjectRetained : updateMirrorObject");
ShaderAttributeObjectRetained mirrorSAV = (ShaderAttributeObjectRetained)mirror;
- if ((component & SHADER_ATTRIBUTE_VALUE_UPDATE) != 0) {
+ if ((component & ShaderConstants.ATTRIBUTE_VALUE_UPDATE) != 0) {
//System.out.println(" -- SHADER_ATTRIBUTE_VALUE_UPDATE");
mirrorSAV.attrWrapper = (AttrWrapper) value;
}
diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeRetained.java
index 0af9ddd..a3876c5 100644
--- a/src/classes/share/javax/media/j3d/ShaderAttributeRetained.java
+++ b/src/classes/share/javax/media/j3d/ShaderAttributeRetained.java
@@ -20,10 +20,7 @@ import javax.vecmath.*;
*/
abstract class ShaderAttributeRetained extends NodeComponentRetained {
- // A list of pre-defined bits to indicate which component
- // in this ShaderAttribute object changed.
- static final int SHADER_ATTRIBUTE_VALUE_UPDATE = 0x001;
-
+
/**
* Name of the shader attribute (immutable)
*/
diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java
index 7a2d928..3910d6f 100644
--- a/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java
+++ b/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java
@@ -24,13 +24,6 @@ import javax.vecmath.*;
*/
class ShaderAttributeSetRetained extends NodeComponentRetained {
- // A list of pre-defined bits to indicate which attribute
- // operation in this ShaderAttributeSet object is needed.
- static final int ATTRIBUTE_SET_PUT = 0x01;
-
- static final int ATTRIBUTE_SET_REMOVE = 0x02;
-
- static final int ATTRIBUTE_SET_CLEAR = 0x04;
private Map attrs = new HashMap();
@@ -70,7 +63,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained {
sAttr.setLive(inBackgroundGroup, refCount);
sAttr.copyMirrorUsers(this);
- sendMessage(ATTRIBUTE_SET_PUT, sAttr.mirror);
+ sendMessage(ShaderConstants.ATTRIBUTE_SET_PUT, sAttr.mirror);
}
}
}
@@ -104,7 +97,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained {
sAttr.clearLive(refCount);
sAttr.removeMirrorUsers(this);
- sendMessage(ATTRIBUTE_SET_REMOVE, attrName);
+ sendMessage(ShaderConstants.ATTRIBUTE_SET_REMOVE, attrName);
}
}
}
@@ -129,7 +122,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained {
((ShaderAttributeRetained)attr.retained).clearLive(refCount);
((ShaderAttributeRetained)attr.retained).removeMirrorUsers(this);
- sendMessage(ATTRIBUTE_SET_REMOVE, attrName);
+ sendMessage(ShaderConstants.ATTRIBUTE_SET_REMOVE, attrName);
}
}
}
@@ -150,7 +143,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained {
sAttrs[i].clearLive(refCount);
sAttrs[i].removeMirrorUsers(this);
}
- sendMessage(ATTRIBUTE_SET_CLEAR, null);
+ sendMessage(ShaderConstants.ATTRIBUTE_SET_CLEAR, null);
}
}
}
@@ -293,17 +286,17 @@ class ShaderAttributeSetRetained extends NodeComponentRetained {
ShaderAttributeSetRetained mirrorSAS = (ShaderAttributeSetRetained)mirror;
- if ((component & ATTRIBUTE_SET_PUT) != 0) {
+ if ((component & ShaderConstants.ATTRIBUTE_SET_PUT) != 0) {
// System.out.println(" -- ATTRIBUTE_SET_PUT");
ShaderAttributeRetained mirrorSA = (ShaderAttributeRetained)value;
assert(mirrorSA != null);
((ShaderAttributeSetRetained)mirror).attrs.put(mirrorSA.attrName, mirrorSA);
}
- else if((component & ATTRIBUTE_SET_REMOVE) != 0) {
+ else if((component & ShaderConstants.ATTRIBUTE_SET_REMOVE) != 0) {
// System.out.println(" -- ATTRIBUTE_SET_REMOVE");
((ShaderAttributeSetRetained)mirror).attrs.remove((String)value);
}
- else if((component & ATTRIBUTE_SET_CLEAR) != 0) {
+ else if((component & ShaderConstants.ATTRIBUTE_SET_CLEAR) != 0) {
// System.out.println(" -- ATTRIBUTE_SET_CLEAR");
((ShaderAttributeSetRetained)mirror).attrs.clear();
}
diff --git a/src/classes/share/javax/media/j3d/ShaderConstants.java b/src/classes/share/javax/media/j3d/ShaderConstants.java
new file mode 100644
index 0000000..7c4a7e4
--- /dev/null
+++ b/src/classes/share/javax/media/j3d/ShaderConstants.java
@@ -0,0 +1,38 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Use is subject to license terms.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+package javax.media.j3d;
+
+/**
+ * The ShaderConstants class contains internal constants used by other
+ * Shader classes.
+ */
+class ShaderConstants extends Object {
+
+ //
+ // The following bits are used in the messages for various Shader objects.
+ //
+
+ // ShaderAppearance bits
+ static final int SHADER_PROGRAM = 0x0001;
+ static final int SHADER_ATTRIBUTE_SET = 0x0002;
+
+ // ShaderAttributeSet bits -- indicates which attribute
+ // operation in this ShaderAttributeSet object is needed.
+ static final int ATTRIBUTE_SET_PUT = 0x0004;
+ static final int ATTRIBUTE_SET_REMOVE = 0x0008;
+ static final int ATTRIBUTE_SET_CLEAR = 0x0010;
+
+ // ShaderAttribute bits
+ static final int ATTRIBUTE_VALUE_UPDATE = 0x0020;
+
+}