aboutsummaryrefslogtreecommitdiffstats
path: root/src/oculusvr
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-05 09:42:28 +0200
committerSven Gothel <[email protected]>2023-04-05 09:42:28 +0200
commit15e60161787224e85172685f74dc0ac195969b51 (patch)
tree68f3b44be2b340cfb7903996cea4820512049463 /src/oculusvr
parent603233b19373bfa157dd033132bff809af6a123f (diff)
Math: Complete Matrix4f w/ Vec[234]f and adopt it throughout Quaternion, Ray, AABBox, Frustum, Stereo*, ... adding hook to PMVMatrix
Motivation was to simplify matrix + vector math usage, ease review and avoid usage bugs. Matrix4f implementation uses dedicated float fields instead of an array. Performance didn't increase much, as JVM >= 11(?) has some optimizations to drop the array bounds check. AMD64 + OpenJDK17 - Matrix4f.mul(a, b) got a roughly ~10% enhancement over FloatUtil.multMatrix(a, b, dest) - Matrix4f.mul(b) roughly ~3% slower than FloatUtil.multMatrix(a, b, dest) - FloatUtil.multMatrix(a, a_off, b, b_off, dest) is considerable slower than all - Matrix4f.invert(..) roughly ~3% slower than FloatUtil.invertMatrix(..) RaspberryPi 4b aarch64 + OpenJDK17 - Matrix4f.mul(a, b) got a roughly ~10% enhancement over FloatUtil.multMatrix(a, b, dest) - Matrix4f.mul(b) roughly ~20% slower than FloatUtil.multMatrix(a, b) - FloatUtil.multMatrix(a, a_off, b, b_off, dest) is considerable slower than all - Matrix4f.invert(..) roughly ~4% slower than FloatUtil.invertMatrix(..) Conclusion - Matrix4f.mul(b) needs to be revised (esp for aarch64) - Matrix4f.invert(..) should also not be slower ..
Diffstat (limited to 'src/oculusvr')
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java7
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java5
2 files changed, 7 insertions, 5 deletions
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
index 5025e80c5..335123bb9 100644
--- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
+++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
@@ -40,6 +40,7 @@ import com.jogamp.oculusvr.ovrHmdDesc;
import com.jogamp.oculusvr.ovrSizei;
import com.jogamp.oculusvr.ovrTrackingState;
import com.jogamp.opengl.math.FovHVHalves;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.Frustum;
import com.jogamp.opengl.util.stereo.LocationSensorParameter;
import com.jogamp.opengl.util.stereo.StereoDevice;
@@ -49,7 +50,7 @@ import com.jogamp.opengl.util.stereo.StereoUtil;
public class OVRStereoDevice implements StereoDevice {
/** 1.6 up, 5 forward */
- private static final float[] DEFAULT_EYE_POSITION_OFFSET = { 0.0f, 1.6f, -5.0f };
+ private static final Vec3f DEFAULT_EYE_POSITION_OFFSET = new Vec3f( 0.0f, 1.6f, -5.0f );
private final StereoDeviceFactory factory;
public final int deviceIndex;
@@ -181,7 +182,7 @@ public class OVRStereoDevice implements StereoDevice {
public int getRequiredRotation() { return requiredRotation; }
@Override
- public float[] getDefaultEyePositionOffset() { return DEFAULT_EYE_POSITION_OFFSET; }
+ public Vec3f getDefaultEyePositionOffset() { return DEFAULT_EYE_POSITION_OFFSET; }
@Override
public final FovHVHalves[] getDefaultFOV() { return defaultEyeFov; }
@@ -300,7 +301,7 @@ public class OVRStereoDevice implements StereoDevice {
@Override
public final StereoDeviceRenderer createRenderer(final int distortionBits,
- final int textureCount, final float[] eyePositionOffset,
+ final int textureCount, final Vec3f eyePositionOffset,
final FovHVHalves[] eyeFov, final float pixelsPerDisplayPixel, final int textureUnit) {
final ovrFovPort ovrEyeFov0 = OVRUtil.getOVRFovPort(eyeFov[0]);
final ovrFovPort ovrEyeFov1 = OVRUtil.getOVRFovPort(eyeFov[1]);
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java
index 95565dd0f..1430a9c45 100644
--- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java
+++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java
@@ -59,6 +59,7 @@ import com.jogamp.oculusvr.ovrVector2f;
import com.jogamp.oculusvr.ovrVector3f;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
@@ -107,7 +108,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer {
public final EyeParameter getEyeParameter() { return eyeParameter; }
/* pp */ OVREye(final ovrHmdDesc hmdDesc, final int distortionBits,
- final float[] eyePositionOffset, final ovrEyeRenderDesc eyeDesc,
+ final Vec3f eyePositionOffset, final ovrEyeRenderDesc eyeDesc,
final ovrSizei ovrTextureSize, final RectangleImmutable eyeViewport) {
this.eyeName = eyeDesc.getEye();
this.distortionBits = distortionBits;
@@ -398,7 +399,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer {
}
/* pp */ OVRStereoDeviceRenderer(final OVRStereoDevice context, final int distortionBits,
- final int textureCount, final float[] eyePositionOffset,
+ final int textureCount, final Vec3f eyePositionOffset,
final ovrEyeRenderDesc[] eyeRenderDescs,
final DimensionImmutable[] eyeTextureSizes, final DimensionImmutable totalTextureSize,
final RectangleImmutable[] eyeViewports, final int textureUnit) {