Skip to content

Commit

Permalink
Minor cleanup work (#2090)
Browse files Browse the repository at this point in the history
  • Loading branch information
asuessenbach authored Feb 24, 2025
1 parent f03a052 commit 8f9db1b
Show file tree
Hide file tree
Showing 21 changed files with 1,036 additions and 136 deletions.
3 changes: 1 addition & 2 deletions .clang-format_16
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ InsertNewlineAtEOF : true
IntegerLiteralSeparator :
Binary : 4
Decimal : 0
Hex : 2
HexMinDigits : 6
Hex : 0
KeepEmptyLinesAtTheStartOfBlocks : false
LambdaBodyIndentation : Signature
MaxEmptyLinesToKeep : 1
Expand Down
3 changes: 1 addition & 2 deletions .clang-format_17
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ InsertNewlineAtEOF : true
IntegerLiteralSeparator :
Binary : 4
Decimal : 0
Hex : 2
HexMinDigits : 6
Hex : 0
KeepEmptyLinesAtTheStartOfBlocks : false
LambdaBodyIndentation : Signature
MaxEmptyLinesToKeep : 1
Expand Down
3 changes: 1 addition & 2 deletions .clang-format_18
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ InsertNewlineAtEOF : true
IntegerLiteralSeparator :
Binary : 4
Decimal : 0
Hex : 2
HexMinDigits : 6
Hex : 0
KeepEmptyLinesAtTheStartOfBlocks : false
LambdaBodyIndentation : Signature
MaxEmptyLinesToKeep : 1
Expand Down
2 changes: 1 addition & 1 deletion RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main( int /*argc*/, char ** /*argv*/ )
uint32_t height = 64;
vk::su::WindowData window = vk::su::createWindow( AppName, { width, height } );
VkSurfaceKHR _surface;
glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window.handle, nullptr, &_surface );
glfwCreateWindowSurface( *instance, window.handle, nullptr, &_surface );
vk::raii::SurfaceKHR surface( instance, _surface );

// determine a queueFamilyIndex that suports present
Expand Down
13 changes: 5 additions & 8 deletions RAII_Samples/CopyBlitImage/CopyBlitImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ int main( int /*argc*/, char ** /*argv*/ )
assert( imageIndex < swapChainData.images.size() );

commandBuffer.begin( vk::CommandBufferBeginInfo() );
vk::raii::su::setImageLayout( commandBuffer,
static_cast<vk::Image>( swapChainData.images[imageIndex] ),
swapChainData.colorFormat,
vk::ImageLayout::eUndefined,
vk::ImageLayout::eTransferDstOptimal );
vk::raii::su::setImageLayout(
commandBuffer, swapChainData.images[imageIndex], swapChainData.colorFormat, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal );

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

vk::Image blitDestinationImage = static_cast<vk::Image>( swapChainData.images[imageIndex] );
vk::Image blitDestinationImage = swapChainData.images[imageIndex];

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

Expand Down
3 changes: 1 addition & 2 deletions RAII_Samples/DebugUtilsObjectName/DebugUtilsObjectName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ int main( int /*argc*/, char ** /*argv*/ )

/* VULKAN_KEY_START */

vk::DebugUtilsObjectNameInfoEXT debugUtilsObjectNameInfo(
vk::ObjectType::eImage, NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( VkImage, static_cast<vk ::Image>( image ) ), "Image name" );
vk::DebugUtilsObjectNameInfoEXT debugUtilsObjectNameInfo( vk::ObjectType::eImage, NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( VkImage, *image ), "Image name" );
device.setDebugUtilsObjectNameEXT( debugUtilsObjectNameInfo );

