Skip to content

Commit 8f9db1b

Browse files
authored
Minor cleanup work (#2090)
1 parent f03a052 commit 8f9db1b

File tree

21 files changed

+1036
-136
lines changed

21 files changed

+1036
-136
lines changed

.clang-format_16

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ InsertNewlineAtEOF : true
7575
IntegerLiteralSeparator :
7676
Binary : 4
7777
Decimal : 0
78-
Hex : 2
79-
HexMinDigits : 6
78+
Hex : 0
8079
KeepEmptyLinesAtTheStartOfBlocks : false
8180
LambdaBodyIndentation : Signature
8281
MaxEmptyLinesToKeep : 1

.clang-format_17

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ InsertNewlineAtEOF : true
8181
IntegerLiteralSeparator :
8282
Binary : 4
8383
Decimal : 0
84-
Hex : 2
85-
HexMinDigits : 6
84+
Hex : 0
8685
KeepEmptyLinesAtTheStartOfBlocks : false
8786
LambdaBodyIndentation : Signature
8887
MaxEmptyLinesToKeep : 1

.clang-format_18

+1-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ InsertNewlineAtEOF : true
8484
IntegerLiteralSeparator :
8585
Binary : 4
8686
Decimal : 0
87-
Hex : 2
88-
HexMinDigits : 6
87+
Hex : 0
8988
KeepEmptyLinesAtTheStartOfBlocks : false
9089
LambdaBodyIndentation : Signature
9190
MaxEmptyLinesToKeep : 1

RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int main( int /*argc*/, char ** /*argv*/ )
4242
uint32_t height = 64;
4343
vk::su::WindowData window = vk::su::createWindow( AppName, { width, height } );
4444
VkSurfaceKHR _surface;
45-
glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window.handle, nullptr, &_surface );
45+
glfwCreateWindowSurface( *instance, window.handle, nullptr, &_surface );
4646
vk::raii::SurfaceKHR surface( instance, _surface );
4747

4848
// determine a queueFamilyIndex that suports present

RAII_Samples/CopyBlitImage/CopyBlitImage.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,8 @@ int main( int /*argc*/, char ** /*argv*/ )
7878
assert( imageIndex < swapChainData.images.size() );
7979

8080
commandBuffer.begin( vk::CommandBufferBeginInfo() );
81-
vk::raii::su::setImageLayout( commandBuffer,
82-
static_cast<vk::Image>( swapChainData.images[imageIndex] ),
83-
swapChainData.colorFormat,
84-
vk::ImageLayout::eUndefined,
85-
vk::ImageLayout::eTransferDstOptimal );
81+
vk::raii::su::setImageLayout(
82+
commandBuffer, swapChainData.images[imageIndex], swapChainData.colorFormat, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal );
8683

8784
// in order to get a clean desctruction sequence, instantiate the DeviceMemory for the image first
8885
vk::raii::DeviceMemory deviceMemory( nullptr );
@@ -150,7 +147,7 @@ int main( int /*argc*/, char ** /*argv*/ )
150147
// Intend to blit from this image, set the layout accordingly
151148
vk::raii::su::setImageLayout( commandBuffer, blitSourceImage, swapChainData.colorFormat, vk::ImageLayout::eGeneral, vk::ImageLayout::eTransferSrcOptimal );
152149

153-
vk::Image blitDestinationImage = static_cast<vk::Image>( swapChainData.images[imageIndex] );
150+
vk::Image blitDestinationImage = swapChainData.images[imageIndex];
154151

155152
// Do a 32x32 blit to all of the dst image - should get big squares
156153
vk::ImageSubresourceLayers imageSubresourceLayers( vk::ImageAspectFlagBits::eColor, 0, 0, 1 );
@@ -203,9 +200,9 @@ int main( int /*argc*/, char ** /*argv*/ )
203200
result = presentQueue.presentKHR( presentInfoKHR );
204201
switch ( result )
205202
{
206-
case vk::Result::eSuccess: break;
203+
case vk::Result::eSuccess : break;
207204
case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
208-
default: assert( false ); // an unexpected result is returned !
205+
default : assert( false ); // an unexpected result is returned !
209206
}
210207
std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
211208

RAII_Samples/DebugUtilsObjectName/DebugUtilsObjectName.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ int main( int /*argc*/, char ** /*argv*/ )
4747

4848
/* VULKAN_KEY_START */
4949

50-
vk::DebugUtilsObjectNameInfoEXT debugUtilsObjectNameInfo(
51-
vk::ObjectType::eImage, NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( VkImage, static_cast<vk ::Image>( image ) ), "Image name" );
50+
vk::DebugUtilsObjectNameInfoEXT debugUtilsObjectNameInfo( vk::ObjectType::eImage, NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( VkImage, *image ), "Image name" );
5251
device.setDebugUtilsObjectNameEXT( debugUtilsObjectNameInfo );
5352

5453
/* VULKAN_KEY_END */

RAII_Samples/PhysicalDeviceGroups/PhysicalDeviceGroups.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,19 @@ int main( int /*argc*/, char ** /*argv*/ )
4040
for ( size_t i = 0; i < groupProperties.size(); i++ )
4141
{
4242
std::cout << "Group Properties " << i << " :\n";
43-
std::cout << "\t"
44-
<< "physicalDeviceCount = " << groupProperties[i].physicalDeviceCount << "\n";
45-
std::cout << "\t"
46-
<< "physicalDevices:\n";
43+
std::cout << "\t" << "physicalDeviceCount = " << groupProperties[i].physicalDeviceCount << "\n";
44+
std::cout << "\t" << "physicalDevices:\n";
4745
for ( size_t j = 0; j < groupProperties[i].physicalDeviceCount; j++ )
4846
{
49-
vk::raii::PhysicalDevice physicalDevice( instance, static_cast<VkPhysicalDevice>( groupProperties[i].physicalDevices[j] ) );
47+
vk::raii::PhysicalDevice physicalDevice( instance, groupProperties[i].physicalDevices[j] );
5048
std::cout << "\t\t" << j << " : " << physicalDevice.getProperties().deviceName << "\n";
5149
}
52-
std::cout << "\t"
53-
<< "subsetAllocation = " << !!groupProperties[i].subsetAllocation << "\n";
50+
std::cout << "\t" << "subsetAllocation = " << !!groupProperties[i].subsetAllocation << "\n";
5451
std::cout << "\n";
5552

5653
if ( 1 < groupProperties[i].physicalDeviceCount )
5754
{
58-
vk::raii::PhysicalDevice physicalDevice( instance, static_cast<VkPhysicalDevice>( groupProperties[i].physicalDevices[0] ) );
55+
vk::raii::PhysicalDevice physicalDevice( instance, groupProperties[i].physicalDevices[0] );
5956

6057
// get the QueueFamilyProperties of the first PhysicalDevice
6158
std::vector<vk::QueueFamilyProperties> queueFamilyProperties = physicalDevice.getQueueFamilyProperties();

RAII_Samples/RayTracing/RayTracing.cpp

+8-14
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static void keyCallback( GLFWwindow * window, int key, int /*scancode*/, int act
581581
switch ( key )
582582
{
583583
case GLFW_KEY_ESCAPE:
584-
case 'Q': glfwSetWindowShouldClose( window, 1 ); break;
584+
case 'Q' : glfwSetWindowShouldClose( window, 1 ); break;
585585
case 'R':
586586
{
587587
AppInfo * appInfo = reinterpret_cast<AppInfo *>( glfwGetWindowUserPointer( window ) );
@@ -725,7 +725,7 @@ int main( int /*argc*/, char ** /*argv*/ )
725725

726726
// Create Window Surface (using glfw)
727727
VkSurfaceKHR glfwSurface;
728-
VkResult err = glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window, nullptr, &glfwSurface );
728+
VkResult err = glfwCreateWindowSurface( *instance, window, nullptr, &glfwSurface );
729729
check_vk_result( err );
730730
vk::raii::SurfaceKHR surface( instance, glfwSurface );
731731

@@ -1188,11 +1188,8 @@ int main( int /*argc*/, char ** /*argv*/ )
11881188
vk::WriteDescriptorSet writeDescriptorSet( *rayTracingDescriptorSets[backBufferIndex], 1, 0, bindings[1].descriptorType, imageInfo );
11891189
device.updateDescriptorSets( writeDescriptorSet, nullptr );
11901190

1191-
vk::raii::su::setImageLayout( commandBuffer,
1192-
static_cast<vk::Image>( swapChainData.images[backBufferIndex] ),
1193-
surfaceFormat.format,
1194-
vk::ImageLayout::eUndefined,
1195-
vk::ImageLayout::eGeneral );
1191+
vk::raii::su::setImageLayout(
1192+
commandBuffer, swapChainData.images[backBufferIndex], surfaceFormat.format, vk::ImageLayout::eUndefined, vk::ImageLayout::eGeneral );
11961193

11971194
commandBuffer.bindPipeline( vk::PipelineBindPoint::eRayTracingNV, *rayTracingPipeline );
11981195

@@ -1214,11 +1211,8 @@ int main( int /*argc*/, char ** /*argv*/ )
12141211
windowExtent.height,
12151212
1 );
12161213

1217-
vk::raii::su::setImageLayout( commandBuffer,
1218-
static_cast<vk::Image>( swapChainData.images[backBufferIndex] ),
1219-
surfaceFormat.format,
1220-
vk::ImageLayout::eGeneral,
1221-
vk::ImageLayout::ePresentSrcKHR );
1214+
vk::raii::su::setImageLayout(
1215+
commandBuffer, swapChainData.images[backBufferIndex], surfaceFormat.format, vk::ImageLayout::eGeneral, vk::ImageLayout::ePresentSrcKHR );
12221216
}
12231217

12241218
// frame end
@@ -1236,9 +1230,9 @@ int main( int /*argc*/, char ** /*argv*/ )
12361230
result = presentQueue.presentKHR( presentInfoKHR );
12371231
switch ( result )
12381232
{
1239-
case vk::Result::eSuccess: break;
1233+
case vk::Result::eSuccess : break;
12401234
case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
1241-
default: assert( false ); // an unexpected result is returned !
1235+
default : assert( false ); // an unexpected result is returned !
12421236
}
12431237
frameIndex = ( frameIndex + 1 ) % IMGUI_VK_QUEUED_FRAMES;
12441238

RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,8 @@ int main( int /*argc*/, char ** /*argv*/ )
147147
assert( result == vk::Result::eSuccess );
148148
assert( imageIndex < swapChainData.images.size() );
149149

150-
vk::raii::su::setImageLayout( commandBuffer,
151-
static_cast<vk::Image>( swapChainData.images[imageIndex] ),
152-
swapChainData.colorFormat,
153-
vk::ImageLayout::eUndefined,
154-
vk::ImageLayout::eColorAttachmentOptimal );
150+
vk::raii::su::setImageLayout(
151+
commandBuffer, swapChainData.images[imageIndex], swapChainData.colorFormat, vk::ImageLayout::eUndefined, vk::ImageLayout::eColorAttachmentOptimal );
155152

156153
const vk::DeviceSize offset = 0;
157154
vk::Viewport viewport( 0.0f, 0.0f, 200.0f, 200.0f, 0.0f, 1.0f );
@@ -198,7 +195,7 @@ int main( int /*argc*/, char ** /*argv*/ )
198195
vk::ImageLayout::ePresentSrcKHR,
199196
VK_QUEUE_FAMILY_IGNORED,
200197
VK_QUEUE_FAMILY_IGNORED,
201-
static_cast<vk::Image>( swapChainData.images[imageIndex] ),
198+
swapChainData.images[imageIndex],
202199
imageSubresourceRange );
203200
commandBuffer.pipelineBarrier(
204201
vk::PipelineStageFlagBits::eColorAttachmentOutput, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlags(), nullptr, nullptr, prePresentBarrier );
@@ -216,9 +213,9 @@ int main( int /*argc*/, char ** /*argv*/ )
216213
result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, *swapChainData.swapChain, imageIndex, {} ) );
217214
switch ( result )
218215
{
219-
case vk::Result::eSuccess: break;
216+
case vk::Result::eSuccess : break;
220217
case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
221-
default: assert( false ); // an unexpected result is returned !
218+
default : assert( false ); // an unexpected result is returned !
222219
}
223220
std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
224221

