diff options
author | Sven Gothel <[email protected]> | 2011-10-07 02:40:52 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-07 02:40:52 +0200 |
commit | f5a2da16645ebc60d4e3da72f702cf682a5c0488 (patch) | |
tree | 94a65aadeae42f623bce76a803cab1d76b04d1ba /src/jogl/classes/jogamp/opengl/ProjectFloat.java | |
parent | fa7627f623141c6fa15856c74d26c8ffe82550d0 (diff) |
PMVMatrix: Defaults from direct NIO -> array-backed non-direct NIO: Reduced cycles 45% -> 5% (from GearsES2 100%)
- NIO direct access from Java is expensive
- default is now array-backed non-direct NIO,
which guarantees array useage for Java computation (especially the inverse calculation)
- only update Mvi and Mvit if requested in the first place
- moved all local matrices to float[]
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/ProjectFloat.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/ProjectFloat.java | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java index a6316b242..1c69fa370 100644 --- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java +++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java @@ -235,9 +235,18 @@ public class ProjectFloat { /** * Make matrix an identity matrix */ - public static void gluMakeIdentityf(float[] m) { + public static void gluMakeIdentityf(float[] m, int offset) { for (int i = 0; i < 16; i++) { - m[i] = IDENTITY_MATRIX[i]; + m[i+offset] = IDENTITY_MATRIX[i]; + } + } + + /** + * Make matrix an zero matrix + */ + public static void gluMakeZero(float[] m, int offset) { + for (int i = 0; i < 16; i++) { + m[i+offset] = 0; } } @@ -280,21 +289,22 @@ public class ProjectFloat { /** * @param src + * @param srcOffset * @param inverse - * + * @param inverseOffset * @return */ - public boolean gluInvertMatrixf(float[] src, float[] inverse) { + public boolean gluInvertMatrixf(float[] src, int srcOffset, float[] inverse, int inverseOffset) { int i, j, k, swap; float t; float[][] temp = tempInvertMatrix; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - temp[i][j] = src[i*4+j]; + temp[i][j] = src[i*4+j+srcOffset]; } } - gluMakeIdentityf(inverse); + gluMakeIdentityf(inverse, inverseOffset); for (i = 0; i < 4; i++) { // @@ -316,9 +326,9 @@ public class ProjectFloat { temp[i][k] = temp[swap][k]; temp[swap][k] = t; - t = inverse[i*4+k]; - inverse[i*4+k] = inverse[swap*4+k]; - inverse[swap*4+k] = t; + t = inverse[i*4+k+inverseOffset]; + inverse[i*4+k+inverseOffset] = inverse[swap*4+k+inverseOffset]; + inverse[swap*4+k+inverseOffset] = t; } } @@ -333,14 +343,14 @@ public class ProjectFloat { t = temp[i][i]; for (k = 0; k < 4; k++) { temp[i][k] /= t; - inverse[i*4+k] /= t; + inverse[i*4+k+inverseOffset] /= t; } for (j = 0; j < 4; j++) { if (j != i) { t = temp[j][i]; for (k = 0; k < 4; k++) { temp[j][k] -= temp[i][k] * t; - inverse[j*4+k] -= inverse[i*4+k]*t; + inverse[j*4+k+inverseOffset] -= inverse[i*4+k+inverseOffset]*t; } } } @@ -781,7 +791,7 @@ public class ProjectFloat { gluMultMatricesf(modelMatrix, modelMatrix_offset, projMatrix, projMatrix_offset, matrix); - if (!gluInvertMatrixf(matrix, matrix)) + if (!gluInvertMatrixf(matrix, 0, matrix, 0)) return false; in[0] = winx; @@ -907,7 +917,7 @@ public class ProjectFloat { gluMultMatricesf(modelMatrix, modelMatrix_offset, projMatrix, projMatrix_offset, matrix); - if (!gluInvertMatrixf(matrix, matrix)) + if (!gluInvertMatrixf(matrix, 0, matrix, 0)) return false; in[0] = winx; |