Skip to content

Commit c44e935

Browse files
committed
Try to make it work with Vulkan.
1 parent e2b5312 commit c44e935

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/frame/vulkan/sdl_vulkan_none.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void SDLVulkanNone::SetUniqueDevice(std::unique_ptr<DeviceInterface>&& device)
7171
dynamic_cast<vulkan::Device*>(device_.get());
7272
if (!vulkan_device)
7373
{
74-
std::runtime_error("Device is not a vulkan device.");
74+
throw std::runtime_error("Device is not a vulkan device.");
7575
}
7676

7777
vulkan_device->Init(GetInstanceCreateInfo());

src/frame/vulkan/sdl_vulkan_window.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ void SDLVulkanWindow::SetUniqueDevice(std::unique_ptr<DeviceInterface>&& device)
9999
throw std::runtime_error("Device is not a vulkan device.");
100100
}
101101
vulkan_device->Init(GetInstanceCreateInfo());
102+
VkSurfaceKHR c_surface;
103+
vk::raii::Instance instance = vulkan_device->MoveInstance();
104+
if (!SDL_Vulkan_CreateSurface(sdl_window_, *instance, &c_surface))
105+
{
106+
throw std::runtime_error(
107+
fmt::format("Couldn't create surface: {}", SDL_GetError()));
108+
}
109+
surface_khr_.emplace(instance, c_surface);
110+
vulkan_device->EmplaceInstance(std::move(instance));
102111
}
103112

104113
void SDLVulkanWindow::Run(std::function<void()> lambda /* = []{}*/)

src/frame/vulkan/sdl_vulkan_window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class SDLVulkanWindow : public VulkanWindowInterface
9999
HWND hwnd_ = nullptr;
100100
#endif
101101
frame::Logger& logger_ = frame::Logger::GetInstance();
102-
std::optional<vk::raii::SurfaceKHR> vk_surface_KHR_;
102+
std::optional<vk::raii::SurfaceKHR> surface_khr_;
103103
};
104104

105105
} // namespace frame::vulkan.

0 commit comments

Comments
 (0)