mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-24 13:44:58 +00:00
feat: Refactor VulkanDeviceService initialization and add CreateSurface method
This commit is contained in:
@@ -14,9 +14,8 @@ VulkanDeviceService::~VulkanDeviceService() {
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanDeviceService::Initialize(SDL_Window* window,
|
||||
const std::vector<const char*>& deviceExtensions,
|
||||
bool enableValidationLayers) {
|
||||
void VulkanDeviceService::Initialize(const std::vector<const char*>& deviceExtensions,
|
||||
bool enableValidationLayers) {
|
||||
logging::TraceGuard trace;
|
||||
|
||||
deviceExtensions_ = deviceExtensions;
|
||||
@@ -32,10 +31,19 @@ void VulkanDeviceService::Initialize(SDL_Window* window,
|
||||
std::vector<const char*> requiredExtensions(extensions, extensions + extensionCount);
|
||||
|
||||
CreateInstance(requiredExtensions);
|
||||
CreateSurface(window);
|
||||
PickPhysicalDevice();
|
||||
}
|
||||
|
||||
void VulkanDeviceService::CreateSurface(SDL_Window* window) {
|
||||
logging::TraceGuard trace;
|
||||
|
||||
if (!window) {
|
||||
throw std::invalid_argument("Window cannot be null");
|
||||
}
|
||||
|
||||
CreateSurfaceInternal(window);
|
||||
}
|
||||
|
||||
void VulkanDeviceService::CreateInstance(const std::vector<const char*>& requiredExtensions) {
|
||||
logging::TraceGuard trace;
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ public:
|
||||
~VulkanDeviceService() override;
|
||||
|
||||
// IVulkanDeviceService interface
|
||||
void Initialize(SDL_Window* window,
|
||||
const std::vector<const char*>& deviceExtensions,
|
||||
bool enableValidationLayers) override;
|
||||
void Initialize(const std::vector<const char*>& deviceExtensions,
|
||||
bool enableValidationLayers = false) override;
|
||||
void CreateSurface(SDL_Window* window) override;
|
||||
void CreateLogicalDevice() override;
|
||||
void Shutdown() noexcept override;
|
||||
void WaitIdle() override;
|
||||
|
||||
@@ -35,15 +35,23 @@ public:
|
||||
/**
|
||||
* @brief Initialize Vulkan instance and select physical device.
|
||||
*
|
||||
* @param window SDL window for surface creation
|
||||
* @param deviceExtensions Required device extensions
|
||||
* @param enableValidationLayers Whether to enable validation layers
|
||||
* @throws std::runtime_error if initialization fails
|
||||
*/
|
||||
virtual void Initialize(SDL_Window* window,
|
||||
const std::vector<const char*>& deviceExtensions,
|
||||
virtual void Initialize(const std::vector<const char*>& deviceExtensions,
|
||||
bool enableValidationLayers = false) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create Vulkan surface for the given window.
|
||||
*
|
||||
* Must be called after Initialize() and after window is created.
|
||||
*
|
||||
* @param window SDL window for surface creation
|
||||
* @throws std::runtime_error if surface creation fails
|
||||
*/
|
||||
virtual void CreateSurface(SDL_Window* window) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create the logical device and retrieve queues.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user