aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-02-22 16:20:37 -0800
committerSiva Velusamy <vsiva@google.com>2012-02-22 16:23:25 -0800
commit27842cbb38c4f32fbf591b7174da37d8439238c8 (patch)
treedf713d072083a5fd1da4b919bd1ceee21826518b /eclipse
parentbe6b13695a55f688bd3bb0425bcc95cc22b4bd55 (diff)
downloadsdk-27842cbb38c4f32fbf591b7174da37d8439238c8.zip
sdk-27842cbb38c4f32fbf591b7174da37d8439238c8.tar.gz
sdk-27842cbb38c4f32fbf591b7174da37d8439238c8.tar.bz2
gltrace: Add support for generic vertex attributes.
Change-Id: I6eec29a0f48291324178d9e419cc10013274e0ff
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java31
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLStateType.java7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java148
3 files changed, 181 insertions, 5 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java
index dfc922a..690fb7e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java
@@ -25,6 +25,9 @@ public class GLState {
/** # of texture units modelled in the GL State. */
public static final int TEXTURE_UNIT_COUNT = 8;
+ /** # of vertex attributes */
+ private static final int MAX_VERTEX_ATTRIBS = 8;
+
private static GLState sGLState = new GLState();
private IGLProperty createBufferBindings() {
@@ -32,11 +35,11 @@ public class GLState {
array = new GLIntegerProperty(GLStateType.ARRAY_BUFFER_BINDING, 0);
eArray = new GLIntegerProperty(GLStateType.ELEMENT_ARRAY_BUFFER_BINDING, 0);
+
vArray = new GLIntegerProperty(
GLStateType.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_PER_INDEX, 0);
-
IGLProperty vArray8 = new GLListProperty(GLStateType.VERTEX_ATTRIB_ARRAY_BUFFER_BINDINGS,
- vArray, 8);
+ vArray, MAX_VERTEX_ATTRIBS);
return new GLCompositeProperty(
GLStateType.BUFFER_BINDINGS,
@@ -67,14 +70,36 @@ public class GLState {
return new GLListProperty(
GLStateType.VERTEX_ATTRIB_ARRAY,
perVertexAttribArrayState,
- 8);
+ MAX_VERTEX_ATTRIBS);
+ }
+
+ private IGLProperty createGenericVertexAttributeState() {
+ IGLProperty v0 = new GLFloatProperty(GLStateType.GENERIC_VERTEX_ATTRIB_V0,
+ Float.valueOf(0));
+ IGLProperty v1 = new GLFloatProperty(GLStateType.GENERIC_VERTEX_ATTRIB_V1,
+ Float.valueOf(0));
+ IGLProperty v2 = new GLFloatProperty(GLStateType.GENERIC_VERTEX_ATTRIB_V2,
+ Float.valueOf(0));
+ IGLProperty v3 = new GLFloatProperty(GLStateType.GENERIC_VERTEX_ATTRIB_V3,
+ Float.valueOf(0));
+
+ IGLProperty perGenericVertexAttribState = new GLCompositeProperty(
+ GLStateType.GENERIC_VERTEX_ATTRIBUTE_DATA_COMPOSITE,
+ v0, v1, v2, v3);
+
+ return new GLListProperty(
+ GLStateType.GENERIC_VERTEX_ATTRIBUTES,
+ perGenericVertexAttribState,
+ MAX_VERTEX_ATTRIBS);
}
private IGLProperty createVertexArrayData() {
IGLProperty vertexAttribArrays = createVertexAttribArrays();
IGLProperty bufferBindings = createBufferBindings();
+ IGLProperty genericAttribs = createGenericVertexAttributeState();
return new GLCompositeProperty(GLStateType.VERTEX_ARRAY_DATA,
+ genericAttribs,
vertexAttribArrays,
bufferBindings);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLStateType.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLStateType.java
index 42016fa..9d367be 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLStateType.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLStateType.java
@@ -25,6 +25,13 @@ public enum GLStateType {
GL_STATE_ES2("OpenGL ES 2.0 State"),
VERTEX_ARRAY_DATA("Vertex Array Data"),
+ GENERIC_VERTEX_ATTRIBUTES("Generic Vertex Attributes"),
+ GENERIC_VERTEX_ATTRIBUTE_DATA_COMPOSITE("Generic Vertex Attribute Data"),
+ GENERIC_VERTEX_ATTRIB_V0("x"),
+ GENERIC_VERTEX_ATTRIB_V1("y"),
+ GENERIC_VERTEX_ATTRIB_V2("z"),
+ GENERIC_VERTEX_ATTRIB_V3("w"),
+
VERTEX_ATTRIB_ARRAY("Vertex Attrib Array Properties"),
VERTEX_ATTRIB_ARRAY_COMPOSITE("Vertex Attrib Array #n Properties"),
VERTEX_ATTRIB_ARRAY_ENABLED("Vertex Attrib Array Enable"),
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java
index 3cc1004..0afd2e1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java
@@ -41,14 +41,38 @@ public class StateTransformFactory {
switch (msg.getFunction()) {
case eglCreateContext:
return transformsForEglCreateContext(msg);
- case glVertexAttribPointer:
- return transformsForGlVertexAttribPointer(msg);
case glBindFramebuffer:
return transformsForGlBindFramebuffer(msg);
+
+ // vertex data
+ case glVertexAttribPointer:
+ return transformsForGlVertexAttribPointer(msg);
+ case glVertexAttrib1f:
+ case glVertexAttrib2f:
+ case glVertexAttrib3f:
+ case glVertexAttrib4f:
+ return transformsForGlVertexAttribxf(msg);
+ case glVertexAttrib1fv:
+ case glVertexAttrib2fv:
+ case glVertexAttrib3fv:
+ case glVertexAttrib4fv:
+ return transformsForGlVertexAttribxfv(msg);
+ case glEnableVertexAttribArray:
+ return transformsForGlEnableVertexAttribArray(msg);
+ case glDisableVertexAttribArray:
+ return transformsForGlDisableVertexAttribArray(msg);
+
+ // VBO's
+ case glBindBuffer:
+ return transformsForGlBindBuffer(msg);
+
+ // transformation state
case glViewport:
return transformsForGlViewport(msg);
case glDepthRangef:
return transformsForGlDepthRangef(msg);
+
+ // rasterization
case glLineWidth:
return transformsForGlLineWidth(msg);
case glCullFace:
@@ -57,6 +81,8 @@ public class StateTransformFactory {
return transformsForGlFrontFace(msg);
case glPolygonOffset:
return transformsForGlPolygonOffset(msg);
+
+ // pixel operations
case glScissor:
return transformsForGlScissor(msg);
case glStencilFunc:
@@ -194,6 +220,124 @@ public class StateTransformFactory {
return transforms;
}
+ private static List<IStateTransform> transformsForGlVertexAttrib(int context,
+ int index, float v0, float v1, float v2, float v3) {
+ List<IStateTransform> transforms = new ArrayList<IStateTransform>(4);
+ transforms.add(new PropertyChangeTransform(
+ GLPropertyAccessor.makeAccessor(context,
+ GLStateType.VERTEX_ARRAY_DATA,
+ GLStateType.GENERIC_VERTEX_ATTRIBUTES,
+ Integer.valueOf(index),
+ GLStateType.GENERIC_VERTEX_ATTRIB_V0),
+ Float.valueOf(v0)));
+ transforms.add(new PropertyChangeTransform(
+ GLPropertyAccessor.makeAccessor(context,
+ GLStateType.VERTEX_ARRAY_DATA,
+ GLStateType.GENERIC_VERTEX_ATTRIBUTES,
+ Integer.valueOf(index),
+ GLStateType.GENERIC_VERTEX_ATTRIB_V1),
+ Float.valueOf(v1)));
+ transforms.add(new PropertyChangeTransform(
+ GLPropertyAccessor.makeAccessor(context,
+ GLStateType.VERTEX_ARRAY_DATA,
+ GLStateType.GENERIC_VERTEX_ATTRIBUTES,
+ Integer.valueOf(index),
+ GLStateType.GENERIC_VERTEX_ATTRIB_V2),
+ Float.valueOf(v2)));
+ transforms.add(new PropertyChangeTransform(
+ GLPropertyAccessor.makeAccessor(context,
+ GLStateType.VERTEX_ARRAY_DATA,
+ GLStateType.GENERIC_VERTEX_ATTRIBUTES,
+ Integer.valueOf(index),
+ GLStateType.GENERIC_VERTEX_ATTRIB_V3),
+ Float.valueOf(v3)));
+ return transforms;
+ }
+
+ private static List<IStateTransform> transformsForGlVertexAttribxf(GLMessage msg) {
+ // void glVertexAttrib1f(GLuint index, GLfloat v0);
+ // void glVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1);
+ // void glVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2);
+ // void glVertexAttrib4f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+
+ int index = msg.getArgs(0).getIntValue(0);
+ float v0 = msg.getArgs(1).getFloatValue(0);
+ float v1 = msg.getArgsCount() > 2 ? msg.getArgs(2).getFloatValue(0) : 0;
+ float v2 = msg.getArgsCount() > 3 ? msg.getArgs(3).getFloatValue(0) : 0;
+ float v3 = msg.getArgsCount() > 4 ? msg.getArgs(4).getFloatValue(0) : 0;
+
+ return transformsForGlVertexAttrib(msg.getContextId(), index, v0, v1, v2, v3);
+ }
+
+ private static List<IStateTransform> transformsForGlVertexAttribxfv(GLMessage msg) {
+ // void glVertexAttrib1fv(GLuint index, const GLfloat *v);
+ // void glVertexAttrib2fv(GLuint index, const GLfloat *v);
+ // void glVertexAttrib3fv(GLuint index, const GLfloat *v);
+ // void glVertexAttrib4fv(GLuint index, const GLfloat *v);
+
+ int index = msg.getArgs(0).getIntValue(0);
+ float v[] = new float[4];
+
+ for (int i = 0; i < msg.getArgs(1).getFloatValueList().size(); i++) {
+ v[i] = msg.getArgs(1).getFloatValue(i);
+ }
+
+ return transformsForGlVertexAttrib(msg.getContextId(), index, v[0], v[1], v[2], v[3]);
+ }
+
+ private static List<IStateTransform> transformsForGlEnableVertexAttribArray(GLMessage msg) {
+ // void glEnableVertexAttribArray(GLuint index);
+ // void glDisableVertexAttribArray(GLuint index);
+
+ int index = msg.getArgs(0).getIntValue(0);
+ IStateTransform transform = new PropertyChangeTransform(
+ GLPropertyAccessor.makeAccessor(msg.getContextId(),
+ GLStateType.VERTEX_ARRAY_DATA,
+ GLStateType.VERTEX_ATTRIB_ARRAY,
+ Integer.valueOf(index),
+ GLStateType.VERTEX_ATTRIB_ARRAY_ENABLED),
+ Boolean.TRUE);
+ return Collections.singletonList(transform);
+ }
+
+ private static List<IStateTransform> transformsForGlDisableVertexAttribArray(GLMessage msg) {
+ // void glEnableVertexAttribArray(GLuint index);
+ // void glDisableVertexAttribArray(GLuint index);
+
+ int index = msg.getArgs(0).getIntValue(0);
+ IStateTransform transform = new PropertyChangeTransform(
+ GLPropertyAccessor.makeAccessor(msg.getContextId(),
+ GLStateType.VERTEX_ARRAY_DATA,
+ GLStateType.VERTEX_ATTRIB_ARRAY,
+ Integer.valueOf(index),
+ GLStateType.VERTEX_ATTRIB_ARRAY_ENABLED),
+ Boolean.FALSE);
+ return Collections.singletonList(transform);
+ }
+
+ private static List<IStateTransform> transformsForGlBindBuffer(GLMessage msg) {
+ // void glBindBuffer(GLenum target, GLuint buffer);
+ // target is one of GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.
+
+ GLEnum target = GLEnum.valueOf(msg.getArgs(0).getIntValue(0));
+ int buffer = msg.getArgs(1).getIntValue(0);
+ GLStateType bufferType;
+
+ if (target == GLEnum.GL_ARRAY_BUFFER) {
+ bufferType = GLStateType.ARRAY_BUFFER_BINDING;
+ } else {
+ bufferType = GLStateType.ELEMENT_ARRAY_BUFFER_BINDING;
+ }
+
+ IStateTransform transform = new PropertyChangeTransform(
+ GLPropertyAccessor.makeAccessor(msg.getContextId(),
+ GLStateType.VERTEX_ARRAY_DATA,
+ GLStateType.BUFFER_BINDINGS,
+ bufferType),
+ Integer.valueOf(buffer));
+ return Collections.singletonList(transform);
+ }
+
private static List<IStateTransform> transformsForGlBindFramebuffer(GLMessage msg) {
// void glBindFramebuffer(GLenum target, GLuint framebuffer);
int fb = msg.getArgs(1).getIntValue(0);