Merge pull request #15468 from unknownbrackets/switch-merge
Cleanup Switch ignoring of Vulkan
This commit is contained in:
commit
0eea0acf13
8 changed files with 63 additions and 53 deletions
|
@ -83,7 +83,7 @@ if(NOT ANDROID AND NOT IOS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT USE_LIBNX)
|
||||||
set(LINUX ON)
|
set(LINUX ON)
|
||||||
add_definitions(-D__STDC_CONSTANT_MACROS)
|
add_definitions(-D__STDC_CONSTANT_MACROS)
|
||||||
endif()
|
endif()
|
||||||
|
@ -146,6 +146,7 @@ option(UNITTEST "Set to ON to generate the unittest target" ${UNITTEST})
|
||||||
option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform" ${SIMULATOR})
|
option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform" ${SIMULATOR})
|
||||||
option(LIBRETRO "Set to ON to generate the libretro target" OFF)
|
option(LIBRETRO "Set to ON to generate the libretro target" OFF)
|
||||||
# :: Options
|
# :: Options
|
||||||
|
option(USE_LIBNX "Set to ON to build for Switch(libnx)" OFF)
|
||||||
option(USE_FFMPEG "Build with FFMPEG support" ON)
|
option(USE_FFMPEG "Build with FFMPEG support" ON)
|
||||||
option(USE_DISCORD "Build with Discord support" ON)
|
option(USE_DISCORD "Build with Discord support" ON)
|
||||||
option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
|
option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
|
||||||
|
@ -1147,8 +1148,12 @@ elseif(TARGET SDL2::SDL2)
|
||||||
SDL/SDLJoystick.cpp
|
SDL/SDLJoystick.cpp
|
||||||
SDL/SDLMain.cpp
|
SDL/SDLMain.cpp
|
||||||
SDL/SDLGLGraphicsContext.cpp
|
SDL/SDLGLGraphicsContext.cpp
|
||||||
SDL/SDLVulkanGraphicsContext.cpp
|
|
||||||
)
|
)
|
||||||
|
if(NOT USE_LIBNX)
|
||||||
|
set(nativeExtra ${nativeExtra}
|
||||||
|
SDL/SDLVulkanGraphicsContext.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
|
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm SDL/SDLCocoaMetalLayer.h SDL/SDLCocoaMetalLayer.mm)
|
set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm SDL/SDLCocoaMetalLayer.h SDL/SDLCocoaMetalLayer.mm)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
cInterfaceBase* HostGL_CreateGLInterface(){
|
cInterfaceBase* HostGL_CreateGLInterface(){
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
return new cInterfaceEGLAndroid;
|
return new cInterfaceEGLAndroid;
|
||||||
#elif if PPSSPP_PLATFORM(SWITCH)
|
#elif PPSSPP_PLATFORM(SWITCH)
|
||||||
return new cInterfaceEGLSwitch;
|
return new cInterfaceEGLSwitch;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
return new cInterfaceAGL;
|
return new cInterfaceAGL;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "Common/Log.h"
|
#include "Common/Log.h"
|
||||||
#include "Common/System/System.h"
|
#include "Common/System/System.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#if !PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(SWITCH)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -224,11 +224,17 @@ PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
|
||||||
|
|
||||||
using namespace PPSSPP_VK;
|
using namespace PPSSPP_VK;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if PPSSPP_PLATFORM(SWITCH)
|
||||||
static HINSTANCE vulkanLibrary;
|
typedef void *VulkanLibraryHandle;
|
||||||
|
static VulkanLibraryHandle vulkanLibrary;
|
||||||
|
#define dlsym(x, y) nullptr
|
||||||
|
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||||
|
typedef HINSTANCE VulkanLibraryHandle;
|
||||||
|
static VulkanLibraryHandle vulkanLibrary;
|
||||||
#define dlsym(x, y) GetProcAddress(x, y)
|
#define dlsym(x, y) GetProcAddress(x, y)
|
||||||
#else
|
#else
|
||||||
static void *vulkanLibrary;
|
typedef void *VulkanLibraryHandle;
|
||||||
|
static VulkanLibraryHandle vulkanLibrary;
|
||||||
#endif
|
#endif
|
||||||
const char *VulkanResultToString(VkResult res);
|
const char *VulkanResultToString(VkResult res);
|
||||||
|
|
||||||
|
@ -261,6 +267,38 @@ static const char *so_names[] = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static VulkanLibraryHandle VulkanLoadLibrary(const char *logname) {
|
||||||
|
#if PPSSPP_PLATFORM(SWITCH)
|
||||||
|
// Always unavailable, for now.
|
||||||
|
return nullptr;
|
||||||
|
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||||
|
return LoadLibrary(L"vulkan-1.dll");
|
||||||
|
#else
|
||||||
|
void *lib = nullptr;
|
||||||
|
for (int i = 0; i < ARRAY_SIZE(so_names); i++) {
|
||||||
|
lib = dlopen(so_names[i], RTLD_NOW | RTLD_LOCAL);
|
||||||
|
if (lib) {
|
||||||
|
INFO_LOG(G3D, "%s: Library loaded ('%s')", logname, so_names[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lib;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void VulkanFreeLibrary(VulkanLibraryHandle &h) {
|
||||||
|
if (h) {
|
||||||
|
#if PPSSPP_PLATFORM(SWITCH)
|
||||||
|
// Can't load, and can't free.
|
||||||
|
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||||
|
FreeLibrary(h);
|
||||||
|
#else
|
||||||
|
dlclose(h);
|
||||||
|
#endif
|
||||||
|
h = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VulkanSetAvailable(bool available) {
|
void VulkanSetAvailable(bool available) {
|
||||||
g_vulkanAvailabilityChecked = true;
|
g_vulkanAvailabilityChecked = true;
|
||||||
g_vulkanMayBeAvailable = available;
|
g_vulkanMayBeAvailable = available;
|
||||||
|
@ -282,19 +320,7 @@ bool VulkanMayBeAvailable() {
|
||||||
}
|
}
|
||||||
INFO_LOG(G3D, "VulkanMayBeAvailable: Device allowed ('%s')", name.c_str());
|
INFO_LOG(G3D, "VulkanMayBeAvailable: Device allowed ('%s')", name.c_str());
|
||||||
|
|
||||||
#ifndef _WIN32
|
VulkanLibraryHandle lib = VulkanLoadLibrary("VulkanMayBeAvailable");
|
||||||
void *lib = nullptr;
|
|
||||||
for (int i = 0; i < ARRAY_SIZE(so_names); i++) {
|
|
||||||
lib = dlopen(so_names[i], RTLD_NOW | RTLD_LOCAL);
|
|
||||||
if (lib) {
|
|
||||||
INFO_LOG(G3D, "VulkanMayBeAvailable: Library loaded ('%s')", so_names[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// LoadLibrary etc
|
|
||||||
HINSTANCE lib = LoadLibrary(L"vulkan-1.dll");
|
|
||||||
#endif
|
|
||||||
if (!lib) {
|
if (!lib) {
|
||||||
INFO_LOG(G3D, "Vulkan loader: Library not available");
|
INFO_LOG(G3D, "Vulkan loader: Library not available");
|
||||||
g_vulkanAvailabilityChecked = true;
|
g_vulkanAvailabilityChecked = true;
|
||||||
|
@ -452,11 +478,7 @@ bail:
|
||||||
localDestroyInstance(instance, nullptr);
|
localDestroyInstance(instance, nullptr);
|
||||||
}
|
}
|
||||||
if (lib) {
|
if (lib) {
|
||||||
#ifndef _WIN32
|
VulkanFreeLibrary(lib);
|
||||||
dlclose(lib);
|
|
||||||
#else
|
|
||||||
FreeLibrary(lib);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
ERROR_LOG(G3D, "Vulkan with working device not detected.");
|
ERROR_LOG(G3D, "Vulkan with working device not detected.");
|
||||||
}
|
}
|
||||||
|
@ -465,18 +487,7 @@ bail:
|
||||||
|
|
||||||
bool VulkanLoad() {
|
bool VulkanLoad() {
|
||||||
if (!vulkanLibrary) {
|
if (!vulkanLibrary) {
|
||||||
#ifndef _WIN32
|
vulkanLibrary = VulkanLoadLibrary("VulkanLoad");
|
||||||
for (int i = 0; i < ARRAY_SIZE(so_names); i++) {
|
|
||||||
vulkanLibrary = dlopen(so_names[i], RTLD_NOW | RTLD_LOCAL);
|
|
||||||
if (vulkanLibrary) {
|
|
||||||
INFO_LOG(G3D, "VulkanLoad: Found library '%s'", so_names[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// LoadLibrary etc
|
|
||||||
vulkanLibrary = LoadLibrary(L"vulkan-1.dll");
|
|
||||||
#endif
|
|
||||||
if (!vulkanLibrary) {
|
if (!vulkanLibrary) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -495,12 +506,7 @@ bool VulkanLoad() {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ERROR_LOG(G3D, "VulkanLoad: Failed to load Vulkan base functions.");
|
ERROR_LOG(G3D, "VulkanLoad: Failed to load Vulkan base functions.");
|
||||||
#ifndef _WIN32
|
VulkanFreeLibrary(vulkanLibrary);
|
||||||
dlclose(vulkanLibrary);
|
|
||||||
#else
|
|
||||||
FreeLibrary(vulkanLibrary);
|
|
||||||
#endif
|
|
||||||
vulkanLibrary = nullptr;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -706,12 +712,5 @@ void VulkanLoadDeviceFunctions(VkDevice device, const VulkanExtensions &enabledE
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFree() {
|
void VulkanFree() {
|
||||||
if (vulkanLibrary) {
|
VulkanFreeLibrary(vulkanLibrary);
|
||||||
#ifdef _WIN32
|
|
||||||
FreeLibrary(vulkanLibrary);
|
|
||||||
#else
|
|
||||||
dlclose(vulkanLibrary);
|
|
||||||
#endif
|
|
||||||
vulkanLibrary = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2211,7 +2211,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
|
||||||
u64 now = (u64)(time_now_d() * 1000000.0);
|
u64 now = (u64)(time_now_d() * 1000000.0);
|
||||||
if (coreState == CORE_POWERDOWN)
|
if (coreState == CORE_POWERDOWN)
|
||||||
return iResult;
|
return iResult;
|
||||||
if (now - startTime > (getSockError((int)metasocket) == EINPROGRESS ? adhocDefaultTimeout*2LL: adhocDefaultTimeout))
|
if (now - startTime > (u64)(getSockError((int)metasocket) == EINPROGRESS ? adhocDefaultTimeout*2LL: adhocDefaultTimeout))
|
||||||
break;
|
break;
|
||||||
sleep_ms(10);
|
sleep_ms(10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,7 @@ bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) {
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
#if !PPSSPP_PLATFORM(SWITCH)
|
||||||
case GPUCORE_VULKAN:
|
case GPUCORE_VULKAN:
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
ERROR_LOG(G3D, "Unable to init Vulkan GPU backend, no context");
|
ERROR_LOG(G3D, "Unable to init Vulkan GPU backend, no context");
|
||||||
|
@ -102,6 +103,7 @@ bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) {
|
||||||
}
|
}
|
||||||
SetGPU(new GPU_Vulkan(ctx, draw));
|
SetGPU(new GPU_Vulkan(ctx, draw));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return gpu != NULL;
|
return gpu != NULL;
|
||||||
|
|
|
@ -741,6 +741,7 @@ int main(int argc, char *argv[]) {
|
||||||
printf("GL init error '%s'\n", error_message.c_str());
|
printf("GL init error '%s'\n", error_message.c_str());
|
||||||
}
|
}
|
||||||
graphicsContext = ctx;
|
graphicsContext = ctx;
|
||||||
|
#if !PPSSPP_PLATFORM(SWITCH)
|
||||||
} else if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
|
} else if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
|
||||||
SDLVulkanGraphicsContext *ctx = new SDLVulkanGraphicsContext();
|
SDLVulkanGraphicsContext *ctx = new SDLVulkanGraphicsContext();
|
||||||
if (!ctx->Init(window, x, y, mode, &error_message)) {
|
if (!ctx->Init(window, x, y, mode, &error_message)) {
|
||||||
|
@ -754,6 +755,7 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
graphicsContext = ctx;
|
graphicsContext = ctx;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useEmuThread = g_Config.iGPUBackend == (int)GPUBackend::OPENGL;
|
bool useEmuThread = g_Config.iGPUBackend == (int)GPUBackend::OPENGL;
|
||||||
|
|
|
@ -1496,7 +1496,7 @@ void EmuScreen::renderUI() {
|
||||||
DrawFrameTimes(ctx, ctx->GetLayoutBounds());
|
DrawFrameTimes(ctx, ctx->GetLayoutBounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !PPSSPP_PLATFORM(UWP)
|
#if !PPSSPP_PLATFORM(UWP) && !PPSSPP_PLATFORM(SWITCH)
|
||||||
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN && g_Config.bShowAllocatorDebug) {
|
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN && g_Config.bShowAllocatorDebug) {
|
||||||
DrawAllocatorVis(ctx, gpu);
|
DrawAllocatorVis(ctx, gpu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ LibretroGraphicsContext *LibretroGraphicsContext::CreateGraphicsContext() {
|
||||||
delete ctx;
|
delete ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_LIBNX
|
||||||
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_VULKAN) {
|
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_VULKAN) {
|
||||||
ctx = new LibretroVulkanContext();
|
ctx = new LibretroVulkanContext();
|
||||||
|
|
||||||
|
@ -117,6 +118,7 @@ LibretroGraphicsContext *LibretroGraphicsContext::CreateGraphicsContext() {
|
||||||
}
|
}
|
||||||
delete ctx;
|
delete ctx;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_DIRECT3D) {
|
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_DIRECT3D) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue