Skip to content

Commit

Permalink
Try to make it work with Vulkan.
Browse files Browse the repository at this point in the history
  • Loading branch information
anirul committed Jan 30, 2024
1 parent e2b5312 commit c44e935
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/frame/vulkan/sdl_vulkan_none.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void SDLVulkanNone::SetUniqueDevice(std::unique_ptr<DeviceInterface>&& device)
dynamic_cast<vulkan::Device*>(device_.get());
if (!vulkan_device)
{
std::runtime_error("Device is not a vulkan device.");
throw std::runtime_error("Device is not a vulkan device.");
}

vulkan_device->Init(GetInstanceCreateInfo());
Expand Down
9 changes: 9 additions & 0 deletions src/frame/vulkan/sdl_vulkan_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ void SDLVulkanWindow::SetUniqueDevice(std::unique_ptr<DeviceInterface>&& device)
throw std::runtime_error("Device is not a vulkan device.");
}
vulkan_device->Init(GetInstanceCreateInfo());
VkSurfaceKHR c_surface;
vk::raii::Instance instance = vulkan_device->MoveInstance();
if (!SDL_Vulkan_CreateSurface(sdl_window_, *instance, &c_surface))
{
throw std::runtime_error(
fmt::format("Couldn't create surface: {}", SDL_GetError()));
}
surface_khr_.emplace(instance, c_surface);
vulkan_device->EmplaceInstance(std::move(instance));
}

void SDLVulkanWindow::Run(std::function<void()> lambda /* = []{}*/)
Expand Down
2 changes: 1 addition & 1 deletion src/frame/vulkan/sdl_vulkan_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class SDLVulkanWindow : public VulkanWindowInterface
HWND hwnd_ = nullptr;
#endif
frame::Logger& logger_ = frame::Logger::GetInstance();
std::optional<vk::raii::SurfaceKHR> vk_surface_KHR_;
std::optional<vk::raii::SurfaceKHR> surface_khr_;
};

} // namespace frame::vulkan.

0 comments on commit c44e935

Please sign in to comment.