Skip to content

Commit

Permalink
rendervulkan: address several warnings from GCC's -Wnrvo diagnostic flag
Browse files Browse the repository at this point in the history
Three functions edited to enable complete (n)rvo
  • Loading branch information
sharkautarch committed Feb 8, 2025
1 parent d4ca0b9 commit 674b97f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/rendervulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,8 +1199,13 @@ int32_t CVulkanDevice::findMemoryType( VkMemoryPropertyFlags properties, uint32_
}

std::unique_ptr<CVulkanCmdBuffer> CVulkanDevice::commandBuffer()
{
std::unique_ptr<CVulkanCmdBuffer> cmdBuffer;
{
auto finalizeCmdBuffer = [this](std::unique_ptr<CVulkanCmdBuffer> cmdBuffer, void (*preInitHook)(CVulkanDevice*) = [](CVulkanDevice*) { return; } ) {
preInitHook(this);
cmdBuffer->begin();
return cmdBuffer;
};

if (m_unusedCmdBufs.empty())
{
VkCommandBuffer rawCmdBuffer;
Expand All @@ -1218,16 +1223,14 @@ std::unique_ptr<CVulkanCmdBuffer> CVulkanDevice::commandBuffer()
return nullptr;
}

cmdBuffer = std::make_unique<CVulkanCmdBuffer>(this, rawCmdBuffer, queue(), queueFamily());
return finalizeCmdBuffer(std::make_unique<CVulkanCmdBuffer>(this, rawCmdBuffer, queue(), queueFamily()));
}
else
{
cmdBuffer = std::move(m_unusedCmdBufs.back());
m_unusedCmdBufs.pop_back();
return finalizeCmdBuffer(std::move(m_unusedCmdBufs.back()), [](CVulkanDevice* obj) {
obj->m_unusedCmdBufs.pop_back();
});
}

cmdBuffer->begin();
return cmdBuffer;
}

uint64_t CVulkanDevice::submitInternal( CVulkanCmdBuffer* cmdBuffer )
Expand Down Expand Up @@ -1337,7 +1340,7 @@ int VulkanTimelineSemaphore_t::GetFd() const

std::shared_ptr<VulkanTimelineSemaphore_t> CVulkanDevice::CreateTimelineSemaphore( uint64_t ulStartPoint, bool bShared )
{
std::shared_ptr<VulkanTimelineSemaphore_t> pSemaphore = std::make_unique<VulkanTimelineSemaphore_t>();
auto pSemaphore = std::make_unique<VulkanTimelineSemaphore_t>()
pSemaphore->pDevice = this;

VkSemaphoreCreateInfo createInfo =
Expand Down Expand Up @@ -1368,13 +1371,14 @@ std::shared_ptr<VulkanTimelineSemaphore_t> CVulkanDevice::CreateTimelineSemaphor
return nullptr;
}

return pSemaphore;
return std::shared_ptr<VulkanTimelineSemaphore_t>( std::move(pSemaphore) );
}

std::shared_ptr<VulkanTimelineSemaphore_t> CVulkanDevice::ImportTimelineSemaphore( gamescope::CTimeline *pTimeline )
{
std::shared_ptr<VulkanTimelineSemaphore_t> pSemaphore = std::make_unique<VulkanTimelineSemaphore_t>();
auto pSemaphore = std::make_unique<VulkanTimelineSemaphore_t>()
pSemaphore->pDevice = this;


const VkSemaphoreTypeCreateInfo typeInfo =
{
Expand Down Expand Up @@ -1417,7 +1421,7 @@ std::shared_ptr<VulkanTimelineSemaphore_t> CVulkanDevice::ImportTimelineSemaphor
return nullptr;
}

return pSemaphore;
return std::shared_ptr<VulkanTimelineSemaphore_t>( std::move(pSemaphore) );
}

void CVulkanCmdBuffer::AddDependency( std::shared_ptr<VulkanTimelineSemaphore_t> pTimelineSemaphore, uint64_t ulPoint )
Expand Down

0 comments on commit 674b97f

Please sign in to comment.