MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Hpp / pickSurfaceFormat

Function pickSurfaceFormat

samples/utils/utils.cpp:539–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537 }
538
539 vk::SurfaceFormatKHR pickSurfaceFormat( std::vector<vk::SurfaceFormatKHR> const & formats )
540 {
541 assert( !formats.empty() );
542 vk::SurfaceFormatKHR pickedFormat = formats[0];
543 if ( formats.size() == 1 )
544 {
545 if ( formats[0].format == vk::Format::eUndefined )
546 {
547 pickedFormat.format = vk::Format::eB8G8R8A8Unorm;
548 pickedFormat.colorSpace = vk::ColorSpaceKHR::eSrgbNonlinear;
549 }
550 }
551 else
552 {
553 // request several formats, the first found will be used
554 vk::Format requestedFormats[] = { vk::Format::eB8G8R8A8Unorm, vk::Format::eR8G8B8A8Unorm, vk::Format::eB8G8R8Unorm, vk::Format::eR8G8B8Unorm };
555 vk::ColorSpaceKHR requestedColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear;
556 for ( size_t i = 0; i < sizeof( requestedFormats ) / sizeof( requestedFormats[0] ); i++ )
557 {
558 vk::Format requestedFormat = requestedFormats[i];
559 auto it = std::find_if( formats.begin(),
560 formats.end(),
561 [requestedFormat, requestedColorSpace]( vk::SurfaceFormatKHR const & f )
562 { return ( f.format == requestedFormat ) && ( f.colorSpace == requestedColorSpace ); } );
563 if ( it != formats.end() )
564 {
565 pickedFormat = *it;
566 break;
567 }
568 }
569 }
570 assert( pickedFormat.colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear );
571 return pickedFormat;
572 }
573
574 void setImageLayout(
575 vk::CommandBuffer const & commandBuffer, vk::Image image, vk::Format format, vk::ImageLayout oldImageLayout, vk::ImageLayout newImageLayout )

Callers 15

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
SwapChainDataMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected