From ef6da6bddb6ff37d3eaa682e67a4e7d713ac325b Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Sun, 17 Sep 2023 23:38:16 +0300 Subject: [PATCH] more vulkan init progress --- src/Core/PS4/HLE/Graphics/graphics_ctx.h | 2 ++ src/emulator.h | 1 + src/vulkan_util.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/Core/PS4/HLE/Graphics/graphics_ctx.h b/src/Core/PS4/HLE/Graphics/graphics_ctx.h index 782b66f3..330fad57 100644 --- a/src/Core/PS4/HLE/Graphics/graphics_ctx.h +++ b/src/Core/PS4/HLE/Graphics/graphics_ctx.h @@ -1,9 +1,11 @@ #pragma once #include +#include namespace HLE::Libs::Graphics { struct GraphicCtx { u32 screen_width = 0; u32 screen_height = 0; + VkInstance m_instance = nullptr; }; } // namespace HLE::Libs::Graphics \ No newline at end of file diff --git a/src/emulator.h b/src/emulator.h index 975b5330..143eb18f 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -11,6 +11,7 @@ struct WindowCtx { Lib::ConditionVariable m_graphic_initialized_cond; SDL_Window* m_window = nullptr; bool is_window_hidden = true; + VkSurfaceKHR m_surface = nullptr; }; struct EmuPrivate { diff --git a/src/vulkan_util.cpp b/src/vulkan_util.cpp index 677f61b4..28cb185f 100644 --- a/src/vulkan_util.cpp +++ b/src/vulkan_util.cpp @@ -18,6 +18,30 @@ void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) { app_info.pEngineName = "shadps4"; app_info.engineVersion = 1; app_info.apiVersion = VK_API_VERSION_1_2; + + VkInstanceCreateInfo inst_info{}; + inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + inst_info.pNext = nullptr; + inst_info.flags = 0; + inst_info.pApplicationInfo = &app_info; + inst_info.enabledExtensionCount = ext.required_extensions.size(); + inst_info.ppEnabledExtensionNames = ext.required_extensions.data(); + inst_info.enabledLayerCount = 0; + inst_info.ppEnabledLayerNames = nullptr; + + VkResult result = vkCreateInstance(&inst_info, nullptr, &ctx->m_graphic_ctx.m_instance); + if (result == VK_ERROR_INCOMPATIBLE_DRIVER) { + LOG_CRITICAL_IF(log_file_vulkanutil, "Can't find an compatiblie vulkan driver\n"); + std::exit(0); + } else if (result != VK_SUCCESS) { + LOG_CRITICAL_IF(log_file_vulkanutil, "Can't create an vulkan instance\n"); + std::exit(0); + } + + if (SDL_Vulkan_CreateSurface(ctx->m_window, ctx->m_graphic_ctx.m_instance, &ctx->m_surface) == SDL_FALSE) { + LOG_CRITICAL_IF(log_file_vulkanutil, "Can't create an vulkan surface\n"); + std::exit(0); + } } void Graphics::Vulkan::vulkanGetExtensions(VulkanExt* ext) {