mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-12 23:54:15 +00:00
Changes to allow a single APK to run on both Quest and Pico
Link against the generic Android openxr_loader then load the correct loader library at runtime on start-up
This commit is contained in:
parent
348bd46f62
commit
0b27c1c0e9
10 changed files with 185 additions and 160 deletions
15
.gitignore
vendored
15
.gitignore
vendored
|
@ -15,9 +15,6 @@ $RECYCLE.BIN/
|
||||||
*.o
|
*.o
|
||||||
*.d
|
*.d
|
||||||
|
|
||||||
#binaries
|
|
||||||
*.so
|
|
||||||
|
|
||||||
#libs
|
#libs
|
||||||
*.a
|
*.a
|
||||||
|
|
||||||
|
@ -43,3 +40,15 @@ assets/pak0.pk3
|
||||||
assets/sp_pak_weapons.pk3
|
assets/sp_pak_weapons.pk3
|
||||||
assets/z_zvr_weapons.pk3
|
assets/z_zvr_weapons.pk3
|
||||||
assets/sp_vpak8.pk3
|
assets/sp_vpak8.pk3
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/armeabi-v7a/libogg.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/armeabi-v7a/libvorbis-jni.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/armeabi-v7a/libvorbis.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/armeabi/libogg.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/armeabi/libvorbis-jni.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/armeabi/libvorbis.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/mips/libogg.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/mips/libvorbis-jni.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/mips/libvorbis.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/x86/libogg.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/x86/libvorbis-jni.so
|
||||||
|
Projects/Android/jni/SupportLibs/liboggvorbis/libs/x86/libvorbis.so
|
||||||
|
|
|
@ -37,6 +37,11 @@ android {
|
||||||
assets.srcDirs = ['../../assets']
|
assets.srcDirs = ['../../assets']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
exclude 'lib/arm64-v8a/libopenxr_loader.so'
|
||||||
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = '1.8'
|
sourceCompatibility = '1.8'
|
||||||
targetCompatibility = '1.8'
|
targetCompatibility = '1.8'
|
||||||
|
|
|
@ -376,24 +376,26 @@ bool VR_GetVRProjection(int eye, float zNear, float zFar, float* projection)
|
||||||
|
|
||||||
if (!vr.cgzoommode)
|
if (!vr.cgzoommode)
|
||||||
{
|
{
|
||||||
#ifdef PICO_XR
|
|
||||||
XrMatrix4x4f_CreateProjectionFov(
|
|
||||||
&(gAppState.ProjectionMatrices[eye]), GRAPHICS_OPENGL_ES,
|
|
||||||
gAppState.Projections[eye].fov, zNear, zFar);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef META_QUEST
|
if (strstr(gAppState.OpenXRHMDModel, "Quest") != NULL)
|
||||||
XrFovf fov = {};
|
{
|
||||||
for (int eye = 0; eye < ovrMaxNumEyes; eye++) {
|
XrFovf fov = {};
|
||||||
fov.angleLeft += gAppState.Projections[eye].fov.angleLeft / 2.0f;
|
for (int eye = 0; eye < ovrMaxNumEyes; eye++) {
|
||||||
fov.angleRight += gAppState.Projections[eye].fov.angleRight / 2.0f;
|
fov.angleLeft += gAppState.Projections[eye].fov.angleLeft / 2.0f;
|
||||||
fov.angleUp += gAppState.Projections[eye].fov.angleUp / 2.0f;
|
fov.angleRight += gAppState.Projections[eye].fov.angleRight / 2.0f;
|
||||||
fov.angleDown += gAppState.Projections[eye].fov.angleDown / 2.0f;
|
fov.angleUp += gAppState.Projections[eye].fov.angleUp / 2.0f;
|
||||||
|
fov.angleDown += gAppState.Projections[eye].fov.angleDown / 2.0f;
|
||||||
|
}
|
||||||
|
XrMatrix4x4f_CreateProjectionFov(
|
||||||
|
&(gAppState.ProjectionMatrices[eye]), GRAPHICS_OPENGL_ES,
|
||||||
|
fov, zNear, zFar);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XrMatrix4x4f_CreateProjectionFov(
|
||||||
|
&(gAppState.ProjectionMatrices[eye]), GRAPHICS_OPENGL_ES,
|
||||||
|
gAppState.Projections[eye].fov, zNear, zFar);
|
||||||
}
|
}
|
||||||
XrMatrix4x4f_CreateProjectionFov(
|
|
||||||
&(gAppState.ProjectionMatrices[eye]), GRAPHICS_OPENGL_ES,
|
|
||||||
fov, zNear, zFar);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memcpy(projection, gAppState.ProjectionMatrices[eye].m, 16 * sizeof(float));
|
memcpy(projection, gAppState.ProjectionMatrices[eye].m, 16 * sizeof(float));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -70,17 +70,14 @@ float SS_MULTIPLIER = 0.0f;
|
||||||
|
|
||||||
GLboolean stageSupported = GL_FALSE;
|
GLboolean stageSupported = GL_FALSE;
|
||||||
|
|
||||||
#ifdef META_QUEST
|
|
||||||
|
|
||||||
const char* const requiredExtensionNames[] = {
|
const char* const requiredExtensionNames_meta[] = {
|
||||||
XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME,
|
XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME,
|
||||||
XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME,
|
XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME,
|
||||||
XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME,
|
XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME,
|
||||||
XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME,
|
XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME,
|
||||||
XR_FB_COLOR_SPACE_EXTENSION_NAME};
|
XR_FB_COLOR_SPACE_EXTENSION_NAME};
|
||||||
#endif //META_QUEST
|
|
||||||
|
|
||||||
#ifdef PICO_XR
|
|
||||||
#define XR_PICO_CONFIGS_EXT_EXTENSION_NAME "XR_PICO_configs_ext"
|
#define XR_PICO_CONFIGS_EXT_EXTENSION_NAME "XR_PICO_configs_ext"
|
||||||
|
|
||||||
enum ConfigsEXT
|
enum ConfigsEXT
|
||||||
|
@ -133,16 +130,17 @@ typedef XrResult (XRAPI_PTR *PFN_xrSetConfigPICO) (
|
||||||
char * configData);
|
char * configData);
|
||||||
PFN_xrSetConfigPICO pfnXrSetConfigPICO;
|
PFN_xrSetConfigPICO pfnXrSetConfigPICO;
|
||||||
|
|
||||||
const char* const requiredExtensionNames[] = {
|
const char* const requiredExtensionNames_pico[] = {
|
||||||
XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME,
|
XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME,
|
||||||
XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME,
|
XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME,
|
||||||
XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME,
|
XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME,
|
||||||
XR_PICO_CONFIGS_EXT_EXTENSION_NAME};
|
XR_PICO_CONFIGS_EXT_EXTENSION_NAME};
|
||||||
|
|
||||||
#endif //PICO_XR
|
|
||||||
|
|
||||||
const uint32_t numRequiredExtensions =
|
const uint32_t numRequiredExtensions_meta =
|
||||||
sizeof(requiredExtensionNames) / sizeof(requiredExtensionNames[0]);
|
sizeof(requiredExtensionNames_meta) / sizeof(requiredExtensionNames_meta[0]);
|
||||||
|
const uint32_t numRequiredExtensions_pico =
|
||||||
|
sizeof(requiredExtensionNames_pico) / sizeof(requiredExtensionNames_pico[0]);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -930,18 +928,21 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) {
|
||||||
OXR(pfnPerfSettingsSetPerformanceLevelEXT(
|
OXR(pfnPerfSettingsSetPerformanceLevelEXT(
|
||||||
app->Session, XR_PERF_SETTINGS_DOMAIN_GPU_EXT, gpuPerfLevel));
|
app->Session, XR_PERF_SETTINGS_DOMAIN_GPU_EXT, gpuPerfLevel));
|
||||||
|
|
||||||
#ifdef META_QUEST
|
if (strstr(gAppState.OpenXRHMDModel, "Quest") != NULL)
|
||||||
PFN_xrSetAndroidApplicationThreadKHR pfnSetAndroidApplicationThreadKHR = NULL;
|
{
|
||||||
OXR(xrGetInstanceProcAddr(
|
PFN_xrSetAndroidApplicationThreadKHR pfnSetAndroidApplicationThreadKHR = NULL;
|
||||||
app->Instance,
|
OXR(xrGetInstanceProcAddr(
|
||||||
"xrSetAndroidApplicationThreadKHR",
|
app->Instance,
|
||||||
(PFN_xrVoidFunction * )(&pfnSetAndroidApplicationThreadKHR)));
|
"xrSetAndroidApplicationThreadKHR",
|
||||||
|
(PFN_xrVoidFunction *) (&pfnSetAndroidApplicationThreadKHR)));
|
||||||
|
|
||||||
OXR(pfnSetAndroidApplicationThreadKHR(
|
OXR(pfnSetAndroidApplicationThreadKHR(
|
||||||
app->Session, XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR, app->MainThreadTid));
|
app->Session, XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR,
|
||||||
OXR(pfnSetAndroidApplicationThreadKHR(
|
app->MainThreadTid));
|
||||||
app->Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, app->RenderThreadTid));
|
OXR(pfnSetAndroidApplicationThreadKHR(
|
||||||
#endif
|
app->Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR,
|
||||||
|
app->RenderThreadTid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (state == XR_SESSION_STATE_STOPPING) {
|
} else if (state == XR_SESSION_STATE_STOPPING) {
|
||||||
assert(app->SessionActive);
|
assert(app->SessionActive);
|
||||||
|
@ -990,7 +991,6 @@ GLboolean ovrApp_HandleXrEvents(ovrApp* app) {
|
||||||
perf_settings_event->fromLevel,
|
perf_settings_event->fromLevel,
|
||||||
perf_settings_event->toLevel);
|
perf_settings_event->toLevel);
|
||||||
} break;
|
} break;
|
||||||
#ifdef META_QUEST
|
|
||||||
case XR_TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB: {
|
case XR_TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB: {
|
||||||
const XrEventDataDisplayRefreshRateChangedFB* refresh_rate_changed_event =
|
const XrEventDataDisplayRefreshRateChangedFB* refresh_rate_changed_event =
|
||||||
(XrEventDataDisplayRefreshRateChangedFB*)(baseEventHeader);
|
(XrEventDataDisplayRefreshRateChangedFB*)(baseEventHeader);
|
||||||
|
@ -999,7 +999,6 @@ GLboolean ovrApp_HandleXrEvents(ovrApp* app) {
|
||||||
refresh_rate_changed_event->fromDisplayRefreshRate,
|
refresh_rate_changed_event->fromDisplayRefreshRate,
|
||||||
refresh_rate_changed_event->toDisplayRefreshRate);
|
refresh_rate_changed_event->toDisplayRefreshRate);
|
||||||
} break;
|
} break;
|
||||||
#endif
|
|
||||||
case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING: {
|
case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING: {
|
||||||
XrEventDataReferenceSpaceChangePending* ref_space_change_event =
|
XrEventDataReferenceSpaceChangePending* ref_space_change_event =
|
||||||
(XrEventDataReferenceSpaceChangePending*)(baseEventHeader);
|
(XrEventDataReferenceSpaceChangePending*)(baseEventHeader);
|
||||||
|
@ -1449,89 +1448,94 @@ void TBXR_InitRenderer( ) {
|
||||||
gAppState.Instance, gAppState.SystemId, XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, &gAppState.ViewportConfig));
|
gAppState.Instance, gAppState.SystemId, XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, &gAppState.ViewportConfig));
|
||||||
|
|
||||||
|
|
||||||
#ifdef META_QUEST
|
if (strstr(gAppState.OpenXRHMDModel, "Quest") != NULL)
|
||||||
XrSystemColorSpacePropertiesFB colorSpacePropertiesFB = {};
|
|
||||||
colorSpacePropertiesFB.type = XR_TYPE_SYSTEM_COLOR_SPACE_PROPERTIES_FB;
|
|
||||||
|
|
||||||
XrSystemProperties systemProperties = {};
|
|
||||||
systemProperties.type = XR_TYPE_SYSTEM_PROPERTIES;
|
|
||||||
systemProperties.next = &colorSpacePropertiesFB;
|
|
||||||
OXR(xrGetSystemProperties(gAppState.Instance, gAppState.SystemId, &systemProperties));
|
|
||||||
|
|
||||||
// Enumerate the supported color space options for the system.
|
|
||||||
{
|
{
|
||||||
PFN_xrEnumerateColorSpacesFB pfnxrEnumerateColorSpacesFB = NULL;
|
XrSystemColorSpacePropertiesFB colorSpacePropertiesFB = {};
|
||||||
OXR(xrGetInstanceProcAddr(
|
colorSpacePropertiesFB.type = XR_TYPE_SYSTEM_COLOR_SPACE_PROPERTIES_FB;
|
||||||
gAppState.Instance,
|
|
||||||
"xrEnumerateColorSpacesFB",
|
|
||||||
(PFN_xrVoidFunction*)(&pfnxrEnumerateColorSpacesFB)));
|
|
||||||
|
|
||||||
uint32_t colorSpaceCountOutput = 0;
|
XrSystemProperties systemProperties = {};
|
||||||
OXR(pfnxrEnumerateColorSpacesFB(gAppState.Session, 0, &colorSpaceCountOutput, NULL));
|
systemProperties.type = XR_TYPE_SYSTEM_PROPERTIES;
|
||||||
|
systemProperties.next = &colorSpacePropertiesFB;
|
||||||
|
OXR(xrGetSystemProperties(gAppState.Instance, gAppState.SystemId, &systemProperties));
|
||||||
|
|
||||||
XrColorSpaceFB* colorSpaces =
|
// Enumerate the supported color space options for the system.
|
||||||
(XrColorSpaceFB*)malloc(colorSpaceCountOutput * sizeof(XrColorSpaceFB));
|
{
|
||||||
|
PFN_xrEnumerateColorSpacesFB pfnxrEnumerateColorSpacesFB = NULL;
|
||||||
|
OXR(xrGetInstanceProcAddr(
|
||||||
|
gAppState.Instance,
|
||||||
|
"xrEnumerateColorSpacesFB",
|
||||||
|
(PFN_xrVoidFunction *) (&pfnxrEnumerateColorSpacesFB)));
|
||||||
|
|
||||||
OXR(pfnxrEnumerateColorSpacesFB(
|
uint32_t colorSpaceCountOutput = 0;
|
||||||
gAppState.Session, colorSpaceCountOutput, &colorSpaceCountOutput, colorSpaces));
|
OXR(pfnxrEnumerateColorSpacesFB(gAppState.Session, 0, &colorSpaceCountOutput, NULL));
|
||||||
ALOGV("Supported ColorSpaces:");
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < colorSpaceCountOutput; i++) {
|
XrColorSpaceFB *colorSpaces =
|
||||||
ALOGV("%d:%d", i, colorSpaces[i]);
|
(XrColorSpaceFB *) malloc(colorSpaceCountOutput * sizeof(XrColorSpaceFB));
|
||||||
|
|
||||||
|
OXR(pfnxrEnumerateColorSpacesFB(
|
||||||
|
gAppState.Session, colorSpaceCountOutput, &colorSpaceCountOutput, colorSpaces));
|
||||||
|
ALOGV("Supported ColorSpaces:");
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < colorSpaceCountOutput; i++)
|
||||||
|
{
|
||||||
|
ALOGV("%d:%d", i, colorSpaces[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const XrColorSpaceFB requestColorSpace = XR_COLOR_SPACE_REC2020_FB;
|
||||||
|
|
||||||
|
PFN_xrSetColorSpaceFB pfnxrSetColorSpaceFB = NULL;
|
||||||
|
OXR(xrGetInstanceProcAddr(
|
||||||
|
gAppState.Instance, "xrSetColorSpaceFB",
|
||||||
|
(PFN_xrVoidFunction *) (&pfnxrSetColorSpaceFB)));
|
||||||
|
|
||||||
|
OXR(pfnxrSetColorSpaceFB(gAppState.Session, requestColorSpace));
|
||||||
|
|
||||||
|
free(colorSpaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
const XrColorSpaceFB requestColorSpace = XR_COLOR_SPACE_REC2020_FB;
|
// Get the supported display refresh rates for the system.
|
||||||
|
{
|
||||||
|
PFN_xrEnumerateDisplayRefreshRatesFB pfnxrEnumerateDisplayRefreshRatesFB = NULL;
|
||||||
|
OXR(xrGetInstanceProcAddr(
|
||||||
|
gAppState.Instance,
|
||||||
|
"xrEnumerateDisplayRefreshRatesFB",
|
||||||
|
(PFN_xrVoidFunction *) (&pfnxrEnumerateDisplayRefreshRatesFB)));
|
||||||
|
|
||||||
PFN_xrSetColorSpaceFB pfnxrSetColorSpaceFB = NULL;
|
OXR(pfnxrEnumerateDisplayRefreshRatesFB(
|
||||||
OXR(xrGetInstanceProcAddr(
|
gAppState.Session, 0, &gAppState.NumSupportedDisplayRefreshRates, NULL));
|
||||||
gAppState.Instance, "xrSetColorSpaceFB", (PFN_xrVoidFunction*)(&pfnxrSetColorSpaceFB)));
|
|
||||||
|
|
||||||
OXR(pfnxrSetColorSpaceFB(gAppState.Session, requestColorSpace));
|
gAppState.SupportedDisplayRefreshRates =
|
||||||
|
(float *) malloc(gAppState.NumSupportedDisplayRefreshRates * sizeof(float));
|
||||||
|
OXR(pfnxrEnumerateDisplayRefreshRatesFB(
|
||||||
|
gAppState.Session,
|
||||||
|
gAppState.NumSupportedDisplayRefreshRates,
|
||||||
|
&gAppState.NumSupportedDisplayRefreshRates,
|
||||||
|
gAppState.SupportedDisplayRefreshRates));
|
||||||
|
ALOGV("Supported Refresh Rates:");
|
||||||
|
for (uint32_t i = 0; i < gAppState.NumSupportedDisplayRefreshRates; i++)
|
||||||
|
{
|
||||||
|
ALOGV("%d:%f", i, gAppState.SupportedDisplayRefreshRates[i]);
|
||||||
|
}
|
||||||
|
|
||||||
free(colorSpaces);
|
OXR(xrGetInstanceProcAddr(
|
||||||
}
|
gAppState.Instance,
|
||||||
|
"xrGetDisplayRefreshRateFB",
|
||||||
|
(PFN_xrVoidFunction *) (&gAppState.pfnGetDisplayRefreshRate)));
|
||||||
|
|
||||||
// Get the supported display refresh rates for the system.
|
OXR(gAppState.pfnGetDisplayRefreshRate(gAppState.Session,
|
||||||
{
|
&gAppState.currentDisplayRefreshRate));
|
||||||
PFN_xrEnumerateDisplayRefreshRatesFB pfnxrEnumerateDisplayRefreshRatesFB = NULL;
|
ALOGV("Current System Display Refresh Rate: %f", gAppState.currentDisplayRefreshRate);
|
||||||
OXR(xrGetInstanceProcAddr(
|
|
||||||
gAppState.Instance,
|
|
||||||
"xrEnumerateDisplayRefreshRatesFB",
|
|
||||||
(PFN_xrVoidFunction*)(&pfnxrEnumerateDisplayRefreshRatesFB)));
|
|
||||||
|
|
||||||
OXR(pfnxrEnumerateDisplayRefreshRatesFB(
|
OXR(xrGetInstanceProcAddr(
|
||||||
gAppState.Session, 0, &gAppState.NumSupportedDisplayRefreshRates, NULL));
|
gAppState.Instance,
|
||||||
|
"xrRequestDisplayRefreshRateFB",
|
||||||
|
(PFN_xrVoidFunction *) (&gAppState.pfnRequestDisplayRefreshRate)));
|
||||||
|
|
||||||
gAppState.SupportedDisplayRefreshRates =
|
// Test requesting the system default.
|
||||||
(float*)malloc(gAppState.NumSupportedDisplayRefreshRates * sizeof(float));
|
OXR(gAppState.pfnRequestDisplayRefreshRate(gAppState.Session, 0.0f));
|
||||||
OXR(pfnxrEnumerateDisplayRefreshRatesFB(
|
ALOGV("Requesting system default display refresh rate");
|
||||||
gAppState.Session,
|
|
||||||
gAppState.NumSupportedDisplayRefreshRates,
|
|
||||||
&gAppState.NumSupportedDisplayRefreshRates,
|
|
||||||
gAppState.SupportedDisplayRefreshRates));
|
|
||||||
ALOGV("Supported Refresh Rates:");
|
|
||||||
for (uint32_t i = 0; i < gAppState.NumSupportedDisplayRefreshRates; i++) {
|
|
||||||
ALOGV("%d:%f", i, gAppState.SupportedDisplayRefreshRates[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OXR(xrGetInstanceProcAddr(
|
|
||||||
gAppState.Instance,
|
|
||||||
"xrGetDisplayRefreshRateFB",
|
|
||||||
(PFN_xrVoidFunction*)(&gAppState.pfnGetDisplayRefreshRate)));
|
|
||||||
|
|
||||||
OXR(gAppState.pfnGetDisplayRefreshRate(gAppState.Session, &gAppState.currentDisplayRefreshRate));
|
|
||||||
ALOGV("Current System Display Refresh Rate: %f", gAppState.currentDisplayRefreshRate);
|
|
||||||
|
|
||||||
OXR(xrGetInstanceProcAddr(
|
|
||||||
gAppState.Instance,
|
|
||||||
"xrRequestDisplayRefreshRateFB",
|
|
||||||
(PFN_xrVoidFunction*)(&gAppState.pfnRequestDisplayRefreshRate)));
|
|
||||||
|
|
||||||
// Test requesting the system default.
|
|
||||||
OXR(gAppState.pfnRequestDisplayRefreshRate(gAppState.Session, 0.0f));
|
|
||||||
ALOGV("Requesting system default display refresh rate");
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t numOutputSpaces = 0;
|
uint32_t numOutputSpaces = 0;
|
||||||
OXR(xrEnumerateReferenceSpaces(gAppState.Session, 0, &numOutputSpaces, NULL));
|
OXR(xrEnumerateReferenceSpaces(gAppState.Session, 0, &numOutputSpaces, NULL));
|
||||||
|
@ -1561,15 +1565,16 @@ void TBXR_InitRenderer( ) {
|
||||||
gAppState.Projections[eye].type = XR_TYPE_VIEW;
|
gAppState.Projections[eye].type = XR_TYPE_VIEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PICO_XR
|
if (strstr(gAppState.OpenXRHMDModel, "Quest") == NULL) // PICO
|
||||||
xrGetInstanceProcAddr(gAppState.Instance,"xrSetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrSetConfigPICO));
|
{
|
||||||
xrGetInstanceProcAddr(gAppState.Instance,"xrGetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrGetConfigPICO));
|
xrGetInstanceProcAddr(gAppState.Instance,"xrSetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrSetConfigPICO));
|
||||||
|
xrGetInstanceProcAddr(gAppState.Instance,"xrGetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrGetConfigPICO));
|
||||||
|
|
||||||
pfnXrSetConfigPICO(gAppState.Session,TRACKING_ORIGIN,"0");
|
pfnXrSetConfigPICO(gAppState.Session,TRACKING_ORIGIN,"0");
|
||||||
pfnXrSetConfigPICO(gAppState.Session,TRACKING_ORIGIN,"1");
|
pfnXrSetConfigPICO(gAppState.Session,TRACKING_ORIGIN,"1");
|
||||||
|
|
||||||
pfnXrGetConfigPICO(gAppState.Session, GET_DISPLAY_RATE, &gAppState.currentDisplayRefreshRate);
|
pfnXrGetConfigPICO(gAppState.Session, GET_DISPLAY_RATE, &gAppState.currentDisplayRefreshRate);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
ovrRenderer_Create(
|
ovrRenderer_Create(
|
||||||
gAppState.Session,
|
gAppState.Session,
|
||||||
|
@ -1592,6 +1597,9 @@ void TBXR_InitialiseOpenXR()
|
||||||
ovrEgl_CreateContext(&gAppState.Egl, NULL);
|
ovrEgl_CreateContext(&gAppState.Egl, NULL);
|
||||||
EglInitExtensions();
|
EglInitExtensions();
|
||||||
|
|
||||||
|
//First, find out which HMD we are using
|
||||||
|
gAppState.OpenXRHMDModel = (char*)getenv("OPENXR_HMD");
|
||||||
|
|
||||||
PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR;
|
PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR;
|
||||||
xrGetInstanceProcAddr(
|
xrGetInstanceProcAddr(
|
||||||
XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR);
|
XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR);
|
||||||
|
@ -1617,22 +1625,27 @@ void TBXR_InitialiseOpenXR()
|
||||||
XrInstanceCreateInfo instanceCreateInfo;
|
XrInstanceCreateInfo instanceCreateInfo;
|
||||||
memset(&instanceCreateInfo, 0, sizeof(instanceCreateInfo));
|
memset(&instanceCreateInfo, 0, sizeof(instanceCreateInfo));
|
||||||
instanceCreateInfo.type = XR_TYPE_INSTANCE_CREATE_INFO;
|
instanceCreateInfo.type = XR_TYPE_INSTANCE_CREATE_INFO;
|
||||||
#ifdef META_QUEST
|
|
||||||
instanceCreateInfo.next = NULL;
|
|
||||||
#endif
|
|
||||||
#ifdef PICO_XR
|
|
||||||
XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR};
|
|
||||||
instanceCreateInfoAndroid.applicationVM = java.Vm;
|
|
||||||
instanceCreateInfoAndroid.applicationActivity = java.ActivityObject;
|
|
||||||
|
|
||||||
instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid;
|
XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR};
|
||||||
#endif
|
instanceCreateInfoAndroid.applicationVM = java.Vm;
|
||||||
|
instanceCreateInfoAndroid.applicationActivity = java.ActivityObject;
|
||||||
|
|
||||||
|
instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid;
|
||||||
|
|
||||||
instanceCreateInfo.createFlags = 0;
|
instanceCreateInfo.createFlags = 0;
|
||||||
instanceCreateInfo.applicationInfo = appInfo;
|
instanceCreateInfo.applicationInfo = appInfo;
|
||||||
instanceCreateInfo.enabledApiLayerCount = 0;
|
instanceCreateInfo.enabledApiLayerCount = 0;
|
||||||
instanceCreateInfo.enabledApiLayerNames = NULL;
|
instanceCreateInfo.enabledApiLayerNames = NULL;
|
||||||
instanceCreateInfo.enabledExtensionCount = numRequiredExtensions;
|
if (strstr(gAppState.OpenXRHMDModel, "Quest") != NULL)
|
||||||
instanceCreateInfo.enabledExtensionNames = requiredExtensionNames;
|
{
|
||||||
|
instanceCreateInfo.enabledExtensionCount = numRequiredExtensions_meta;
|
||||||
|
instanceCreateInfo.enabledExtensionNames = requiredExtensionNames_meta;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instanceCreateInfo.enabledExtensionCount = numRequiredExtensions_pico;
|
||||||
|
instanceCreateInfo.enabledExtensionNames = requiredExtensionNames_pico;
|
||||||
|
}
|
||||||
|
|
||||||
XrResult initResult;
|
XrResult initResult;
|
||||||
OXR(initResult = xrCreateInstance(&instanceCreateInfo, &gAppState.Instance));
|
OXR(initResult = xrCreateInstance(&instanceCreateInfo, &gAppState.Instance));
|
||||||
|
@ -1676,17 +1689,18 @@ instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid;
|
||||||
OXR(pfnGetOpenGLESGraphicsRequirementsKHR(gAppState.Instance, gAppState.SystemId,
|
OXR(pfnGetOpenGLESGraphicsRequirementsKHR(gAppState.Instance, gAppState.SystemId,
|
||||||
&graphicsRequirements));
|
&graphicsRequirements));
|
||||||
|
|
||||||
#ifdef META_QUEST
|
if (strstr(gAppState.OpenXRHMDModel, "Quest") != NULL)
|
||||||
XrSystemColorSpacePropertiesFB colorSpacePropertiesFB = {};
|
{
|
||||||
colorSpacePropertiesFB.type = XR_TYPE_SYSTEM_COLOR_SPACE_PROPERTIES_FB;
|
XrSystemColorSpacePropertiesFB colorSpacePropertiesFB = {};
|
||||||
|
colorSpacePropertiesFB.type = XR_TYPE_SYSTEM_COLOR_SPACE_PROPERTIES_FB;
|
||||||
|
|
||||||
XrSystemProperties systemProperties = {};
|
XrSystemProperties systemProperties = {};
|
||||||
systemProperties.type = XR_TYPE_SYSTEM_PROPERTIES;
|
systemProperties.type = XR_TYPE_SYSTEM_PROPERTIES;
|
||||||
systemProperties.next = &colorSpacePropertiesFB;
|
systemProperties.next = &colorSpacePropertiesFB;
|
||||||
OXR(xrGetSystemProperties(gAppState.Instance, gAppState.SystemId, &systemProperties));
|
OXR(xrGetSystemProperties(gAppState.Instance, gAppState.SystemId, &systemProperties));
|
||||||
|
|
||||||
ALOGV("System Color Space Properties: colorspace=%d", colorSpacePropertiesFB.colorSpace);
|
ALOGV("System Color Space Properties: colorspace=%d", colorSpacePropertiesFB.colorSpace);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
TBXR_InitialiseResolution();
|
TBXR_InitialiseResolution();
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,6 +224,7 @@ typedef struct
|
||||||
bool Resumed;
|
bool Resumed;
|
||||||
bool Focused;
|
bool Focused;
|
||||||
bool FrameSetup;
|
bool FrameSetup;
|
||||||
|
char* OpenXRHMDModel;
|
||||||
|
|
||||||
float Width;
|
float Width;
|
||||||
float Height;
|
float Height;
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
JK3_BASE_CFLAGS = -DHAVE_GLES -DFINAL_BUILD -fexceptions -Wall -Wno-write-strings -Wno-comment -fno-caller-saves -fno-tree-vectorize -Wno-unused-but-set-variable -fvisibility=hidden
|
||||||
# Uncomment for the correct headset - slight changes required in OpenXR implementation
|
JK3_BASE_CPPFLAGS = -fvisibility-inlines-hidden -Wno-invalid-offsetof -fvisibility=hidden
|
||||||
OPENXR_HMD := META_QUEST
|
|
||||||
#OPENXR_HMD := PICO_XR
|
|
||||||
|
|
||||||
JK3_BASE_CFLAGS = -O1 -D$(OPENXR_HMD) -DHAVE_GLES -DFINAL_BUILD -fexceptions -Wall -Wno-write-strings -Wno-comment -fno-caller-saves -fno-tree-vectorize -Wno-unused-but-set-variable -fvisibility=hidden
|
|
||||||
JK3_BASE_CPPFLAGS = -O1 -fvisibility-inlines-hidden -Wno-invalid-offsetof -fvisibility=hidden
|
|
||||||
|
|
||||||
JK3_BASE_LDLIBS =
|
JK3_BASE_LDLIBS =
|
||||||
|
|
||||||
|
|
4
Projects/Android/libs/arm64-v8a/readme.txt
Normal file
4
Projects/Android/libs/arm64-v8a/readme.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Into this folder copy the libopenxr_loader.so for each HMD required to support, suffixed with the headset type:
|
||||||
|
|
||||||
|
libopenxr_loader_meta.so
|
||||||
|
libopenxr_loader_pico.so
|
|
@ -4,23 +4,7 @@ include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE := openxr_loader
|
LOCAL_MODULE := openxr_loader
|
||||||
|
|
||||||
ifeq ($(NDK_DEBUG),1)
|
LOCAL_SRC_FILES := lib$(LOCAL_MODULE).so
|
||||||
BUILDTYPE := Debug
|
|
||||||
else
|
|
||||||
BUILDTYPE := Release
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# Meta provide Debug and Release libraries
|
|
||||||
ifeq ($(OPENXR_HMD),META_QUEST)
|
|
||||||
LOCAL_SRC_FILES := ../../../../../OpenXR/Libs/Android/$(TARGET_ARCH_ABI)/$(BUILDTYPE)/lib$(LOCAL_MODULE).so
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Pico only provide the one loader
|
|
||||||
ifeq ($(OPENXR_HMD),PICO_XR)
|
|
||||||
LOCAL_SRC_FILES := ../../../../../OpenXR/libs/android.$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE).so
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# NOTE: This check is added to prevent the following error when running a "make clean" where
|
# NOTE: This check is added to prevent the following error when running a "make clean" where
|
||||||
# the prebuilt lib may have been deleted: "LOCAL_SRC_FILES points to a missing file"
|
# the prebuilt lib may have been deleted: "LOCAL_SRC_FILES points to a missing file"
|
||||||
|
|
BIN
Projects/AndroidPrebuilt/jni/libopenxr_loader.so
Normal file
BIN
Projects/AndroidPrebuilt/jni/libopenxr_loader.so
Normal file
Binary file not shown.
|
@ -65,7 +65,16 @@ import java.util.Vector;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.loadLibrary("openxr_loader");
|
String model = android.os.Build.MODEL;
|
||||||
|
if (model.contains("Quest"))
|
||||||
|
{
|
||||||
|
System.loadLibrary("openxr_loader_meta");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.loadLibrary("openxr_loader_pico");
|
||||||
|
}
|
||||||
|
|
||||||
System.loadLibrary( "openjk_" + game );
|
System.loadLibrary( "openjk_" + game );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +257,8 @@ import java.util.Vector;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setenv("JK_LIBDIR", getApplicationInfo().nativeLibraryDir, true);
|
setenv("JK_LIBDIR", getApplicationInfo().nativeLibraryDir, true);
|
||||||
|
|
||||||
|
setenv("OPENXR_HMD", model, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue