Skip to content
Permalink
Browse files

Merge pull request #12331 from hrydgard/init-fixes

Assorted init fixes and logging.
  • Loading branch information...
hrydgard committed Sep 17, 2019
2 parents 6d2be0d + 5092026 commit 709f0f67960406ae0a06f4c75059744ea23f517a
@@ -220,6 +220,7 @@ static HINSTANCE vulkanLibrary;
#else
static void *vulkanLibrary;
#endif
const char *VulkanResultToString(VkResult res);

bool g_vulkanAvailabilityChecked = false;
bool g_vulkanMayBeAvailable = false;
@@ -322,7 +323,7 @@ bool VulkanMayBeAvailable() {
res = localEnumerateInstanceExtensionProperties(nullptr, &instanceExtCount, nullptr);
// Maximum paranoia.
if (res != VK_SUCCESS) {
ELOG("Enumerating VK extensions failed.");
ELOG("Enumerating VK extensions failed (%s)", VulkanResultToString(res));
goto bail;
}
if (instanceExtCount == 0) {
@@ -333,7 +334,7 @@ bool VulkanMayBeAvailable() {
instanceExts.resize(instanceExtCount);
res = localEnumerateInstanceExtensionProperties(nullptr, &instanceExtCount, instanceExts.data());
if (res != VK_SUCCESS) {
ELOG("Enumerating VK extensions failed.");
ELOG("Enumerating VK extensions failed (%s)", VulkanResultToString(res));
goto bail;
}
for (auto iter : instanceExts) {
@@ -379,13 +380,13 @@ bool VulkanMayBeAvailable() {
res = localCreateInstance(&ci, nullptr, &instance);
if (res != VK_SUCCESS) {
instance = nullptr;
ELOG("Failed to create vulkan instance.");
ELOG("VulkanMayBeAvailable: Failed to create vulkan instance (%s)", VulkanResultToString(res));
goto bail;
}
ILOG("VulkanMayBeAvailable: Vulkan test instance created successfully.");
res = localEnumerate(instance, &physicalDeviceCount, nullptr);
if (res != VK_SUCCESS) {
ELOG("VulkanMayBeAvailable: Failed to count physical devices.");
ELOG("VulkanMayBeAvailable: Failed to count physical devices (%s)", VulkanResultToString(res));
goto bail;
}
if (physicalDeviceCount == 0) {
@@ -395,7 +396,7 @@ bool VulkanMayBeAvailable() {
devices.resize(physicalDeviceCount);
res = localEnumerate(instance, &physicalDeviceCount, devices.data());
if (res != VK_SUCCESS) {
ELOG("VulkanMayBeAvailable: Failed to enumerate physical devices.");
ELOG("VulkanMayBeAvailable: Failed to enumerate physical devices (%s)", VulkanResultToString(res));
goto bail;
}
anyGood = false;
@@ -514,6 +514,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
LogManager *logman = LogManager::GetInstance();

#ifdef __ANDROID__
// On early versions of Android we don't need to ask permission.
CreateDirectoriesAndroid();
#endif

@@ -978,6 +979,7 @@ void NativeRender(GraphicsContext *graphicsContext) {
ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
break;
case GPUBackend::OPENGL:
default:
ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
break;
}
@@ -1005,7 +1007,6 @@ void NativeRender(GraphicsContext *graphicsContext) {
uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres));
// uiContext->SetBounds(Bounds(dp_xres/2, 0, dp_xres / 2, dp_yres / 2));


// OSX 10.6 and SDL 1.2 bug.
#if defined(__APPLE__) && !defined(USING_QT_UI)
static int dp_xres_old = dp_xres;
@@ -1016,14 +1017,6 @@ void NativeRender(GraphicsContext *graphicsContext) {
#endif
}

// Test lost/restore on PC
#if 0
if (gpu) {
gpu->DeviceLost();
gpu->DeviceRestore();
}
#endif

graphicsContext->Resize();
screenManager->resized();

@@ -1101,9 +1094,15 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
#endif
// We must have failed to load the config before, so load it now to avoid overwriting the old config
// with a freshly generated one.
// NOTE: If graphics backend isn't what's in the config (due to error fallback, or not matching the default
// and then getting permission), it will get out of sync. So we save and restore g_Config.iGPUBackend.
// Ideally we should simply reinitialize graphics to the mode from the config, but there are potential issues
// and I can't risk it before 1.9.0.
int gpuBackend = g_Config.iGPUBackend;
ILOG("Reloading config after storage permission grant.");
g_Config.Load();
PostLoadConfig();
g_Config.iGPUBackend = gpuBackend;
}
}

@@ -141,8 +141,18 @@ bool AndroidVulkanContext::InitAPI() {
}

bool AndroidVulkanContext::InitFromRenderThread(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) {
ILOG("InitSurfaceAndroid: desiredwidth=%d desiredheight=%d", desiredBackbufferSizeX, desiredBackbufferSizeY);
g_Vulkan->InitSurface(WINDOWSYSTEM_ANDROID, (void *)wnd, nullptr);
ILOG("AndroidVulkanContext::InitFromRenderThread: desiredwidth=%d desiredheight=%d", desiredBackbufferSizeX, desiredBackbufferSizeY);
if (!g_Vulkan) {
ELOG("AndroidVulkanContext::InitFromRenderThread: No Vulkan context");
return false;
}

VkResult res = g_Vulkan->InitSurface(WINDOWSYSTEM_ANDROID, (void *)wnd, nullptr);
if (res != VK_SUCCESS) {
ELOG("g_Vulkan->InitSurface failed: '%s'", VulkanResultToString(res));
return false;
}

if (g_validate_) {
int bits = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
g_Vulkan->InitDebugMsgCallback(&Vulkan_Dbg, bits, &g_LogOptions);
@@ -974,8 +974,13 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
ILOG("Trying again, this time with OpenGL.");
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
SetGPUBackend((GPUBackend)g_Config.iGPUBackend);
tries++;
goto retry;
// If we were still supporting EGL for GL:
// tries++;
// goto retry;
delete graphicsContext;
graphicsContext = nullptr;
renderLoopRunning = false;
return false;
}

delete graphicsContext;
@@ -20,12 +20,9 @@ TextDrawerAndroid::TextDrawerAndroid(Draw::DrawContext *draw) : TextDrawer(draw)
const char *textRendererClassName = "org/ppsspp/ppsspp/TextRenderer";
jclass localClass = findClass(textRendererClassName);
cls_textRenderer = reinterpret_cast<jclass>(env_->NewGlobalRef(localClass));
ILOG("cls_textRender: %p", cls_textRenderer);
if (cls_textRenderer) {
method_measureText = env_->GetStaticMethodID(cls_textRenderer, "measureText", "(Ljava/lang/String;D)I");
ILOG("method_measureText: %p", method_measureText);
method_renderText = env_->GetStaticMethodID(cls_textRenderer, "renderText", "(Ljava/lang/String;D)[I");
ILOG("method_renderText: %p", method_renderText);
} else {
ELOG("Failed to find class: '%s'", textRendererClassName);
}
@@ -109,6 +109,7 @@ void ProcessGPUFeatures() {
WLOG("GL DRIVER BUG: PVR with bad and terrible precision");
gl_extensions.bugs |= BUG_PVR_SHADER_PRECISION_TERRIBLE | BUG_PVR_SHADER_PRECISION_BAD;
} else {
// TODO: I'm not sure if the Rogue series is affected by this.
WLOG("GL DRIVER BUG: PVR with bad precision");
gl_extensions.bugs |= BUG_PVR_SHADER_PRECISION_BAD;
}

0 comments on commit 709f0f6

Please sign in to comment.
You can’t perform that action at this time.