From c2f7587a1fab01c733acdca35cc36badd8bde378 Mon Sep 17 00:00:00 2001 From: K1ngst0m Date: Mon, 20 Nov 2023 23:57:00 +0800 Subject: [PATCH] code refine --- engine/api/vulkan/swapChain.cpp | 22 +++------------------- engine/renderGraph/renderGraph.cpp | 10 ++++------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/engine/api/vulkan/swapChain.cpp b/engine/api/vulkan/swapChain.cpp index 87578326..68be6656 100644 --- a/engine/api/vulkan/swapChain.cpp +++ b/engine/api/vulkan/swapChain.cpp @@ -81,9 +81,9 @@ Result SwapChain::acquireNextImage(Semaphore* pSemaphore, Fence* pFence) { APH_ASSERT(pSemaphore); VkResult res = VK_SUCCESS; - res = - m_pDevice->getDeviceTable()->vkAcquireNextImageKHR(m_pDevice->getHandle(), getHandle(), UINT64_MAX, pSemaphore->getHandle(), - pFence ? pFence->getHandle() : VK_NULL_HANDLE, &m_imageIdx); + res = m_pDevice->getDeviceTable()->vkAcquireNextImageKHR( + m_pDevice->getHandle(), getHandle(), UINT64_MAX, pSemaphore->getHandle(), + pFence ? pFence->getHandle() : VK_NULL_HANDLE, &m_imageIdx); if(res == VK_ERROR_OUT_OF_DATE_KHR) { @@ -230,22 +230,6 @@ void SwapChain::reCreate() }; auto pImage = m_imagePools.allocate(m_pDevice, imageCreateInfo, handle); - - { - // auto queue = m_pDevice->getQueue(QueueType::Graphics); - // auto* pPool = m_pDevice->acquireCommandPool({.queue = queue, .transient = true}); - // vk::CommandBuffer* cmd = nullptr; - // APH_CHECK_RESULT(pPool->allocate(1, &cmd)); - // _VR(cmd->begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)); - // cmd->transitionImageLayout(pImage, ResourceState::RESOURCE_STATE_PRESENT); - // _VR(cmd->end()); - // vk::QueueSubmitInfo submitInfo{.commandBuffers = {cmd}}; - // APH_CHECK_RESULT(queue->submit({submitInfo})); - // APH_CHECK_RESULT(queue->waitIdle()); - // pPool->free(1, &cmd); - // APH_CHECK_RESULT(m_pDevice->releaseCommandPool(pPool)); - } - m_images.push_back(pImage); } } diff --git a/engine/renderGraph/renderGraph.cpp b/engine/renderGraph/renderGraph.cpp index 804ef7b3..28e999c5 100644 --- a/engine/renderGraph/renderGraph.cpp +++ b/engine/renderGraph/renderGraph.cpp @@ -146,7 +146,7 @@ void RenderGraph::build(vk::SwapChain* pSwapChain) m_buildData.bufferBarriers.clear(); m_buildData.imageBarriers.clear(); m_buildData.frameSubmitInfos.clear(); - for(auto *pass: m_declareData.passes) + for(auto* pass : m_declareData.passes) { m_buildData.passDependencyGraph[pass].clear(); } @@ -478,8 +478,6 @@ void RenderGraph::execute(vk::Fence* pFence) } frameFence->reset(); - vk::Semaphore* presentSem = m_buildData.presentSem; - APH_CHECK_RESULT(queue->submit(m_buildData.frameSubmitInfos, frameFence)); if(m_buildData.pSwapchain) @@ -522,7 +520,7 @@ void RenderGraph::execute(vk::Fence* pFence) pCopyCmd->insertBarrier({ { .pImage = pOutImage, - .currentState = ResourceState::CopySource, + .currentState = ResourceState::Undefined, .newState = ResourceState::RenderTarget, }, { @@ -532,9 +530,9 @@ void RenderGraph::execute(vk::Fence* pFence) }, }); }, - {m_buildData.renderSem}, {presentSem}); + {m_buildData.renderSem}, {m_buildData.presentSem}); - APH_CHECK_RESULT(m_buildData.pSwapchain->presentImage(queue, {presentSem})); + APH_CHECK_RESULT(m_buildData.pSwapchain->presentImage(queue, {m_buildData.presentSem})); } if(!pFence)