mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-29 11:06:07 +00:00
added vulkan extension initialize
This commit is contained in:
parent
be4c88a338
commit
f6388c367e
|
@ -53,7 +53,7 @@ add_executable(shadps4
|
|||
src/Core/PS4/HLE/Kernel/event_queues.h
|
||||
src/Core/PS4/HLE/Kernel/cpu_management.cpp
|
||||
src/Core/PS4/HLE/Kernel/cpu_management.h
|
||||
"src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/Core/PS4/HLE/Graphics/graphics_ctx.h")
|
||||
"src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/Core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h")
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY} vulkan-1 spirv-tools-opt spirv-tools)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "emulator.h"
|
||||
|
||||
#include "Core/PS4/HLE/Graphics/video_out.h"
|
||||
#include <vulkan_util.h>
|
||||
|
||||
namespace Emulator {
|
||||
|
||||
|
@ -47,6 +48,7 @@ void emuRun() {
|
|||
{
|
||||
// init window and wait until init finishes
|
||||
CreateSdlWindow(g_window_ctx);
|
||||
Graphics::Vulkan::vulkanCreate(g_window_ctx);
|
||||
g_window_ctx->m_is_graphic_initialized = true;
|
||||
g_window_ctx->m_graphic_initialized_cond.SignalCondVar();
|
||||
}
|
||||
|
|
54
src/vulkan_util.cpp
Normal file
54
src/vulkan_util.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "vulkan_util.h"
|
||||
#include <Util/log.h>
|
||||
#include <debug.h>
|
||||
#include <SDL_vulkan.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
constexpr bool log_file_vulkanutil = true; // disable it to disable logging
|
||||
|
||||
void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) {
|
||||
VulkanExt ext;
|
||||
vulkanGetExtensions(&ext);
|
||||
|
||||
VkApplicationInfo app_info{};
|
||||
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
app_info.pNext = nullptr;
|
||||
app_info.pApplicationName = "shadps4";
|
||||
app_info.applicationVersion = 1;
|
||||
app_info.pEngineName = "shadps4";
|
||||
app_info.engineVersion = 1;
|
||||
app_info.apiVersion = VK_API_VERSION_1_2;
|
||||
}
|
||||
|
||||
void Graphics::Vulkan::vulkanGetExtensions(VulkanExt* ext) {
|
||||
u32 required_extensions_count = 0;
|
||||
u32 available_extensions_count = 0;
|
||||
u32 available_layers_count = 0;
|
||||
auto result = SDL_Vulkan_GetInstanceExtensions(&required_extensions_count, nullptr);
|
||||
|
||||
ext->required_extensions = std::vector<const char*>(required_extensions_count);
|
||||
|
||||
result = SDL_Vulkan_GetInstanceExtensions(&required_extensions_count, ext->required_extensions.data());
|
||||
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &available_extensions_count, nullptr);
|
||||
|
||||
ext->available_extensions = std::vector<VkExtensionProperties>(available_extensions_count);
|
||||
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &available_extensions_count, ext->available_extensions.data());
|
||||
|
||||
vkEnumerateInstanceLayerProperties(&available_layers_count, nullptr);
|
||||
ext->available_layers = std::vector<VkLayerProperties>(available_layers_count);
|
||||
vkEnumerateInstanceLayerProperties(&available_layers_count, ext->available_layers.data());
|
||||
|
||||
for (const char* ext : ext->required_extensions) {
|
||||
LOG_INFO_IF(log_file_vulkanutil, "Vulkan required extension = {}\n", ext);
|
||||
}
|
||||
|
||||
for (const auto& ext : ext->available_extensions) {
|
||||
LOG_INFO_IF(log_file_vulkanutil, "Vulkan available extension: {}, version = {}\n", ext.extensionName, ext.specVersion);
|
||||
}
|
||||
|
||||
for (const auto& l : ext->available_layers) {
|
||||
LOG_INFO_IF(log_file_vulkanutil, "Vulkan available layer: {}, specVersion = {}, implVersion = {}, {}\n", l.layerName, l.specVersion,l.implementationVersion,l.description);
|
||||
}
|
||||
}
|
21
src/vulkan_util.h
Normal file
21
src/vulkan_util.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
#include "emulator.h"
|
||||
#include <SDL.h>
|
||||
#include <vector>
|
||||
#include <src/video/khronos/vulkan/vulkan_core.h>
|
||||
|
||||
namespace Graphics::Vulkan {
|
||||
|
||||
struct VulkanExt {
|
||||
bool enable_validation_layers = false;
|
||||
|
||||
std::vector<const char*> required_extensions;
|
||||
std::vector<VkExtensionProperties> available_extensions;
|
||||
std::vector<const char*> required_layers;
|
||||
std::vector<VkLayerProperties> available_layers;
|
||||
};
|
||||
|
||||
void vulkanCreate(Emulator::WindowCtx *ctx);
|
||||
void vulkanGetExtensions(VulkanExt* ext);
|
||||
|
||||
};
|
Loading…
Reference in a new issue