/* VULKAN_KEY_END */
Expand Down
13 changes: 5 additions & 8 deletions RAII_Samples/PhysicalDeviceGroups/PhysicalDeviceGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,19 @@ int main( int /*argc*/, char ** /*argv*/ )
for ( size_t i = 0; i < groupProperties.size(); i++ )
{
std::cout << "Group Properties " << i << " :\n";
std::cout << "\t"
<< "physicalDeviceCount = " << groupProperties[i].physicalDeviceCount << "\n";
std::cout << "\t"
<< "physicalDevices:\n";
std::cout << "\t" << "physicalDeviceCount = " << groupProperties[i].physicalDeviceCount << "\n";
std::cout << "\t" << "physicalDevices:\n";
for ( size_t j = 0; j < groupProperties[i].physicalDeviceCount; j++ )
{
vk::raii::PhysicalDevice physicalDevice( instance, static_cast<VkPhysicalDevice>( groupProperties[i].physicalDevices[j] ) );
vk::raii::PhysicalDevice physicalDevice( instance, groupProperties[i].physicalDevices[j] );
std::cout << "\t\t" << j << " : " << physicalDevice.getProperties().deviceName << "\n";
}
std::cout << "\t"
<< "subsetAllocation = " << !!groupProperties[i].subsetAllocation << "\n";
std::cout << "\t" << "subsetAllocation = " << !!groupProperties[i].subsetAllocation << "\n";
std::cout << "\n";

if ( 1 < groupProperties[i].physicalDeviceCount )
{
vk::raii::PhysicalDevice physicalDevice( instance, static_cast<VkPhysicalDevice>( groupProperties[i].physicalDevices[0] ) );
vk::raii::PhysicalDevice physicalDevice( instance, groupProperties[i].physicalDevices[0] );

// get the QueueFamilyProperties of the first PhysicalDevice
std::vector<vk::QueueFamilyProperties> queueFamilyProperties = physicalDevice.getQueueFamilyProperties();
Expand Down
22 changes: 8 additions & 14 deletions RAII_Samples/RayTracing/RayTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ static void keyCallback( GLFWwindow * window, int key, int /*scancode*/, int act
switch ( key )
{
case GLFW_KEY_ESCAPE:
case 'Q': glfwSetWindowShouldClose( window, 1 ); break;
case 'Q' : glfwSetWindowShouldClose( window, 1 ); break;
case 'R':
{
AppInfo * appInfo = reinterpret_cast<AppInfo *>( glfwGetWindowUserPointer( window ) );
Expand Down Expand Up @@ -725,7 +725,7 @@ int main( int /*argc*/, char ** /*argv*/ )

// Create Window Surface (using glfw)
VkSurfaceKHR glfwSurface;
VkResult err = glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window, nullptr, &glfwSurface );
VkResult err = glfwCreateWindowSurface( *instance, window, nullptr, &glfwSurface );
check_vk_result( err );
vk::raii::SurfaceKHR surface( instance, glfwSurface );

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

vk::raii::su::setImageLayout( commandBuffer,
static_cast<vk::Image>( swapChainData.images[backBufferIndex] ),
surfaceFormat.format,
vk::ImageLayout::eUndefined,
vk::ImageLayout::eGeneral );
vk::raii::su::setImageLayout(
commandBuffer, swapChainData.images[backBufferIndex], surfaceFormat.format, vk::ImageLayout::eUndefined, vk::ImageLayout::eGeneral );

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

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

vk::raii::su::setImageLayout( commandBuffer,
static_cast<vk::Image>( swapChainData.images[backBufferIndex] ),
surfaceFormat.format,
vk::ImageLayout::eGeneral,
vk::ImageLayout::ePresentSrcKHR );
vk::raii::su::setImageLayout(
commandBuffer, swapChainData.images[backBufferIndex], surfaceFormat.format, vk::ImageLayout::eGeneral, vk::ImageLayout::ePresentSrcKHR );
}

// frame end
Expand All @@ -1236,9 +1230,9 @@ int main( int /*argc*/, char ** /*argv*/ )
result = presentQueue.presentKHR( presentInfoKHR );
switch ( result )
{
case vk::Result::eSuccess: break;
case vk::Result::eSuccess : break;
case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
default: assert( false ); // an unexpected result is returned !
default : assert( false ); // an unexpected result is returned !
}
frameIndex = ( frameIndex + 1 ) % IMGUI_VK_QUEUED_FRAMES;

Expand Down
13 changes: 5 additions & 8 deletions RAII_Samples/SecondaryCommandBuffer/SecondaryCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,8 @@ int main( int /*argc*/, char ** /*argv*/ )
assert( result == vk::Result::eSuccess );
assert( imageIndex < swapChainData.images.size() );

vk::raii::su::setImageLayout( commandBuffer,
static_cast<vk::Image>( swapChainData.images[imageIndex] ),
swapChainData.colorFormat,
vk::ImageLayout::eUndefined,
vk::ImageLayout::eColorAttachmentOptimal );
vk::raii::su::setImageLayout(
commandBuffer, swapChainData.images[imageIndex], swapChainData.colorFormat, vk::ImageLayout::eUndefined, vk::ImageLayout::eColorAttachmentOptimal );

const vk::DeviceSize offset = 0;
vk::Viewport viewport( 0.0f, 0.0f, 200.0f, 200.0f, 0.0f, 1.0f );
Expand Down Expand Up @@ -198,7 +195,7 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::ImageLayout::ePresentSrcKHR,
VK_QUEUE_FAMILY_IGNORED,
VK_QUEUE_FAMILY_IGNORED,
static_cast<vk::Image>( swapChainData.images[imageIndex] ),
swapChainData.images[imageIndex],
imageSubresourceRange );
commandBuffer.pipelineBarrier(
vk::PipelineStageFlagBits::eColorAttachmentOutput, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlags(), nullptr, nullptr, prePresentBarrier );
Expand All @@ -216,9 +213,9 @@ int main( int /*argc*/, char ** /*argv*/ )
result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, *swapChainData.swapChain, imageIndex, {} ) );
switch ( result )
{
case vk::Result::eSuccess: break;
case vk::Result::eSuccess : break;
case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
default: assert( false ); // an unexpected result is returned !
default : assert( false ); // an unexpected result is returned !
}
std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );

