mirror of https://github.com/snes9xgit/snes9x.git
Vulkan: Allocate swapchain on context create.
This commit is contained in:
parent
befb0ba768
commit
13824a6ef4
|
@ -11,6 +11,7 @@ static std::unique_ptr<vk::DynamicLoader> dl;
|
||||||
|
|
||||||
Context::Context()
|
Context::Context()
|
||||||
{
|
{
|
||||||
|
swapchain = std::make_unique<Swapchain>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::~Context()
|
Context::~Context()
|
||||||
|
@ -180,7 +181,6 @@ bool Context::init()
|
||||||
init_command_pool();
|
init_command_pool();
|
||||||
init_descriptor_pool();
|
init_descriptor_pool();
|
||||||
|
|
||||||
swapchain = std::make_unique<Swapchain>(*this);
|
|
||||||
wait_idle();
|
wait_idle();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ Swapchain::Swapchain(Context &context_)
|
||||||
command_pool(context.command_pool.get()),
|
command_pool(context.command_pool.get()),
|
||||||
surface(context.surface.get())
|
surface(context.surface.get())
|
||||||
{
|
{
|
||||||
create_render_pass();
|
|
||||||
end_render_pass_function = nullptr;
|
end_render_pass_function = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +151,9 @@ bool Swapchain::uncreate()
|
||||||
|
|
||||||
bool Swapchain::create()
|
bool Swapchain::create()
|
||||||
{
|
{
|
||||||
|
if (!render_pass)
|
||||||
|
create_render_pass();
|
||||||
|
|
||||||
frames.clear();
|
frames.clear();
|
||||||
image_data.clear();
|
image_data.clear();
|
||||||
|
|
||||||
|
|
|
@ -130,15 +130,15 @@ int S9xVulkanDisplayDriver::init()
|
||||||
wl_surface *surface = gdk_wayland_window_get_wl_surface(drawing_area->get_window()->gobj());
|
wl_surface *surface = gdk_wayland_window_get_wl_surface(drawing_area->get_window()->gobj());
|
||||||
wl_display *display = gdk_wayland_display_get_wl_display(drawing_area->get_display()->gobj());
|
wl_display *display = gdk_wayland_display_get_wl_display(drawing_area->get_display()->gobj());
|
||||||
|
|
||||||
if (!wayland_surface->attach(display, surface, get_metrics(*drawing_area)))
|
|
||||||
goto abort;
|
|
||||||
if (!context->init_wayland())
|
|
||||||
goto abort;
|
|
||||||
if (!context->create_wayland_surface(wayland_surface->display, wayland_surface->child))
|
|
||||||
goto abort;
|
|
||||||
context->swapchain->set_desired_size(current_width, current_height);
|
context->swapchain->set_desired_size(current_width, current_height);
|
||||||
if (!context->create_swapchain())
|
if (!wayland_surface->attach(display, surface, get_metrics(*drawing_area)) ||
|
||||||
goto abort;
|
!context->init_wayland() ||
|
||||||
|
!context->create_wayland_surface(wayland_surface->display, wayland_surface->child) ||
|
||||||
|
!context->create_swapchain())
|
||||||
|
{
|
||||||
|
context.reset();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (GDK_IS_X11_WINDOW(drawing_area->get_window()->gobj()))
|
if (GDK_IS_X11_WINDOW(drawing_area->get_window()->gobj()))
|
||||||
|
@ -146,12 +146,13 @@ int S9xVulkanDisplayDriver::init()
|
||||||
display = gdk_x11_display_get_xdisplay(drawing_area->get_display()->gobj());
|
display = gdk_x11_display_get_xdisplay(drawing_area->get_display()->gobj());
|
||||||
xid = gdk_x11_window_get_xid(drawing_area->get_window()->gobj());
|
xid = gdk_x11_window_get_xid(drawing_area->get_window()->gobj());
|
||||||
|
|
||||||
if (!context->init_Xlib())
|
if (!context->init_Xlib() ||
|
||||||
goto abort;
|
!context->create_Xlib_surface(display, xid) ||
|
||||||
if (!context->create_Xlib_surface(display, xid))
|
!context->create_swapchain())
|
||||||
goto abort;
|
{
|
||||||
if (!context->create_swapchain())
|
context.reset();
|
||||||
goto abort;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
device = context->device;
|
device = context->device;
|
||||||
|
@ -179,10 +180,6 @@ int S9xVulkanDisplayDriver::init()
|
||||||
simple_output = std::make_unique<Vulkan::SimpleOutput>(context.get(), vk::Format::eR5G6B5UnormPack16);
|
simple_output = std::make_unique<Vulkan::SimpleOutput>(context.get(), vk::Format::eR5G6B5UnormPack16);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
abort:
|
|
||||||
context.reset();
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void S9xVulkanDisplayDriver::deinit()
|
void S9xVulkanDisplayDriver::deinit()
|
||||||
|
|
|
@ -89,12 +89,13 @@ bool EmuCanvasVulkan::createContext()
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto hwnd = (HWND)winId();
|
auto hwnd = (HWND)winId();
|
||||||
if (!context->init_win32())
|
if (!context->init_win32() ||
|
||||||
goto fail;
|
!context->create_win32_surface(nullptr, hwnd) ||
|
||||||
if (!context->create_win32_surface(nullptr, hwnd))
|
!context->swapchain->create())
|
||||||
goto fail;
|
{
|
||||||
if (!context->swapchain->create())
|
context.reset();
|
||||||
goto fail;
|
return false;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if (platform == "wayland")
|
if (platform == "wayland")
|
||||||
{
|
{
|
||||||
|
@ -104,30 +105,27 @@ bool EmuCanvasVulkan::createContext()
|
||||||
wayland_surface->attach(display, surface, { parent->x() - main_window->x(), parent->y() - main_window->y(), width(), height(), static_cast<int>(devicePixelRatio()) });
|
wayland_surface->attach(display, surface, { parent->x() - main_window->x(), parent->y() - main_window->y(), width(), height(), static_cast<int>(devicePixelRatio()) });
|
||||||
auto [scaled_width, scaled_height] = wayland_surface->get_size();
|
auto [scaled_width, scaled_height] = wayland_surface->get_size();
|
||||||
|
|
||||||
if (!context->init_wayland())
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (!context->create_wayland_surface(display, wayland_surface->child))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
context->swapchain->set_desired_size(scaled_width, scaled_height);
|
context->swapchain->set_desired_size(scaled_width, scaled_height);
|
||||||
if (!context->swapchain->create())
|
if (!context->init_wayland() ||
|
||||||
goto fail;
|
!context->create_wayland_surface(display, wayland_surface->child) ||
|
||||||
|
!context->swapchain->create())
|
||||||
|
{
|
||||||
|
context.reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (platform == "xcb")
|
else if (platform == "xcb")
|
||||||
{
|
{
|
||||||
auto display = (Display *)pni->nativeResourceForWindow("display", window);
|
auto display = (Display *)pni->nativeResourceForWindow("display", window);
|
||||||
auto xid = (Window)winId();
|
auto xid = (Window)winId();
|
||||||
|
|
||||||
if (!context->init_Xlib())
|
if (!context->init_Xlib() ||
|
||||||
goto fail;
|
!context->create_Xlib_surface(display, xid) ||
|
||||||
|
!context->swapchain->create())
|
||||||
if (!context->create_Xlib_surface(display, xid))
|
{
|
||||||
goto fail;
|
context.reset();
|
||||||
|
return false;
|
||||||
context->wait_idle();
|
}
|
||||||
if (!context->swapchain->create())
|
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -142,10 +140,6 @@ bool EmuCanvasVulkan::createContext()
|
||||||
paintEvent(nullptr);
|
paintEvent(nullptr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
|
||||||
context.reset();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuCanvasVulkan::tryLoadShader()
|
void EmuCanvasVulkan::tryLoadShader()
|
||||||
|
|
Loading…
Reference in New Issue