mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-29 11:06:07 +00:00
even more vulkan init
This commit is contained in:
parent
ef6da6bddb
commit
78bafe88fa
|
@ -7,5 +7,6 @@ struct GraphicCtx {
|
||||||
u32 screen_width = 0;
|
u32 screen_width = 0;
|
||||||
u32 screen_height = 0;
|
u32 screen_height = 0;
|
||||||
VkInstance m_instance = nullptr;
|
VkInstance m_instance = nullptr;
|
||||||
|
VkPhysicalDevice physical_device = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace HLE::Libs::Graphics
|
} // namespace HLE::Libs::Graphics
|
|
@ -2,8 +2,24 @@
|
||||||
#include <Core/PS4/HLE/Graphics/graphics_ctx.h>
|
#include <Core/PS4/HLE/Graphics/graphics_ctx.h>
|
||||||
#include <Lib/Threads.h>
|
#include <Lib/Threads.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Emulator {
|
namespace Emulator {
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VulkanSurfaceCapabilities {};
|
||||||
|
|
||||||
|
struct VulkanQueues {};
|
||||||
|
|
||||||
struct WindowCtx {
|
struct WindowCtx {
|
||||||
HLE::Libs::Graphics::GraphicCtx m_graphic_ctx;
|
HLE::Libs::Graphics::GraphicCtx m_graphic_ctx;
|
||||||
Lib::Mutex m_mutex;
|
Lib::Mutex m_mutex;
|
||||||
|
@ -12,6 +28,7 @@ struct WindowCtx {
|
||||||
SDL_Window* m_window = nullptr;
|
SDL_Window* m_window = nullptr;
|
||||||
bool is_window_hidden = true;
|
bool is_window_hidden = true;
|
||||||
VkSurfaceKHR m_surface = nullptr;
|
VkSurfaceKHR m_surface = nullptr;
|
||||||
|
VulkanSurfaceCapabilities* m_surface_capabilities = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EmuPrivate {
|
struct EmuPrivate {
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
#include "vulkan_util.h"
|
#include "vulkan_util.h"
|
||||||
|
|
||||||
|
#include <SDL_vulkan.h>
|
||||||
#include <Util/log.h>
|
#include <Util/log.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <SDL_vulkan.h>
|
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
constexpr bool log_file_vulkanutil = true; // disable it to disable logging
|
constexpr bool log_file_vulkanutil = true; // disable it to disable logging
|
||||||
|
|
||||||
void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) {
|
void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) {
|
||||||
VulkanExt ext;
|
Emulator::VulkanExt ext;
|
||||||
vulkanGetExtensions(&ext);
|
vulkanGetInstanceExtensions(&ext);
|
||||||
|
|
||||||
VkApplicationInfo app_info{};
|
VkApplicationInfo app_info{};
|
||||||
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||||
|
@ -42,9 +43,19 @@ void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) {
|
||||||
LOG_CRITICAL_IF(log_file_vulkanutil, "Can't create an vulkan surface\n");
|
LOG_CRITICAL_IF(log_file_vulkanutil, "Can't create an vulkan surface\n");
|
||||||
std::exit(0);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO i am not sure if it's that it is neccesary or if it needs more
|
||||||
|
std::vector<const char*> device_extensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME,
|
||||||
|
VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME, "VK_KHR_maintenance1"};
|
||||||
|
|
||||||
|
ctx->m_surface_capabilities = new Emulator::VulkanSurfaceCapabilities{};
|
||||||
|
Emulator::VulkanQueues queues;
|
||||||
|
|
||||||
|
vulkanFindCompatiblePhysicalDevice(ctx->m_graphic_ctx.m_instance, ctx->m_surface, device_extensions, ctx->m_surface_capabilities,
|
||||||
|
&ctx->m_graphic_ctx.physical_device, &queues);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Vulkan::vulkanGetExtensions(VulkanExt* ext) {
|
void Graphics::Vulkan::vulkanGetInstanceExtensions(Emulator::VulkanExt* ext) {
|
||||||
u32 required_extensions_count = 0;
|
u32 required_extensions_count = 0;
|
||||||
u32 available_extensions_count = 0;
|
u32 available_extensions_count = 0;
|
||||||
u32 available_layers_count = 0;
|
u32 available_layers_count = 0;
|
||||||
|
@ -73,6 +84,24 @@ void Graphics::Vulkan::vulkanGetExtensions(VulkanExt* ext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& l : ext->available_layers) {
|
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);
|
LOG_INFO_IF(log_file_vulkanutil, "Vulkan available layer: {}, specVersion = {}, implVersion = {}, {}\n", l.layerName, l.specVersion,
|
||||||
|
l.implementationVersion, l.description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::Vulkan::vulkanFindCompatiblePhysicalDevice(VkInstance instance, VkSurfaceKHR surface,
|
||||||
|
const std::vector<const char*>& device_extensions,
|
||||||
|
Emulator::VulkanSurfaceCapabilities* out_capabilities, VkPhysicalDevice* out_device,
|
||||||
|
Emulator::VulkanQueues* out_queues) {
|
||||||
|
u32 count_devices = 0;
|
||||||
|
vkEnumeratePhysicalDevices(instance, &count_devices, nullptr);
|
||||||
|
|
||||||
|
std::vector<VkPhysicalDevice> devices(count_devices);
|
||||||
|
vkEnumeratePhysicalDevices(instance, &count_devices, devices.data());
|
||||||
|
|
||||||
|
VkPhysicalDevice found_best_device = nullptr;
|
||||||
|
Emulator::VulkanQueues found_best_queues;
|
||||||
|
|
||||||
|
for (const auto& device : devices) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "emulator.h"
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <vector>
|
|
||||||
#include <src/video/khronos/vulkan/vulkan_core.h>
|
#include <src/video/khronos/vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "emulator.h"
|
||||||
|
|
||||||
namespace Graphics::Vulkan {
|
namespace Graphics::Vulkan {
|
||||||
|
|
||||||
struct VulkanExt {
|
void vulkanCreate(Emulator::WindowCtx* ctx);
|
||||||
bool enable_validation_layers = false;
|
void vulkanGetInstanceExtensions(Emulator::VulkanExt* ext);
|
||||||
|
void vulkanFindCompatiblePhysicalDevice(VkInstance instance, VkSurfaceKHR surface, const std::vector<const char*>& device_extensions,
|
||||||
std::vector<const char*> required_extensions;
|
Emulator::VulkanSurfaceCapabilities* out_capabilities, VkPhysicalDevice* out_device, Emulator::VulkanQueues* out_queues);
|
||||||
std::vector<VkExtensionProperties> available_extensions;
|
}; // namespace Graphics::Vulkan
|
||||||
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