Add better handling for submitting command buffer

This commit is contained in:
2024-01-09 09:41:06 -05:00
parent ac33d53ae8
commit 96f2aea4a6
2 changed files with 17 additions and 5 deletions

View File

@@ -108,10 +108,22 @@ namespace fgl::engine
if ( Device::getInstance().device().resetFences( 1, &inFlightFences[ currentFrame ] ) != vk::Result::eSuccess )
throw std::runtime_error( "failed to reset fences!" );
if ( Device::getInstance().graphicsQueue().submit( 1, &submitInfo, inFlightFences[ currentFrame ] )
!= vk::Result::eSuccess )
if ( auto result =
Device::getInstance().graphicsQueue().submit( 1, &submitInfo, inFlightFences[ currentFrame ] );
result != vk::Result::eSuccess )
{
throw std::runtime_error( "failed to submit draw command buffer!" );
switch ( result )
{
case vk::Result::eErrorOutOfDateKHR:
return vk::Result::eErrorOutOfDateKHR;
case vk::Result::eSuboptimalKHR:
return vk::Result::eSuboptimalKHR;
case vk::Result::eErrorDeviceLost:
throw std::runtime_error( "Device lost!" );
default:
throw std::runtime_error(
"failed to submit draw command buffer!: ID" + std::to_string( static_cast< int >( result ) ) );
}
}
vk::PresentInfoKHR presentInfo = {};

View File

@@ -106,8 +106,8 @@ namespace fgl::engine
vk::Format findDepthFormat();
vk::Result acquireNextImage( uint32_t* imageIndex );
vk::Result submitCommandBuffers( const vk::CommandBuffer* buffers, uint32_t* imageIndex );
[[nodiscard]] vk::Result acquireNextImage( uint32_t* imageIndex );
[[nodiscard]] vk::Result submitCommandBuffers( const vk::CommandBuffer* buffers, uint32_t* imageIndex );
};
} // namespace fgl::engine