Skip to content

Commit

Permalink
[vr] Move logging to Citra-android backend
Browse files Browse the repository at this point in the history
  • Loading branch information
amwatson committed Jan 27, 2024
1 parent ed59ea7 commit e528693
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 111 deletions.
21 changes: 0 additions & 21 deletions src/android/app/src/main/jni/input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@
#include <android/log.h>
#include <stdlib.h>

#if !defined(LOG_TAG)
#define LOG_TAG "citra"
#endif

#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define ALOGV(...) \
__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#ifndef NDEBUG
#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#else
#define ALOGD(...)
#endif
#define FAIL(...) \
do { \
__android_log_print(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__); \
abort(); \
} while (0)
namespace InputManager {

static std::shared_ptr<ButtonFactory> button;
Expand Down Expand Up @@ -333,7 +314,6 @@ NDKMotionFactory* NDKMotionHandler() {
}

void Init() {
ALOGI("initializing input manager");
button = std::make_shared<ButtonFactory>();
analog = std::make_shared<AnalogFactory>();
motion = std::make_shared<NDKMotionFactory>();
Expand All @@ -343,7 +323,6 @@ void Init() {
}

void Shutdown() {
ALOGI("shutting down input manager");
Input::UnregisterFactory<Input::ButtonDevice>("gamepad");
Input::UnregisterFactory<Input::AnalogDevice>("gamepad");
Input::UnregisterFactory<Input::MotionDevice>("motion_emu");
Expand Down
48 changes: 24 additions & 24 deletions src/android/app/src/main/jni/vr/OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ License : Licensed under GPLv3 or any later version.
do { \
const int32_t ret = fn; \
if (ret < 0) { \
ALOGE("ERROR (%s): %s() returned %d", __FUNCTION__, #fn, ret); \
ALOGE("ERROR ({}): {}() returned {}", __FUNCTION__, #fn, ret); \
return (returnCode); \
} \
} while (0)
Expand All @@ -38,7 +38,7 @@ void OXR_CheckErrors(XrResult result, const char* function, bool failOnError) {
if (failOnError) {
FAIL("OpenXR error: %s: %s\n", function, errorBuffer);
} else {
ALOGV("OpenXR error: %s: %s\n", function, errorBuffer);
ALOGV("OpenXR error: {}: {}\n", function, errorBuffer);
}
}
}
Expand Down Expand Up @@ -79,7 +79,7 @@ namespace {
OXR(xrEnumerateApiLayerProperties(numInputLayers, &numOutputLayers, layerProperties.data()));

for (uint32_t i = 0; i < numOutputLayers; i++) {
ALOGI("Found layer %s", layerProperties[i].layerName);
ALOGI("Found layer {}", layerProperties[i].layerName);
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ int XrCheckRequiredExtensions(const char* const* requiredExtensionNames,
uint32_t numOutputExtensions = 0;
OXR(xrEnumerateInstanceExtensionProperties(NULL, numInputExtensions, &numOutputExtensions,
NULL));
ALOGV("xrEnumerateInstanceExtensionProperties found %u extension(s).", numOutputExtensions);
ALOGV("xrEnumerateInstanceExtensionProperties found {} extension(s).", numOutputExtensions);

numInputExtensions = numOutputExtensions;

Expand All @@ -124,21 +124,21 @@ int XrCheckRequiredExtensions(const char* const* requiredExtensionNames,
extensionProperties.data()));
#ifndef NDEBUG
for (uint32_t i = 0; i < numOutputExtensions; i++) {
ALOGV("Extension #%d = '%s'.", i, extensionProperties[i].extensionName);
ALOGV("Extension #{} = '{}'.", i, extensionProperties[i].extensionName);
}
#endif

for (uint32_t i = 0; i < numRequiredExtensions; i++) {
bool found = false;
for (uint32_t j = 0; j < numOutputExtensions; j++) {
if (!strcmp(requiredExtensionNames[i], extensionProperties[j].extensionName)) {
ALOGD("Found required extension %s", requiredExtensionNames[i]);
ALOGD("Found required extension {}", requiredExtensionNames[i]);
found = true;
break;
}
}
if (!found) {
ALOGE("Failed to find required extension %s", requiredExtensionNames[i]);
ALOGE("Failed to find required extension {}", requiredExtensionNames[i]);
return -2;
}
}
Expand Down Expand Up @@ -185,7 +185,7 @@ XrInstance XrInstanceCreate() {
XrInstance instanceLocal;
OXR(initResult = xrCreateInstance(&ici, &instanceLocal));
if (initResult != XR_SUCCESS) {
ALOGE("ERROR(%s()): Failed to create XR instance_: %d.", __FUNCTION__, initResult);
ALOGE("ERROR({}()): Failed to create XR instance_: {}.", __FUNCTION__, initResult);
return XR_NULL_HANDLE;
}
// Log runtime instance info
Expand All @@ -194,7 +194,7 @@ XrInstance XrInstanceCreate() {
instanceInfo.type = XR_TYPE_INSTANCE_PROPERTIES;
instanceInfo.next = NULL;
OXR(xrGetInstanceProperties(instanceLocal, &instanceInfo));
ALOGV("Runtime %s: Version : %u.%u.%u", instanceInfo.runtimeName,
ALOGV("Runtime {}: Version : {}.{}.{}", instanceInfo.runtimeName,
XR_VERSION_MAJOR(instanceInfo.runtimeVersion),
XR_VERSION_MINOR(instanceInfo.runtimeVersion),
XR_VERSION_PATCH(instanceInfo.runtimeVersion));
Expand All @@ -216,7 +216,7 @@ int32_t XrInitializeLoaderTrampoline(JavaVM* jvm, jobject activityObject) {
loaderInitializeInfoAndroid.applicationContext = activityObject;
xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid);
} else {
ALOGE("%s(): xrInitializeLoaderKHR is NULL", __FUNCTION__);
ALOGE("{}(): xrInitializeLoaderKHR is NULL", __FUNCTION__);
return -1;
}
return 0;
Expand All @@ -241,7 +241,7 @@ XrSession XrSessionCreate(const XrInstance& localInstance, const XrSystemId& sys
XrResult initResult;
OXR(initResult = xrCreateSession(localInstance, &sessionCreateInfo, &session));
if (initResult != XR_SUCCESS) {
ALOGE("Failed to create XR session: %d.", initResult);
ALOGE("Failed to create XR session: {}.", initResult);
return XR_NULL_HANDLE;
}
return session;
Expand All @@ -258,7 +258,7 @@ XrSystemId XrGetSystemId(const XrInstance& instanceLocal) {
XrResult initResult;
OXR(initResult = xrGetSystem(instanceLocal, &sgi, &systemId));
if (initResult != XR_SUCCESS) {
ALOGE("ERROR (%s()): Failed to get system.", __FUNCTION__);
ALOGE("ERROR ({}()): Failed to get system.", __FUNCTION__);
return XR_NULL_SYSTEM_ID;
}
return systemId;
Expand All @@ -269,14 +269,14 @@ size_t GetMaxLayerCount(const XrInstance& instanceLocal, const XrSystemId& syste
systemProperties.type = XR_TYPE_SYSTEM_PROPERTIES;
OXR(xrGetSystemProperties(instanceLocal, systemId, &systemProperties));

ALOGV("System Properties: Name=%s VendorId=%x", systemProperties.systemName,
ALOGV("System Properties: Name={} VendorId={}", systemProperties.systemName,
systemProperties.vendorId);
ALOGV("System Graphics Properties: MaxWidth=%d MaxHeight=%d MaxLayers=%d",
ALOGV("System Graphics Properties: MaxWidth={} MaxHeight={} MaxLayers={}",
systemProperties.graphicsProperties.maxSwapchainImageWidth,
systemProperties.graphicsProperties.maxSwapchainImageHeight,
systemProperties.graphicsProperties.maxLayerCount);
ALOGV("System Tracking Properties: OrientationTracking=%s "
"PositionTracking=%s",
ALOGV("System Tracking Properties: OrientationTracking={} "
"PositionTracking={}",
systemProperties.trackingProperties.orientationTracking ? "True" : "False",
systemProperties.trackingProperties.positionTracking ? "True" : "False");

Expand Down Expand Up @@ -310,20 +310,20 @@ int32_t OpenXr::XrViewConfigInit() {
OXR(xrEnumerateViewConfigurations(instance_, systemId_, viewportConfigTypeCount,
&viewportConfigTypeCount, viewportConfigurationTypes.data()));

ALOGV("Available Viewport Configuration Types: %d", viewportConfigTypeCount);
ALOGV("Available Viewport Configuration Types: {}", viewportConfigTypeCount);

bool foundSupportedViewport;
for (uint32_t i = 0; i < viewportConfigTypeCount; i++) {
const XrViewConfigurationType viewportConfigType = viewportConfigurationTypes[i];

ALOGV("Viewport configuration type %d : %s", viewportConfigType,
ALOGV("Viewport configuration type {} : {}", viewportConfigType,
viewportConfigType == VIEW_CONFIG_TYPE ? "Selected" : "");

XrViewConfigurationProperties viewportConfig;
viewportConfig.type = XR_TYPE_VIEW_CONFIGURATION_PROPERTIES;
OXR(xrGetViewConfigurationProperties(instance_, systemId_, viewportConfigType,
&viewportConfig));
ALOGV("FovMutable=%s ConfigurationType %d", viewportConfig.fovMutable ? "true" : "false",
ALOGV("FovMutable={} ConfigurationType {}", viewportConfig.fovMutable ? "true" : "false",
viewportConfig.viewConfigurationType);

uint32_t viewCount;
Expand All @@ -347,12 +347,12 @@ int32_t OpenXr::XrViewConfigInit() {
const XrViewConfigurationView* element = &elements[e];
(void)element;

ALOGV("Viewport [%d]: Recommended Width=%d Height=%d "
"SampleCount=%d",
ALOGV("Viewport [{}]: Recommended Width={} Height={} "
"SampleCount={}",
e, element->recommendedImageRectWidth, element->recommendedImageRectHeight,
element->recommendedSwapchainSampleCount);

ALOGV("Viewport [%d]: Max Width=%d Height=%d SampleCount=%d", e,
ALOGV("Viewport [{}]: Max Width={} Height={} SampleCount={}", e,
element->maxImageRectWidth, element->maxImageRectHeight,
element->maxSwapchainSampleCount);
}
Expand All @@ -366,7 +366,7 @@ int32_t OpenXr::XrViewConfigInit() {
}
}
} else {
ALOGD("Empty viewport configuration type: %d", viewCount);
ALOGD("Empty viewport configuration type: {}", viewCount);
}
}
if (!foundSupportedViewport) {
Expand Down Expand Up @@ -490,7 +490,7 @@ int OpenXr::OpenXRInit(JavaVM* const jvm, const jobject activityObject) {
const XrVersion eglVersion = XR_MAKE_VERSION(eglMajor, eglMinor, 0);
if (eglVersion < graphicsRequirements.minApiVersionSupported ||
eglVersion > graphicsRequirements.maxApiVersionSupported) {
ALOGE("GLES version %d.%d not supported", eglMajor, eglMinor);
ALOGE("GLES version {}.{} not supported", eglMajor, eglMinor);
return -5;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/android/app/src/main/jni/vr/XrController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace {
XrAction CreateAction(XrActionSet actionSet, XrActionType type, const char* actionName,
const char* localizedName, int countSubactionPaths = 0,
XrPath* subactionPaths = nullptr) {
ALOG_INPUT_VERBOSE("CreateAction %s, %d" actionName, countSubactionPaths);
ALOG_INPUT_VERBOSE("CreateAction {}, {}" actionName, countSubactionPaths);

XrActionCreateInfo aci = {};
aci.type = XR_TYPE_ACTION_CREATE_INFO;
Expand Down
28 changes: 14 additions & 14 deletions src/android/app/src/main/jni/vr/gl/Egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ EglContext::EglContext() {

const int32_t ret = Init();
if (ret < 0) {
FAIL("EglContext::EglContext() failed: ret=%i", ret);
FAIL("EglContext::EglContext() failed: ret=%d", ret);
}
}

Expand All @@ -68,15 +68,15 @@ EglContext::~EglContext() {
int32_t EglContext::Init() {
mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (mDisplay == EGL_NO_DISPLAY) {
ALOGE(" eglGetDisplay() failed: %s", EglErrorToStr(eglGetError()));
ALOGE(" eglGetDisplay() failed: {}", EglErrorToStr(eglGetError()));
return -1;
}
{
ALOGV(" eglInitialize(mDisplay, &MajorVersion, &MinorVersion)");
EGLint majorVersion = 0;
EGLint minorVersion = 0;
if (eglInitialize(mDisplay, &majorVersion, &minorVersion) == EGL_FALSE) {
ALOGE(" eglInitialize() failed: %s", EglErrorToStr(eglGetError()));
ALOGE(" eglInitialize() failed: {}", EglErrorToStr(eglGetError()));
return -2;
}
}
Expand All @@ -98,45 +98,45 @@ int32_t EglContext::Init() {
EGL_NONE};

if (eglChooseConfig(mDisplay, configAttribs, &mConfig, 1, &numConfigs) == EGL_FALSE) {
ALOGE(" eglChooseConfig() failed: %s", EglErrorToStr(eglGetError()));
ALOGE(" eglChooseConfig() failed: {}", EglErrorToStr(eglGetError()));
return -3;
}
// print out chosen config attributes
ALOGV(" Chosen EGLConfig attributes:");
{
EGLint value = 0;
eglGetConfigAttrib(mDisplay, mConfig, EGL_RED_SIZE, &value);
ALOGV(" EGL_RED_SIZE: %i", value);
ALOGV(" EGL_RED_SIZE: {}", value);
}
{
EGLint value = 0;
eglGetConfigAttrib(mDisplay, mConfig, EGL_GREEN_SIZE, &value);
ALOGV(" EGL_GREEN_SIZE: %i", value);
ALOGV(" EGL_GREEN_SIZE: {}", value);
}
{
EGLint value = 0;
eglGetConfigAttrib(mDisplay, mConfig, EGL_BLUE_SIZE, &value);
ALOGV(" EGL_BLUE_SIZE: %i", value);
ALOGV(" EGL_BLUE_SIZE: {}", value);
}
{
EGLint value = 0;
eglGetConfigAttrib(mDisplay, mConfig, EGL_ALPHA_SIZE, &value);
ALOGV(" EGL_ALPHA_SIZE: %i", value);
ALOGV(" EGL_ALPHA_SIZE: {}", value);
}
{
EGLint value = 0;
eglGetConfigAttrib(mDisplay, mConfig, EGL_DEPTH_SIZE, &value);
ALOGV(" EGL_DEPTH_SIZE: %i", value);
ALOGV(" EGL_DEPTH_SIZE: {}", value);
}
{
EGLint value = 0;
eglGetConfigAttrib(mDisplay, mConfig, EGL_STENCIL_SIZE, &value);
ALOGV(" EGL_STENCIL_SIZE: %i", value);
ALOGV(" EGL_STENCIL_SIZE: {}", value);
}
{
EGLint value = 0;
eglGetConfigAttrib(mDisplay, mConfig, EGL_SAMPLES, &value);
ALOGV(" EGL_SAMPLES: %i", value);
ALOGV(" EGL_SAMPLES: {}", value);
}

EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
Expand All @@ -145,23 +145,23 @@ int32_t EglContext::Init() {
"contextAttribs)");
mContext = eglCreateContext(mDisplay, mConfig, EGL_NO_CONTEXT, contextAttribs);
if (mContext == EGL_NO_CONTEXT) {
ALOGE(" eglCreateContext() failed: %s", EglErrorToStr(eglGetError()));
ALOGE(" eglCreateContext() failed: {}", EglErrorToStr(eglGetError()));
return -4;
}
const EGLint surfaceAttribs[] = {EGL_WIDTH, 16, EGL_HEIGHT, 16, EGL_NONE};
ALOGV(" mDummySurface = eglCreatePbufferSurface(mDisplay, mConfig, "
"surfaceAttribs)");
mDummySurface = eglCreatePbufferSurface(mDisplay, mConfig, surfaceAttribs);
if (mDummySurface == EGL_NO_SURFACE) {
ALOGE(" eglCreatePbufferSurface() failed: %s", EglErrorToStr(eglGetError()));
ALOGE(" eglCreatePbufferSurface() failed: {}", EglErrorToStr(eglGetError()));
eglDestroyContext(mDisplay, mContext);
mContext = EGL_NO_CONTEXT;
return -5;
}
ALOGV(" eglMakeCurrent(mDisplay, mDummySurface, mDummySurface, "
"mContext)");
if (eglMakeCurrent(mDisplay, mDummySurface, mDummySurface, mContext) == EGL_FALSE) {
ALOGE(" eglMakeCurrent() failed: %s", EglErrorToStr(eglGetError()));
ALOGE(" eglMakeCurrent() failed: {}", EglErrorToStr(eglGetError()));
eglDestroySurface(mDisplay, mDummySurface);
eglDestroyContext(mDisplay, mContext);
mContext = EGL_NO_CONTEXT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void GameSurfaceLayer::CreateSwapchain() {
xsci.mipCount = 0;

ALOGI(
"GameSurfaceLayer: Creating swapchain of size %dx%d (%dx%d with resolution factor %dx)",
"GameSurfaceLayer: Creating swapchain of size {}x{} ({}x{} with resolution factor {}x)",
xsci.width, xsci.height, SURFACE_WIDTH_UNSCALED, SURFACE_HEIGHT_UNSCALED,
resolutionFactor_);

Expand Down
4 changes: 2 additions & 2 deletions src/android/app/src/main/jni/vr/utils/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ License : Licensed under GPLv3 or any later version.
#define BAIL_ON_COND(cond, errorStr, returnCode) \
do { \
if (cond) { \
ALOGE("ERROR (%s): %s", __FUNCTION__, errorStr); \
ALOGE("ERROR ({}): {}", __FUNCTION__, errorStr); \
return (returnCode); \
} \
} while (0)
Expand All @@ -30,7 +30,7 @@ License : Licensed under GPLv3 or any later version.
do { \
const int32_t ret = fn; \
if (ret < 0) { \
ALOGE("ERROR (%s): %s() returned %d", __FUNCTION__, #fn, ret); \
ALOGE("ERROR ({}): {}() returned {}", __FUNCTION__, #fn, ret); \
return (returnCode); \
} \
} while (0)
Expand Down

0 comments on commit e528693

Please sign in to comment.