Expand Down
11 changes: 5 additions & 6 deletions RAII_Samples/SurfaceCapabilities/SurfaceCapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ int main( int /*argc*/, char ** /*argv*/ )
std::cout << "PhysicalDevice " << i << "\n";
if ( supportsGetSurfaceCapabilities2 )
{
auto surfaceCapabilities2 =
physicalDevices[i]
.getSurfaceCapabilities2KHR<vk::SurfaceCapabilities2KHR,
vk::DisplayNativeHdrSurfaceCapabilitiesAMD,
vk::SharedPresentSurfaceCapabilitiesKHR,
vk::SurfaceProtectedCapabilitiesKHR>( { static_cast<vk::SurfaceKHR>( surfaceData.surface ) } );
auto surfaceCapabilities2 = physicalDevices[i]
.getSurfaceCapabilities2KHR<vk::SurfaceCapabilities2KHR,
vk::DisplayNativeHdrSurfaceCapabilitiesAMD,
vk::SharedPresentSurfaceCapabilitiesKHR,
vk::SurfaceProtectedCapabilitiesKHR>( { *surfaceData.surface } );

vk::SurfaceCapabilitiesKHR const & surfaceCapabilities = surfaceCapabilities2.get<vk::SurfaceCapabilities2KHR>().surfaceCapabilities;
cout( surfaceCapabilities );
Expand Down
2 changes: 1 addition & 1 deletion RAII_Samples/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ namespace vk
: extent( extent_ ), window( vk::su::createWindow( windowName, extent ) )
{
VkSurfaceKHR _surface;
VkResult err = glfwCreateWindowSurface( static_cast<VkInstance>( *instance ), window.handle, nullptr, &_surface );
VkResult err = glfwCreateWindowSurface( *instance, window.handle, nullptr, &_surface );
if ( err != VK_SUCCESS )
throw std::runtime_error( "Failed to create window!" );
surface = vk::raii::SurfaceKHR( instance, _surface );
Expand Down
10 changes: 10 additions & 0 deletions VideoHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ std::string VideoHppGenerator::generateStruct( std::pair<std::string, StructureD
{
return *reinterpret_cast<StdVideo${structureType}*>( this );
}
operator StdVideo${structureType} const *() const VULKAN_HPP_NOEXCEPT
{
return reinterpret_cast<const StdVideo${structureType}*>( this );
}
operator StdVideo${structureType} *() VULKAN_HPP_NOEXCEPT
{
return reinterpret_cast<StdVideo${structureType}*>( this );
}
${compareOperators}
public:
${members}
Expand Down
Loading

0 comments on commit 8f9db1b

Please sign in to comment.