mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Minor cleanup on fence and event handling in two RAII-samples. (#1859)
This commit is contained in:
parent
48b5595082
commit
2d42465f64
@ -58,7 +58,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
int timeouts = -1;
|
||||
do
|
||||
{
|
||||
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
|
||||
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
|
||||
timeouts++;
|
||||
} while ( result == vk::Result::eTimeout );
|
||||
assert( result == vk::Result::eSuccess );
|
||||
@ -75,16 +75,16 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
commandPool.reset();
|
||||
|
||||
commandBuffer.begin( vk::CommandBufferBeginInfo() );
|
||||
commandBuffer.waitEvents( { event }, vk::PipelineStageFlagBits::eHost, vk::PipelineStageFlagBits::eBottomOfPipe, nullptr, nullptr, nullptr );
|
||||
commandBuffer.waitEvents( *event, vk::PipelineStageFlagBits::eHost, vk::PipelineStageFlagBits::eBottomOfPipe, nullptr, nullptr, nullptr );
|
||||
commandBuffer.end();
|
||||
device.resetFences( { fence } );
|
||||
device.resetFences( *fence );
|
||||
|
||||
// Note that stepping through this code in the debugger is a bad idea because the GPU can TDR waiting for the event.
|
||||
// Execute the code from vk::Queue::submit() through vk::Device::setEvent() without breakpoints
|
||||
graphicsQueue.submit( submitInfo, fence );
|
||||
|
||||
// We should timeout waiting for the fence because the GPU should be waiting on the event
|
||||
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
|
||||
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
|
||||
if ( result != vk::Result::eTimeout )
|
||||
{
|
||||
std::cout << "Didn't get expected timeout in vk::Device::waitForFences, exiting\n";
|
||||
@ -96,11 +96,11 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
event.set();
|
||||
do
|
||||
{
|
||||
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
|
||||
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
|
||||
} while ( result == vk::Result::eTimeout );
|
||||
assert( result == vk::Result::eSuccess );
|
||||
|
||||
device.resetFences( { fence } );
|
||||
device.resetFences( *fence );
|
||||
event.reset();
|
||||
|
||||
// reset the command buffer by resetting the complete command pool
|
||||
@ -116,7 +116,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
assert( result == vk::Result::eEventReset );
|
||||
|
||||
// Send the command buffer and loop waiting for the event
|
||||
graphicsQueue.submit( submitInfo, fence );
|
||||
graphicsQueue.submit( submitInfo, *fence );
|
||||
|
||||
int polls = 0;
|
||||
do
|
||||
@ -128,7 +128,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
do
|
||||
{
|
||||
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
|
||||
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
|
||||
} while ( result == vk::Result::eTimeout );
|
||||
assert( result == vk::Result::eSuccess );
|
||||
|
||||
|
@ -1152,9 +1152,9 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *perFrameData[frameIndex].presentCompleteSemaphore );
|
||||
assert( result == vk::Result::eSuccess );
|
||||
|
||||
while ( vk::Result::eTimeout == device.waitForFences( { *perFrameData[frameIndex].fence }, VK_TRUE, vk::su::FenceTimeout ) )
|
||||
while ( vk::Result::eTimeout == device.waitForFences( *perFrameData[frameIndex].fence, VK_TRUE, vk::su::FenceTimeout ) )
|
||||
;
|
||||
device.resetFences( { *perFrameData[frameIndex].fence } );
|
||||
device.resetFences( *perFrameData[frameIndex].fence );
|
||||
|
||||
// reset the command buffer by resetting the complete command pool of this frame
|
||||
perFrameData[frameIndex].commandPool.reset();
|
||||
|
@ -354,14 +354,16 @@ namespace vk
|
||||
void * /*pUserData*/ )
|
||||
{
|
||||
#if !defined( NDEBUG )
|
||||
if ( static_cast<uint32_t>( pCallbackData->messageIdNumber ) == 0x822806fa )
|
||||
switch ( static_cast<uint32_t>( pCallbackData->messageIdNumber ) )
|
||||
{
|
||||
case 0:
|
||||
// Validation Warning: Override layer has override paths set to C:/VulkanSDK/<version>/Bin
|
||||
return vk::False;
|
||||
case 0x822806fa:
|
||||
// Validation Warning: vkCreateInstance(): to enable extension VK_EXT_debug_utils, but this extension is intended to support use by applications when
|
||||
// debugging and it is strongly recommended that it be otherwise avoided.
|
||||
return vk::False;
|
||||
}
|
||||
else if ( static_cast<uint32_t>( pCallbackData->messageIdNumber ) == 0xe8d1a9fe )
|
||||
{
|
||||
case 0xe8d1a9fe:
|
||||
// Validation Performance Warning: Using debug builds of the validation layers *will* adversely affect performance.
|
||||
return vk::False;
|
||||
}
|
||||
@ -824,7 +826,8 @@ namespace vk
|
||||
: ( surfaceCapabilities.supportedCompositeAlpha & vk::CompositeAlphaFlagBitsKHR::eInherit ) ? vk::CompositeAlphaFlagBitsKHR::eInherit
|
||||
: vk::CompositeAlphaFlagBitsKHR::eOpaque;
|
||||
vk::PresentModeKHR presentMode = vk::su::pickPresentMode( physicalDevice.getSurfacePresentModesKHR( surface ) );
|
||||
vk::SwapchainCreateInfoKHR swapChainCreateInfo( {},
|
||||
vk::SwapchainCreateInfoKHR swapChainCreateInfo(
|
||||
{},
|
||||
surface,
|
||||
vk::su::clampSurfaceImageCount( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ),
|
||||
colorFormat,
|
||||
|
Loading…
Reference in New Issue
Block a user