Skip to content

Commit b562399

Browse files
committed
[vr] Move logging to Citra-android backend
1 parent 1d92111 commit b562399

File tree

10 files changed

+90
-111
lines changed

10 files changed

+90
-111
lines changed

src/android/app/src/main/jni/input_manager.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,6 @@
1919
#include <android/log.h>
2020
#include <stdlib.h>
2121

22-
#if !defined(LOG_TAG)
23-
#define LOG_TAG "citra"
24-
#endif
25-
26-
#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
27-
#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
28-
#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
29-
#define ALOGV(...) \
30-
__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
31-
#ifndef NDEBUG
32-
#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
33-
#else
34-
#define ALOGD(...)
35-
#endif
36-
#define FAIL(...) \
37-
do { \
38-
__android_log_print(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__); \
39-
abort(); \
40-
} while (0)
4122
namespace InputManager {
4223

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

335316
void Init() {
336-
ALOGI("initializing input manager");
337317
button = std::make_shared<ButtonFactory>();
338318
analog = std::make_shared<AnalogFactory>();
339319
motion = std::make_shared<NDKMotionFactory>();
@@ -343,7 +323,6 @@ void Init() {
343323
}
344324

345325
void Shutdown() {
346-
ALOGI("shutting down input manager");
347326
Input::UnregisterFactory<Input::ButtonDevice>("gamepad");
348327
Input::UnregisterFactory<Input::AnalogDevice>("gamepad");
349328
Input::UnregisterFactory<Input::MotionDevice>("motion_emu");

src/android/app/src/main/jni/vr/OpenXR.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ License : Licensed under GPLv3 or any later version.
2525
do { \
2626
const int32_t ret = fn; \
2727
if (ret < 0) { \
28-
ALOGE("ERROR (%s): %s() returned %d", __FUNCTION__, #fn, ret); \
28+
ALOGE("ERROR ({}): {}() returned {}", __FUNCTION__, #fn, ret); \
2929
return (returnCode); \
3030
} \
3131
} while (0)
@@ -38,7 +38,7 @@ void OXR_CheckErrors(XrResult result, const char* function, bool failOnError) {
3838
if (failOnError) {
3939
FAIL("OpenXR error: %s: %s\n", function, errorBuffer);
4040
} else {
41-
ALOGV("OpenXR error: %s: %s\n", function, errorBuffer);
41+
ALOGV("OpenXR error: {}: {}\n", function, errorBuffer);
4242
}
4343
}
4444
}
@@ -79,7 +79,7 @@ namespace {
7979
OXR(xrEnumerateApiLayerProperties(numInputLayers, &numOutputLayers, layerProperties.data()));
8080

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

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

114114
numInputExtensions = numOutputExtensions;
115115

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

131131
for (uint32_t i = 0; i < numRequiredExtensions; i++) {
132132
bool found = false;
133133
for (uint32_t j = 0; j < numOutputExtensions; j++) {
134134
if (!strcmp(requiredExtensionNames[i], extensionProperties[j].extensionName)) {
135-
ALOGD("Found required extension %s", requiredExtensionNames[i]);
135+
ALOGD("Found required extension {}", requiredExtensionNames[i]);
136136
found = true;
137137
break;
138138
}
139139
}
140140
if (!found) {
141-
ALOGE("Failed to find required extension %s", requiredExtensionNames[i]);
141+
ALOGE("Failed to find required extension {}", requiredExtensionNames[i]);
142142
return -2;
143143
}
144144
}
@@ -185,7 +185,7 @@ XrInstance XrInstanceCreate() {
185185
XrInstance instanceLocal;
186186
OXR(initResult = xrCreateInstance(&ici, &instanceLocal));
187187
if (initResult != XR_SUCCESS) {
188-
ALOGE("ERROR(%s()): Failed to create XR instance_: %d.", __FUNCTION__, initResult);
188+
ALOGE("ERROR({}()): Failed to create XR instance_: {}.", __FUNCTION__, initResult);
189189
return XR_NULL_HANDLE;
190190
}
191191
// Log runtime instance info
@@ -194,7 +194,7 @@ XrInstance XrInstanceCreate() {
194194
instanceInfo.type = XR_TYPE_INSTANCE_PROPERTIES;
195195
instanceInfo.next = NULL;
196196
OXR(xrGetInstanceProperties(instanceLocal, &instanceInfo));
197-
ALOGV("Runtime %s: Version : %u.%u.%u", instanceInfo.runtimeName,
197+
ALOGV("Runtime {}: Version : {}.{}.{}", instanceInfo.runtimeName,
198198
XR_VERSION_MAJOR(instanceInfo.runtimeVersion),
199199
XR_VERSION_MINOR(instanceInfo.runtimeVersion),
200200
XR_VERSION_PATCH(instanceInfo.runtimeVersion));
@@ -216,7 +216,7 @@ int32_t XrInitializeLoaderTrampoline(JavaVM* jvm, jobject activityObject) {
216216
loaderInitializeInfoAndroid.applicationContext = activityObject;
217217
xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid);
218218
} else {
219-
ALOGE("%s(): xrInitializeLoaderKHR is NULL", __FUNCTION__);
219+
ALOGE("{}(): xrInitializeLoaderKHR is NULL", __FUNCTION__);
220220
return -1;
221221
}
222222
return 0;
@@ -241,7 +241,7 @@ XrSession XrSessionCreate(const XrInstance& localInstance, const XrSystemId& sys
241241
XrResult initResult;
242242
OXR(initResult = xrCreateSession(localInstance, &sessionCreateInfo, &session));
243243
if (initResult != XR_SUCCESS) {
244-
ALOGE("Failed to create XR session: %d.", initResult);
244+
ALOGE("Failed to create XR session: {}.", initResult);
245245
return XR_NULL_HANDLE;
246246
}
247247
return session;
@@ -258,7 +258,7 @@ XrSystemId XrGetSystemId(const XrInstance& instanceLocal) {
258258
XrResult initResult;
259259
OXR(initResult = xrGetSystem(instanceLocal, &sgi, &systemId));
260260
if (initResult != XR_SUCCESS) {
261-
ALOGE("ERROR (%s()): Failed to get system.", __FUNCTION__);
261+
ALOGE("ERROR ({}()): Failed to get system.", __FUNCTION__);
262262
return XR_NULL_SYSTEM_ID;
263263
}
264264
return systemId;
@@ -269,14 +269,14 @@ size_t GetMaxLayerCount(const XrInstance& instanceLocal, const XrSystemId& syste
269269
systemProperties.type = XR_TYPE_SYSTEM_PROPERTIES;
270270
OXR(xrGetSystemProperties(instanceLocal, systemId, &systemProperties));
271271

272-
ALOGV("System Properties: Name=%s VendorId=%x", systemProperties.systemName,
272+
ALOGV("System Properties: Name={} VendorId={}", systemProperties.systemName,
273273
systemProperties.vendorId);
274-
ALOGV("System Graphics Properties: MaxWidth=%d MaxHeight=%d MaxLayers=%d",
274+
ALOGV("System Graphics Properties: MaxWidth={} MaxHeight={} MaxLayers={}",
275275
systemProperties.graphicsProperties.maxSwapchainImageWidth,
276276
systemProperties.graphicsProperties.maxSwapchainImageHeight,
277277
systemProperties.graphicsProperties.maxLayerCount);
278-
ALOGV("System Tracking Properties: OrientationTracking=%s "
279-
"PositionTracking=%s",
278+
ALOGV("System Tracking Properties: OrientationTracking={} "
279+
"PositionTracking={}",
280280
systemProperties.trackingProperties.orientationTracking ? "True" : "False",
281281
systemProperties.trackingProperties.positionTracking ? "True" : "False");
282282

@@ -310,20 +310,20 @@ int32_t OpenXr::XrViewConfigInit() {
310310
OXR(xrEnumerateViewConfigurations(instance_, systemId_, viewportConfigTypeCount,
311311
&viewportConfigTypeCount, viewportConfigurationTypes.data()));
312312

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

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

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

322322
XrViewConfigurationProperties viewportConfig;
323323
viewportConfig.type = XR_TYPE_VIEW_CONFIGURATION_PROPERTIES;
324324
OXR(xrGetViewConfigurationProperties(instance_, systemId_, viewportConfigType,
325325
&viewportConfig));
326-
ALOGV("FovMutable=%s ConfigurationType %d", viewportConfig.fovMutable ? "true" : "false",
326+
ALOGV("FovMutable={} ConfigurationType {}", viewportConfig.fovMutable ? "true" : "false",
327327
viewportConfig.viewConfigurationType);
328328

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

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

355-
ALOGV("Viewport [%d]: Max Width=%d Height=%d SampleCount=%d", e,
355+
ALOGV("Viewport [{}]: Max Width={} Height={} SampleCount={}", e,
356356
element->maxImageRectWidth, element->maxImageRectHeight,
357357
element->maxSwapchainSampleCount);
358358
}
@@ -366,7 +366,7 @@ int32_t OpenXr::XrViewConfigInit() {
366366
}
367367
}
368368
} else {
369-
ALOGD("Empty viewport configuration type: %d", viewCount);
369+
ALOGD("Empty viewport configuration type: {}", viewCount);
370370
}
371371
}
372372
if (!foundSupportedViewport) {
@@ -490,7 +490,7 @@ int OpenXr::OpenXRInit(JavaVM* const jvm, const jobject activityObject) {
490490
const XrVersion eglVersion = XR_MAKE_VERSION(eglMajor, eglMinor, 0);
491491
if (eglVersion < graphicsRequirements.minApiVersionSupported ||
492492
eglVersion > graphicsRequirements.maxApiVersionSupported) {
493-
ALOGE("GLES version %d.%d not supported", eglMajor, eglMinor);
493+
ALOGE("GLES version {}.{} not supported", eglMajor, eglMinor);
494494
return -5;
495495
}
496496
}

src/android/app/src/main/jni/vr/XrController.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace {
2828
XrAction CreateAction(XrActionSet actionSet, XrActionType type, const char* actionName,
2929
const char* localizedName, int countSubactionPaths = 0,
3030
XrPath* subactionPaths = nullptr) {
31-
ALOG_INPUT_VERBOSE("CreateAction %s, %d" actionName, countSubactionPaths);
31+
ALOG_INPUT_VERBOSE("CreateAction {}, {}" actionName, countSubactionPaths);
3232

3333
XrActionCreateInfo aci = {};
3434
aci.type = XR_TYPE_ACTION_CREATE_INFO;

src/android/app/src/main/jni/vr/gl/Egl.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ EglContext::EglContext() {
5656

5757
const int32_t ret = Init();
5858
if (ret < 0) {
59-
FAIL("EglContext::EglContext() failed: ret=%i", ret);
59+
FAIL("EglContext::EglContext() failed: ret=%d", ret);
6060
}
6161
}
6262

@@ -68,15 +68,15 @@ EglContext::~EglContext() {
6868
int32_t EglContext::Init() {
6969
mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
7070
if (mDisplay == EGL_NO_DISPLAY) {
71-
ALOGE(" eglGetDisplay() failed: %s", EglErrorToStr(eglGetError()));
71+
ALOGE(" eglGetDisplay() failed: {}", EglErrorToStr(eglGetError()));
7272
return -1;
7373
}
7474
{
7575
ALOGV(" eglInitialize(mDisplay, &MajorVersion, &MinorVersion)");
7676
EGLint majorVersion = 0;
7777
EGLint minorVersion = 0;
7878
if (eglInitialize(mDisplay, &majorVersion, &minorVersion) == EGL_FALSE) {
79-
ALOGE(" eglInitialize() failed: %s", EglErrorToStr(eglGetError()));
79+
ALOGE(" eglInitialize() failed: {}", EglErrorToStr(eglGetError()));
8080
return -2;
8181
}
8282
}
@@ -98,45 +98,45 @@ int32_t EglContext::Init() {
9898
EGL_NONE};
9999

100100
if (eglChooseConfig(mDisplay, configAttribs, &mConfig, 1, &numConfigs) == EGL_FALSE) {
101-
ALOGE(" eglChooseConfig() failed: %s", EglErrorToStr(eglGetError()));
101+
ALOGE(" eglChooseConfig() failed: {}", EglErrorToStr(eglGetError()));
102102
return -3;
103103
}
104104
// print out chosen config attributes
105105
ALOGV(" Chosen EGLConfig attributes:");
106106
{
107107
EGLint value = 0;
108108
eglGetConfigAttrib(mDisplay, mConfig, EGL_RED_SIZE, &value);
109-
ALOGV(" EGL_RED_SIZE: %i", value);
109+
ALOGV(" EGL_RED_SIZE: {}", value);
110110
}
111111
{
112112
EGLint value = 0;
113113
eglGetConfigAttrib(mDisplay, mConfig, EGL_GREEN_SIZE, &value);
114-
ALOGV(" EGL_GREEN_SIZE: %i", value);
114+
ALOGV(" EGL_GREEN_SIZE: {}", value);
115115
}
116116
{
117117
EGLint value = 0;
118118
eglGetConfigAttrib(mDisplay, mConfig, EGL_BLUE_SIZE, &value);
119-
ALOGV(" EGL_BLUE_SIZE: %i", value);
119+
ALOGV(" EGL_BLUE_SIZE: {}", value);
120120
}
121121
{
122122
EGLint value = 0;
123123
eglGetConfigAttrib(mDisplay, mConfig, EGL_ALPHA_SIZE, &value);
124-
ALOGV(" EGL_ALPHA_SIZE: %i", value);
124+
ALOGV(" EGL_ALPHA_SIZE: {}", value);
125125
}
126126
{
127127
EGLint value = 0;
128128
eglGetConfigAttrib(mDisplay, mConfig, EGL_DEPTH_SIZE, &value);
129-
ALOGV(" EGL_DEPTH_SIZE: %i", value);
129+
ALOGV(" EGL_DEPTH_SIZE: {}", value);
130130
}
131131
{
132132
EGLint value = 0;
133133
eglGetConfigAttrib(mDisplay, mConfig, EGL_STENCIL_SIZE, &value);
134-
ALOGV(" EGL_STENCIL_SIZE: %i", value);
134+
ALOGV(" EGL_STENCIL_SIZE: {}", value);
135135
}
136136
{
137137
EGLint value = 0;
138138
eglGetConfigAttrib(mDisplay, mConfig, EGL_SAMPLES, &value);
139-
ALOGV(" EGL_SAMPLES: %i", value);
139+
ALOGV(" EGL_SAMPLES: {}", value);
140140
}
141141

142142
EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
@@ -145,23 +145,23 @@ int32_t EglContext::Init() {
145145
"contextAttribs)");
146146
mContext = eglCreateContext(mDisplay, mConfig, EGL_NO_CONTEXT, contextAttribs);
147147
if (mContext == EGL_NO_CONTEXT) {
148-
ALOGE(" eglCreateContext() failed: %s", EglErrorToStr(eglGetError()));
148+
ALOGE(" eglCreateContext() failed: {}", EglErrorToStr(eglGetError()));
149149
return -4;
150150
}
151151
const EGLint surfaceAttribs[] = {EGL_WIDTH, 16, EGL_HEIGHT, 16, EGL_NONE};
152152
ALOGV(" mDummySurface = eglCreatePbufferSurface(mDisplay, mConfig, "
153153
"surfaceAttribs)");
154154
mDummySurface = eglCreatePbufferSurface(mDisplay, mConfig, surfaceAttribs);
155155
if (mDummySurface == EGL_NO_SURFACE) {
156-
ALOGE(" eglCreatePbufferSurface() failed: %s", EglErrorToStr(eglGetError()));
156+
ALOGE(" eglCreatePbufferSurface() failed: {}", EglErrorToStr(eglGetError()));
157157
eglDestroyContext(mDisplay, mContext);
158158
mContext = EGL_NO_CONTEXT;
159159
return -5;
160160
}
161161
ALOGV(" eglMakeCurrent(mDisplay, mDummySurface, mDummySurface, "
162162
"mContext)");
163163
if (eglMakeCurrent(mDisplay, mDummySurface, mDummySurface, mContext) == EGL_FALSE) {
164-
ALOGE(" eglMakeCurrent() failed: %s", EglErrorToStr(eglGetError()));
164+
ALOGE(" eglMakeCurrent() failed: {}", EglErrorToStr(eglGetError()));
165165
eglDestroySurface(mDisplay, mDummySurface);
166166
eglDestroyContext(mDisplay, mContext);
167167
mContext = EGL_NO_CONTEXT;

src/android/app/src/main/jni/vr/layers/GameSurfaceLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ void GameSurfaceLayer::CreateSwapchain() {
456456
xsci.mipCount = 0;
457457

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

src/android/app/src/main/jni/vr/utils/Common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ License : Licensed under GPLv3 or any later version.
2121
#define BAIL_ON_COND(cond, errorStr, returnCode) \
2222
do { \
2323
if (cond) { \
24-
ALOGE("ERROR (%s): %s", __FUNCTION__, errorStr); \
24+
ALOGE("ERROR ({}): {}", __FUNCTION__, errorStr); \
2525
return (returnCode); \
2626
} \
2727
} while (0)
@@ -30,7 +30,7 @@ License : Licensed under GPLv3 or any later version.
3030
do { \
3131
const int32_t ret = fn; \
3232
if (ret < 0) { \
33-
ALOGE("ERROR (%s): %s() returned %d", __FUNCTION__, #fn, ret); \
33+
ALOGE("ERROR ({}): {}() returned {}", __FUNCTION__, #fn, ret); \
3434
return (returnCode); \
3535
} \
3636
} while (0)

0 commit comments

Comments
 (0)