Skip to content

Commit

Permalink
code refine
Browse files Browse the repository at this point in the history
  • Loading branch information
K1ngst0m committed Nov 20, 2023
1 parent af4fdf8 commit c2f7587
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
22 changes: 3 additions & 19 deletions engine/api/vulkan/swapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
}
Expand Down
10 changes: 4 additions & 6 deletions engine/renderGraph/renderGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -522,7 +520,7 @@ void RenderGraph::execute(vk::Fence* pFence)
pCopyCmd->insertBarrier({
{
.pImage = pOutImage,
.currentState = ResourceState::CopySource,
.currentState = ResourceState::Undefined,
.newState = ResourceState::RenderTarget,
},
{
Expand All @@ -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)
Expand Down

0 comments on commit c2f7587

Please sign in to comment.