summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2013-04-10 09:26:48 -0700
committerJesse Hall <jessehall@google.com>2013-04-10 22:00:18 -0700
commit27c86b962373f40a01f094689d623d51c51d4f83 (patch)
tree55480fe81d8a228c4cfa08cc99c6155c99e1cf67
parent31f6edc21bbc2802f4c755b4982945d5237e92ce (diff)
downloadframeworks_native-27c86b962373f40a01f094689d623d51c51d4f83.zip
frameworks_native-27c86b962373f40a01f094689d623d51c51d4f83.tar.gz
frameworks_native-27c86b962373f40a01f094689d623d51c51d4f83.tar.bz2
Special-case glGetUniformIndices
Bug: 8566953 Change-Id: Ic8bcd03e8d41a81f48d603f67ce2046a4afa1561
-rw-r--r--opengl/tools/glgen/specs/gles11/GLES30.spec2
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp154
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java17
-rw-r--r--opengl/tools/glgen/stubs/gles11/glGetUniformIndices.nativeReg2
4 files changed, 174 insertions, 1 deletions
diff --git a/opengl/tools/glgen/specs/gles11/GLES30.spec b/opengl/tools/glgen/specs/gles11/GLES30.spec
index 1e2acf9..4fc541b 100644
--- a/opengl/tools/glgen/specs/gles11/GLES30.spec
+++ b/opengl/tools/glgen/specs/gles11/GLES30.spec
@@ -221,7 +221,7 @@ void glClearBufferfv ( GLenum buffer, GLint drawbuffer, const GLfloat *value )
void glClearBufferfi ( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil )
// const GLubyte * glGetStringi ( GLenum name, GLuint index )
void glCopyBufferSubData ( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size )
-// void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices )
+void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices )
void glGetActiveUniformsiv ( GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params )
GLuint glGetUniformBlockIndex ( GLuint program, const GLchar *uniformBlockName )
void glGetActiveUniformBlockiv ( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params )
diff --git a/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp
new file mode 100644
index 0000000..fb137ab
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp
@@ -0,0 +1,154 @@
+/* void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices ) */
+static
+void
+android_glGetUniformIndices_array
+ (JNIEnv *_env, jobject _this, jint program, jobjectArray uniformNames_ref, jintArray uniformIndices_ref, jint uniformIndicesOffset) {
+ jint _exception = 0;
+ const char* _exceptionType = NULL;
+ const char* _exceptionMessage = NULL;
+ jint _count = 0;
+ jint _i;
+ const char** _names = NULL;
+ GLuint* _indices_base = NULL;
+ GLuint* _indices = NULL;
+
+ if (!uniformNames_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "uniformNames == null";
+ goto exit;
+ }
+ _count = _env->GetArrayLength(uniformNames_ref);
+ _names = (const char**)calloc(_count, sizeof(const char*));
+ for (_i = 0; _i < _count; _i++) {
+ jstring _name = (jstring)_env->GetObjectArrayElement(uniformNames_ref, _i);
+ if (!_name) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "null uniformNames element";
+ goto exit;
+ }
+ _names[_i] = _env->GetStringUTFChars(_name, 0);
+ }
+
+ if (!uniformIndices_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "uniformIndices == null";
+ goto exit;
+ }
+ if (uniformIndicesOffset < 0) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "uniformIndicesOffset < 0";
+ goto exit;
+ }
+ if (_env->GetArrayLength(uniformIndices_ref) - uniformIndicesOffset < _count) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "not enough space in uniformIndices";
+ goto exit;
+ }
+ _indices_base = (GLuint*)_env->GetPrimitiveArrayCritical(
+ uniformIndices_ref, 0);
+ _indices = _indices_base + uniformIndicesOffset;
+
+ glGetUniformIndices(program, _count, _names, _indices);
+
+exit:
+ if (_indices_base) {
+ _env->ReleasePrimitiveArrayCritical(uniformIndices_ref, _indices_base,
+ _exception ? JNI_ABORT : 0);
+ }
+ for (_i = _count - 1; _i >= 0; _i--) {
+ if (_names[_i]) {
+ jstring _name = (jstring)_env->GetObjectArrayElement(uniformNames_ref, _i);
+ if (_name) {
+ _env->ReleaseStringUTFChars(_name, _names[_i]);
+ }
+ }
+ }
+ free(_names);
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+}
+
+/* void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices ) */
+static
+void
+android_glGetUniformIndices_buffer
+ (JNIEnv *_env, jobject _this, jint program, jobjectArray uniformNames_ref, jobject uniformIndices_buf) {
+ jint _exception = 0;
+ const char* _exceptionType = NULL;
+ const char* _exceptionMessage = NULL;
+ jint _count = 0;
+ jint _i;
+ const char** _names = NULL;
+ jarray _uniformIndicesArray = (jarray)0;
+ jint _uniformIndicesRemaining;
+ jint _uniformIndicesOffset = 0;
+ GLuint* _indices = NULL;
+ char* _indicesBase = NULL;
+
+ if (!uniformNames_ref) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "uniformNames == null";
+ goto exit;
+ }
+ if (!uniformIndices_buf) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "uniformIndices == null";
+ goto exit;
+ }
+
+ _count = _env->GetArrayLength(uniformNames_ref);
+ _names = (const char**)calloc(_count, sizeof(const char*));
+ for (_i = 0; _i < _count; _i++) {
+ jstring _name = (jstring)_env->GetObjectArrayElement(uniformNames_ref, _i);
+ if (!_name) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "null uniformNames element";
+ goto exit;
+ }
+ _names[_i] = _env->GetStringUTFChars(_name, 0);
+ }
+
+ _indices = (GLuint*)getPointer(_env, uniformIndices_buf,
+ &_uniformIndicesArray, &_uniformIndicesRemaining,
+ &_uniformIndicesOffset);
+ if (!_indices) {
+ _indicesBase = (char*)_env->GetPrimitiveArrayCritical(
+ _uniformIndicesArray, 0);
+ _indices = (GLuint*)(_indicesBase + _uniformIndicesOffset);
+ }
+ if (_uniformIndicesRemaining < _count) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "not enough space in uniformIndices";
+ goto exit;
+ }
+
+ glGetUniformIndices(program, _count, _names, _indices);
+
+exit:
+ if (_uniformIndicesArray) {
+ releasePointer(_env, _uniformIndicesArray, _indicesBase, JNI_TRUE);
+ }
+ for (_i = _count - 1; _i >= 0; _i--) {
+ if (_names[_i]) {
+ jstring _name = (jstring)_env->GetObjectArrayElement(uniformNames_ref, _i);
+ if (_name) {
+ _env->ReleaseStringUTFChars(_name, _names[_i]);
+ }
+ }
+ }
+ free(_names);
+ if (_exception) {
+ jniThrowException(_env, _exceptionType, _exceptionMessage);
+ }
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java
new file mode 100644
index 0000000..719429b
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java
@@ -0,0 +1,17 @@
+ // C function void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices )
+
+ public static native void glGetUniformIndices(
+ int program,
+ String[] uniformNames,
+ int[] uniformIndices,
+ int uniformIndicesOffset
+ );
+
+ // C function void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices )
+
+ public static native void glGetUniformIndices(
+ int program,
+ String[] uniformNames,
+ java.nio.IntBuffer uniformIndices
+ );
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.nativeReg
new file mode 100644
index 0000000..c711307
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.nativeReg
@@ -0,0 +1,2 @@
+{"glGetUniformIndices", "(I[Ljava/lang/String;[II)V", (void *) android_glGetUniformIndices_array },
+{"glGetUniformIndices", "(I[Ljava/lang/String;[Ljava/nio/IntBuffer)V", (void *) android_glGetUniformIndices_buffer },