Skip to content

Commit 2d42465

Browse files
authored
Minor cleanup on fence and event handling in two RAII-samples. (#1859)
1 parent 48b5595 commit 2d42465

File tree

5 files changed

+39
-36
lines changed

5 files changed

+39
-36
lines changed

RAII_Samples/Events/Events.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int main( int /*argc*/, char ** /*argv*/ )
5858
int timeouts = -1;
5959
do
6060
{
61-
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
61+
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
6262
timeouts++;
6363
} while ( result == vk::Result::eTimeout );
6464
assert( result == vk::Result::eSuccess );
@@ -75,16 +75,16 @@ int main( int /*argc*/, char ** /*argv*/ )
7575
commandPool.reset();
7676

7777
commandBuffer.begin( vk::CommandBufferBeginInfo() );
78-
commandBuffer.waitEvents( { event }, vk::PipelineStageFlagBits::eHost, vk::PipelineStageFlagBits::eBottomOfPipe, nullptr, nullptr, nullptr );
78+
commandBuffer.waitEvents( *event, vk::PipelineStageFlagBits::eHost, vk::PipelineStageFlagBits::eBottomOfPipe, nullptr, nullptr, nullptr );
7979
commandBuffer.end();
80-
device.resetFences( { fence } );
80+
device.resetFences( *fence );
8181

8282
// Note that stepping through this code in the debugger is a bad idea because the GPU can TDR waiting for the event.
8383
// Execute the code from vk::Queue::submit() through vk::Device::setEvent() without breakpoints
8484
graphicsQueue.submit( submitInfo, fence );
8585

8686
// We should timeout waiting for the fence because the GPU should be waiting on the event
87-
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
87+
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
8888
if ( result != vk::Result::eTimeout )
8989
{
9090
std::cout << "Didn't get expected timeout in vk::Device::waitForFences, exiting\n";
@@ -96,11 +96,11 @@ int main( int /*argc*/, char ** /*argv*/ )
9696
event.set();
9797
do
9898
{
99-
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
99+
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
100100
} while ( result == vk::Result::eTimeout );
101101
assert( result == vk::Result::eSuccess );
102102

103-
device.resetFences( { fence } );
103+
device.resetFences( *fence );
104104
event.reset();
105105

106106
// reset the command buffer by resetting the complete command pool
@@ -116,7 +116,7 @@ int main( int /*argc*/, char ** /*argv*/ )
116116
assert( result == vk::Result::eEventReset );
117117

118118
// Send the command buffer and loop waiting for the event
119-
graphicsQueue.submit( submitInfo, fence );
119+
graphicsQueue.submit( submitInfo, *fence );
120120

121121
int polls = 0;
122122
do
@@ -128,7 +128,7 @@ int main( int /*argc*/, char ** /*argv*/ )
128128

129129
do
130130
{
131-
result = device.waitForFences( { fence }, true, vk::su::FenceTimeout );
131+
result = device.waitForFences( *fence, true, vk::su::FenceTimeout );
132132
} while ( result == vk::Result::eTimeout );
133133
assert( result == vk::Result::eSuccess );
134134

RAII_Samples/RayTracing/RayTracing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,9 @@ int main( int /*argc*/, char ** /*argv*/ )
11521152
swapChainData.swapChain.acquireNextImage( vk::su::FenceTimeout, *perFrameData[frameIndex].presentCompleteSemaphore );
11531153
assert( result == vk::Result::eSuccess );
11541154

1155-
while ( vk::Result::eTimeout == device.waitForFences( { *perFrameData[frameIndex].fence }, VK_TRUE, vk::su::FenceTimeout ) )
1155+
while ( vk::Result::eTimeout == device.waitForFences( *perFrameData[frameIndex].fence, VK_TRUE, vk::su::FenceTimeout ) )
11561156
;
1157-
device.resetFences( { *perFrameData[frameIndex].fence } );
1157+
device.resetFences( *perFrameData[frameIndex].fence );
11581158

11591159
// reset the command buffer by resetting the complete command pool of this frame
11601160
perFrameData[frameIndex].commandPool.reset();

samples/utils/utils.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,18 @@ namespace vk
354354
void * /*pUserData*/ )
355355
{
356356
#if !defined( NDEBUG )
357-
if ( static_cast<uint32_t>( pCallbackData->messageIdNumber ) == 0x822806fa )
357+
switch ( static_cast<uint32_t>( pCallbackData->messageIdNumber ) )
358358
{
359-
// Validation Warning: vkCreateInstance(): to enable extension VK_EXT_debug_utils, but this extension is intended to support use by applications when
360-
// debugging and it is strongly recommended that it be otherwise avoided.
361-
return vk::False;
362-
}
363-
else if ( static_cast<uint32_t>( pCallbackData->messageIdNumber ) == 0xe8d1a9fe )
364-
{
365-
// Validation Performance Warning: Using debug builds of the validation layers *will* adversely affect performance.
366-
return vk::False;
359+
case 0:
360+
// Validation Warning: Override layer has override paths set to C:/VulkanSDK/<version>/Bin
361+
return vk::False;
362+
case 0x822806fa:
363+
// Validation Warning: vkCreateInstance(): to enable extension VK_EXT_debug_utils, but this extension is intended to support use by applications when
364+
// debugging and it is strongly recommended that it be otherwise avoided.
365+
return vk::False;
366+
case 0xe8d1a9fe:
367+
// Validation Performance Warning: Using debug builds of the validation layers *will* adversely affect performance.
368+
return vk::False;
367369
}
368370
#endif
369371

@@ -824,21 +826,22 @@ namespace vk
824826
: ( surfaceCapabilities.supportedCompositeAlpha & vk::CompositeAlphaFlagBitsKHR::eInherit ) ? vk::CompositeAlphaFlagBitsKHR::eInherit
825827
: vk::CompositeAlphaFlagBitsKHR::eOpaque;
826828
vk::PresentModeKHR presentMode = vk::su::pickPresentMode( physicalDevice.getSurfacePresentModesKHR( surface ) );
827-
vk::SwapchainCreateInfoKHR swapChainCreateInfo( {},
828-
surface,
829-
vk::su::clampSurfaceImageCount( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ),
830-
colorFormat,
831-
surfaceFormat.colorSpace,
832-
swapchainExtent,
833-
1,
834-
usage,
835-
vk::SharingMode::eExclusive,
836-
{},
837-
preTransform,
838-
compositeAlpha,
839-
presentMode,
840-
true,
841-
oldSwapChain );
829+
vk::SwapchainCreateInfoKHR swapChainCreateInfo(
830+
{},
831+
surface,
832+
vk::su::clampSurfaceImageCount( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ),
833+
colorFormat,
834+
surfaceFormat.colorSpace,
835+
swapchainExtent,
836+
1,
837+
usage,
838+
vk::SharingMode::eExclusive,
839+
{},
840+
preTransform,
841+
compositeAlpha,
842+
presentMode,
843+
true,
844+
oldSwapChain );
842845
if ( graphicsQueueFamilyIndex != presentQueueFamilyIndex )
843846
{
844847
uint32_t queueFamilyIndices[2] = { graphicsQueueFamilyIndex, presentQueueFamilyIndex };

vulkan/vulkan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16709,7 +16709,7 @@ namespace VULKAN_HPP_NAMESPACE
1670916709
m_library = dlopen( "libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL );
1671016710
}
1671116711
# elif defined( _WIN32 )
16712-
m_library = ::LoadLibraryA( "vulkan-1.dll" );
16712+
m_library = ::LoadLibraryA( "vulkan-1.dll" );
1671316713
# else
1671416714
# error unsupported platform
1671516715
# endif

vulkan/vulkansc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6960,7 +6960,7 @@ namespace VULKAN_HPP_NAMESPACE
69606960
m_library = dlopen( "libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL );
69616961
}
69626962
# elif defined( _WIN32 )
6963-
m_library = ::LoadLibraryA( "vulkan-1.dll" );
6963+
m_library = ::LoadLibraryA( "vulkan-1.dll" );
69646964
# else
69656965
# error unsupported platform
69666966
# endif

0 commit comments

Comments
 (0)