Commit 308a750e authored by Florian Oetke's avatar Florian Oetke
Browse files

fixed move operators

parent 3ba1cf6d
Pipeline #2686 passed with stage
in 9 minutes and 45 seconds
......@@ -11,7 +11,6 @@ namespace mirrage::graphic {
class Swapchain : public Window_modification_handler {
public:
Swapchain() = default;
Swapchain(const vk::Device& dev, vk::PhysicalDevice, Window&, vk::SwapchainCreateInfoKHR);
Swapchain(Swapchain&&) = default;
Swapchain& operator=(Swapchain&&) = default;
......@@ -32,9 +31,9 @@ namespace mirrage::graphic {
auto image_format() const noexcept { return _image_format; }
private:
const vk::Device& _device;
const vk::Device* _device;
vk::PhysicalDevice _gpu;
Window& _window;
Window* _window;
vk::SwapchainCreateInfoKHR _info;
vk::UniqueSwapchainKHR _swapchain;
std::vector<vk::Image> _images;
......
......@@ -102,7 +102,7 @@ namespace mirrage::graphic {
private:
friend class Device;
const vk::Device& _device;
const vk::Device* _device;
vk::UniqueCommandPool _pool;
Command_buffer_pool(const vk::Device& device, vk::UniqueCommandPool pool);
......
......@@ -10,9 +10,9 @@ namespace mirrage::graphic {
Window& window,
vk::SwapchainCreateInfoKHR info)
: Window_modification_handler(window)
, _device(dev)
, _device(&dev)
, _gpu(gpu)
, _window(window)
, _window(&window)
, _info(info)
, _swapchain(dev.createSwapchainKHRUnique(info))
, _images(dev.getSwapchainImagesKHR(*_swapchain))
......@@ -37,13 +37,14 @@ namespace mirrage::graphic {
ivc.setViewType(vk::ImageViewType::e2D);
ivc.setFormat(_info.imageFormat);
ivc.setSubresourceRange(vk::ImageSubresourceRange{vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1});
_image_views.emplace_back(_device.createImageViewUnique(ivc));
_image_views.emplace_back(_device->createImageViewUnique(ivc));
}
}
auto Swapchain::acquireNextImage(vk::Semaphore s, vk::Fence f) const -> std::size_t
{
return _device.acquireNextImageKHR(*_swapchain, std::numeric_limits<std::uint64_t>::max(), s, f).value;
return _device->acquireNextImageKHR(*_swapchain, std::numeric_limits<std::uint64_t>::max(), s, f)
.value;
}
bool Swapchain::present(vk::Queue& q, std::size_t img_index, vk::Semaphore s)
......@@ -53,25 +54,25 @@ namespace mirrage::graphic {
auto info = vk::PresentInfoKHR{s ? 1u : 0u, &s, 1, &*_swapchain, &img_index_vk};
auto result = vkQueuePresentKHR(VkQueue(q), reinterpret_cast<VkPresentInfoKHR*>(&info));
_window.on_present();
_window->on_present();
if(result != VK_SUCCESS || _recreate_pending) {
_recreate_pending = false;
_device.waitIdle();
_device->waitIdle();
auto capabilities = _gpu.getSurfaceCapabilitiesKHR(_window.surface());
auto capabilities = _gpu.getSurfaceCapabilitiesKHR(_window->surface());
LOG(plog::debug) << "Extends: " << capabilities.currentExtent.width << ", "
<< capabilities.currentExtent.height;
_image_width = _window.width();
_image_height = _window.height();
_image_width = _window->width();
_image_height = _window->height();
_info.oldSwapchain = *_swapchain;
_info.imageExtent.width = gsl::narrow<std::uint32_t>(_image_width);
_info.imageExtent.height = gsl::narrow<std::uint32_t>(_image_height);
_swapchain = _device.createSwapchainKHRUnique(_info);
_images = _device.getSwapchainImagesKHR(*_swapchain);
_swapchain = _device->createSwapchainKHRUnique(_info);
_images = _device->getSwapchainImagesKHR(*_swapchain);
_create_image_views();
......
......@@ -9,19 +9,23 @@
namespace mirrage::graphic {
Command_buffer_pool::Command_buffer_pool(const vk::Device& device, vk::UniqueCommandPool pool)
: _device(device), _pool(std::move(pool))
: _device(&device), _pool(std::move(pool))
{
}
Command_buffer_pool::~Command_buffer_pool() { _device.waitIdle(); }
Command_buffer_pool::~Command_buffer_pool()
{
if(_device)
_device->waitIdle();
}
auto Command_buffer_pool::create_primary(std::int32_t count) -> std::vector<vk::UniqueCommandBuffer>
{
return _device.allocateCommandBuffersUnique(vk::CommandBufferAllocateInfo(
return _device->allocateCommandBuffersUnique(vk::CommandBufferAllocateInfo(
*_pool, vk::CommandBufferLevel::ePrimary, gsl::narrow<std::uint32_t>(count)));
}
auto Command_buffer_pool::create_secondary(std::int32_t count) -> std::vector<vk::UniqueCommandBuffer>
{
return _device.allocateCommandBuffersUnique(vk::CommandBufferAllocateInfo(
return _device->allocateCommandBuffersUnique(vk::CommandBufferAllocateInfo(
*_pool, vk::CommandBufferLevel::eSecondary, gsl::narrow<std::uint32_t>(count)));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment