From cc67b17ae4ed3ca0259a43508774c2cc1e028476 Mon Sep 17 00:00:00 2001 From: Anish Bhobe Date: Tue, 23 Jul 2024 21:15:20 +0200 Subject: [PATCH] Cleanups and checks. --- samples/00_util/frame.cpp | 28 ++++++++++++++++++++++++ samples/00_util/frame.h | 5 +++++ samples/02_box/box.cpp | 3 +-- samples/03_model_render/model_render.cpp | 3 ++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/samples/00_util/frame.cpp b/samples/00_util/frame.cpp index 82258ab..356f156 100644 --- a/samples/00_util/frame.cpp +++ b/samples/00_util/frame.cpp @@ -79,6 +79,34 @@ Frame::~Frame() DEBUG("Destoryed Frame"); } +Frame::Frame(Frame &&other) noexcept + : m_Device(other.m_Device) + , m_Pool(Take(other.m_Pool)) + , m_CommandBuffer(Take(other.m_CommandBuffer)) + , m_FrameAvailableFence(Take(other.m_FrameAvailableFence)) + , m_ImageAcquireSem(Take(other.m_ImageAcquireSem)) + , m_RenderFinishSem(Take(other.m_RenderFinishSem)) + , m_FrameIdx(other.m_FrameIdx) + , m_ImageIdx(other.m_ImageIdx) +{ +} + +Frame & +Frame::operator=(Frame &&other) noexcept +{ + if (this == &other) + return *this; + m_Device = other.m_Device; + m_Pool = Take(other.m_Pool); + m_CommandBuffer = Take(other.m_CommandBuffer); + m_FrameAvailableFence = Take(other.m_FrameAvailableFence); + m_ImageAcquireSem = Take(other.m_ImageAcquireSem); + m_RenderFinishSem = Take(other.m_RenderFinishSem); + m_FrameIdx = other.m_FrameIdx; + m_ImageIdx = other.m_ImageIdx; + return *this; +} + // Frame Manager FrameManager::FrameManager(const Device *device, u32 queueFamilyIndex, u32 framesInFlight) diff --git a/samples/00_util/frame.h b/samples/00_util/frame.h index ec9fafd..5dc3704 100644 --- a/samples/00_util/frame.h +++ b/samples/00_util/frame.h @@ -32,6 +32,11 @@ struct Frame Frame(const Device *device, u32 queueFamilyIndex, u32 frameCount); ~Frame(); + + Frame(Frame &&other) noexcept; + Frame &operator=(Frame &&other) noexcept; + + DISALLOW_COPY_AND_ASSIGN(Frame); }; struct FrameManager diff --git a/samples/02_box/box.cpp b/samples/02_box/box.cpp index 98b86e5..9e2a041 100644 --- a/samples/02_box/box.cpp +++ b/samples/02_box/box.cpp @@ -243,7 +243,6 @@ main(int, char **) vertexStaging.Write(&device, 0, vertices.size() * sizeof vertices[0], vertices.data()); imageStaging.Init(&device, imageFile.GetSize(), "Image Staging"); - INFO("fine {}", imageFile.GetSize()); imageStaging.Write(&device, 0, imageFile.GetSize(), imageFile.m_Data); vk::ImageMemoryBarrier imageReadyToWrite = { @@ -668,7 +667,7 @@ CreatePipeline(const Device *device, const Swapchain *swapchain) .viewMask = 0, .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapchain->m_Format, - .depthAttachmentFormat = vk::Format::eD32Sfloat, + .depthAttachmentFormat = vk::Format::eD24UnormS8Uint, }; vk::GraphicsPipelineCreateInfo pipelineCreateInfo = { diff --git a/samples/03_model_render/model_render.cpp b/samples/03_model_render/model_render.cpp index 051206f..9e4af6c 100644 --- a/samples/03_model_render/model_render.cpp +++ b/samples/03_model_render/model_render.cpp @@ -335,7 +335,8 @@ main(int, char **) gui::Draw(cmd, currentAttachment); cmd.pipelineBarrier(vk::PipelineStageFlagBits::eColorAttachmentOutput, vk::PipelineStageFlagBits::eAllCommands, - {}, 0, nullptr, 0, nullptr, postRenderBarriers.size(), postRenderBarriers.data()); + {}, 0, nullptr, 0, nullptr, Cast(postRenderBarriers.size()), + postRenderBarriers.data()); vk::ImageBlit blitRegion = { .srcSubresource =