mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-23 08:09:51 +00:00
Vulkan: Prepare for adding a second init path for VulkanContext.
Will eventually be used for libretro.
This commit is contained in:
parent
5847bf3201
commit
7610220b30
@ -84,19 +84,7 @@ const char *PresentModeString(VkPresentModeKHR presentMode) {
|
||||
}
|
||||
|
||||
VulkanContext::VulkanContext() {
|
||||
#if SIMULATE_VULKAN_FAILURE == 1
|
||||
return;
|
||||
#endif
|
||||
if (!VulkanLoad()) {
|
||||
init_error_ = "Failed to load Vulkan driver library";
|
||||
// No DLL?
|
||||
return;
|
||||
}
|
||||
|
||||
// We can get the list of layers and extensions without an instance so we can use this information
|
||||
// to enable the extensions we need that are available.
|
||||
GetInstanceLayerProperties();
|
||||
GetInstanceLayerExtensionList(nullptr, instance_extension_properties_);
|
||||
// Do nothing here.
|
||||
}
|
||||
|
||||
VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
|
||||
@ -105,6 +93,11 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
// We can get the list of layers and extensions without an instance so we can use this information
|
||||
// to enable the extensions we need that are available.
|
||||
GetInstanceLayerProperties();
|
||||
GetInstanceLayerExtensionList(nullptr, instance_extension_properties_);
|
||||
|
||||
if (!IsInstanceExtensionAvailable(VK_KHR_SURFACE_EXTENSION_NAME)) {
|
||||
// Cannot create a Vulkan display without VK_KHR_SURFACE_EXTENSION.
|
||||
init_error_ = "Vulkan not loaded - no surface extension";
|
||||
|
@ -24,14 +24,12 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode,
|
||||
|
||||
Version gitVer(PPSSPP_GIT_VERSION);
|
||||
|
||||
vulkan_ = new VulkanContext();
|
||||
if (vulkan_->InitError().size()) {
|
||||
*error_message = vulkan_->InitError();
|
||||
delete vulkan_;
|
||||
vulkan_ = nullptr;
|
||||
if (!VulkanLoad()) {
|
||||
*error_message = "Failed to load Vulkan driver library";
|
||||
return false;
|
||||
}
|
||||
|
||||
vulkan_ = new VulkanContext();
|
||||
int vulkanFlags = VULKAN_FLAG_PRESENT_MAILBOX;
|
||||
// vulkanFlags |= VULKAN_FLAG_VALIDATE;
|
||||
VulkanContext::CreateInfo info{};
|
||||
|
@ -89,14 +89,14 @@ bool WindowsVulkanContext::Init(HINSTANCE hInst, HWND hWnd, std::string *error_m
|
||||
g_LogOptions.msgBoxOnError = false;
|
||||
|
||||
Version gitVer(PPSSPP_GIT_VERSION);
|
||||
g_Vulkan = new VulkanContext();
|
||||
if (g_Vulkan->InitError().size()) {
|
||||
*error_message = g_Vulkan->InitError();
|
||||
delete g_Vulkan;
|
||||
g_Vulkan = nullptr;
|
||||
|
||||
if (!VulkanLoad()) {
|
||||
*error_message = "Failed to load Vulkan driver library";
|
||||
return false;
|
||||
}
|
||||
// int vulkanFlags = VULKAN_FLAG_PRESENT_FIFO_RELAXED;
|
||||
|
||||
g_Vulkan = new VulkanContext();
|
||||
|
||||
VulkanContext::CreateInfo info{};
|
||||
info.app_name = "PPSSPP";
|
||||
info.app_ver = gitVer.ToInteger();
|
||||
|
@ -92,9 +92,16 @@ bool AndroidVulkanContext::InitAPI() {
|
||||
ILOG("Creating Vulkan context");
|
||||
Version gitVer(PPSSPP_GIT_VERSION);
|
||||
|
||||
if (!VulkanLoad()) {
|
||||
ELOG("Failed to load Vulkan driver library");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!g_Vulkan) {
|
||||
// TODO: Assert if g_Vulkan already exists here?
|
||||
g_Vulkan = new VulkanContext();
|
||||
}
|
||||
|
||||
VulkanContext::CreateInfo info{};
|
||||
info.app_name = "PPSSPP";
|
||||
info.app_ver = gitVer.ToInteger();
|
||||
|
@ -30,14 +30,20 @@ void LibretroVulkanContext::SwapBuffers() {
|
||||
static bool create_device(retro_vulkan_context *context, VkInstance instance, VkPhysicalDevice gpu, VkSurfaceKHR surface, PFN_vkGetInstanceProcAddr get_instance_proc_addr, const char **required_device_extensions, unsigned num_required_device_extensions, const char **required_device_layers, unsigned num_required_device_layers, const VkPhysicalDeviceFeatures *required_features) {
|
||||
init_glslang();
|
||||
|
||||
vk = new VulkanContext;
|
||||
if (!vk->InitError().empty()) {
|
||||
ERROR_LOG(G3D, "%s", vk->InitError().c_str());
|
||||
if (!VulkanLoad()) {
|
||||
// TODO: In the context of RetroArch, someone has already loaded the functions -
|
||||
// we shouldn't need to load them again. On the other hand, it can't really hurt, we're gonna
|
||||
// get the same pointers.
|
||||
ERROR_LOG(G3D, "RetroArch called the Vulkan entry point without Vulkan available???");
|
||||
return false;
|
||||
}
|
||||
|
||||
vk = new VulkanContext();
|
||||
|
||||
vk_libretro_init(instance, gpu, surface, get_instance_proc_addr, required_device_extensions, num_required_device_extensions, required_device_layers, num_required_device_layers, required_features);
|
||||
|
||||
// TODO: Here we'll inject the instance and all of the stuff into the VulkanContext.
|
||||
|
||||
vk->CreateInstance({});
|
||||
|
||||
int physical_device = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user