RAII_Samples/SurfaceCapabilities/SurfaceCapabilities.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ int main( int /*argc*/, char ** /*argv*/ )
8484
std::cout << "PhysicalDevice " << i << "\n";
8585
if ( supportsGetSurfaceCapabilities2 )
8686
{
87-
auto surfaceCapabilities2 =
88-
physicalDevices[i]
89-
.getSurfaceCapabilities2KHR<vk::SurfaceCapabilities2KHR,
90-
vk::DisplayNativeHdrSurfaceCapabilitiesAMD,
91-
vk::SharedPresentSurfaceCapabilitiesKHR,
92-
vk::SurfaceProtectedCapabilitiesKHR>( { static_cast<vk::SurfaceKHR>( surfaceData.surface ) } );
87+
auto surfaceCapabilities2 = physicalDevices[i]
88+
.getSurfaceCapabilities2KHR<vk::SurfaceCapabilities2KHR,
89+
vk::DisplayNativeHdrSurfaceCapabilitiesAMD,
90+
vk::SharedPresentSurfaceCapabilitiesKHR,
91+
vk::SurfaceProtectedCapabilitiesKHR>( { *surfaceData.surface } );
9392

9493
vk::SurfaceCapabilitiesKHR const & surfaceCapabilities = surfaceCapabilities2.get<vk::SurfaceCapabilities2KHR>().surfaceCapabilities;
9594
cout( surfaceCapabilities );

RAII_Samples/utils/utils.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ namespace vk
315315
: extent( extent_ ), window( vk::su::createWindow( windowName, extent ) )
316316
{
317317
VkSurfaceKHR _surface;
318-
VkResult err = glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window.handle, nullptr, &_surface );
318+
VkResult err = glfwCreateWindowSurface( *instance, window.handle, nullptr, &_surface );
319319
if ( err != VK_SUCCESS )
320320
throw std::runtime_error( "Failed to create window!" );
321321
surface = vk::raii::SurfaceKHR( instance, _surface );

VideoHppGenerator.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ std::string VideoHppGenerator::generateStruct( std::pair<std::string, StructureD
269269
{
270270
return *reinterpret_cast<StdVideo${structureType}*>( this );
271271
}
272+
273+
operator StdVideo${structureType} const *() const VULKAN_HPP_NOEXCEPT
274+
{
275+
return reinterpret_cast<const StdVideo${structureType}*>( this );
276+
}
277+
278+
operator StdVideo${structureType} *() VULKAN_HPP_NOEXCEPT
279+
{
280+
return reinterpret_cast<StdVideo${structureType}*>( this );
281+
}
272282
${compareOperators}
273283
public:
274284
${members}

0 commit comments

Comments
 (0)