MCPcopy Create free account
hub / github.com/LunarG/VulkanTools / determineOutputFormat

Function determineOutputFormat

layersvt/screenshot.cpp:565–739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565static VkFormat determineOutputFormat(VkFormat format, ColorSpaceFormat userColorSpaceFormat, uint32_t numChannels) {
566 // Initial dest format is undefined as we will look for one
567 VkFormat destformat = VK_FORMAT_UNDEFINED;
568
569 // This variable set by readScreenShotFormatENV func during init
570 if (userColorSpaceFormat != ColorSpaceFormat::UNDEFINED) {
571 switch (userColorSpaceFormat) {
572 case ColorSpaceFormat::UNORM:
573 if (numChannels == 4)
574 destformat = VK_FORMAT_R8G8B8A8_UNORM;
575 else
576 destformat = VK_FORMAT_R8G8B8_UNORM;
577 break;
578 case ColorSpaceFormat::SRGB:
579 if (numChannels == 4)
580 destformat = VK_FORMAT_R8G8B8A8_SRGB;
581 else
582 destformat = VK_FORMAT_R8G8B8_SRGB;
583 break;
584 case ColorSpaceFormat::SNORM:
585 if (numChannels == 4)
586 destformat = VK_FORMAT_R8G8B8A8_SNORM;
587 else
588 destformat = VK_FORMAT_R8G8B8_SNORM;
589 break;
590 case ColorSpaceFormat::USCALED:
591 if (numChannels == 4)
592 destformat = VK_FORMAT_R8G8B8A8_USCALED;
593 else
594 destformat = VK_FORMAT_R8G8B8_USCALED;
595 break;
596 case ColorSpaceFormat::SSCALED:
597 if (numChannels == 4)
598 destformat = VK_FORMAT_R8G8B8A8_SSCALED;
599 else
600 destformat = VK_FORMAT_R8G8B8_SSCALED;
601 break;
602 case ColorSpaceFormat::UINT:
603 if (numChannels == 4)
604 destformat = VK_FORMAT_R8G8B8A8_UINT;
605 else
606 destformat = VK_FORMAT_R8G8B8_UINT;
607 break;
608 case ColorSpaceFormat::SINT:
609 if (numChannels == 4)
610 destformat = VK_FORMAT_R8G8B8A8_SINT;
611 else
612 destformat = VK_FORMAT_R8G8B8_SINT;
613 break;
614 default:
615 destformat = VK_FORMAT_UNDEFINED;
616 break;
617 }
618 }
619
620 // User did not require specific format so we use same colorspace with
621 // swapchain format
622 if (destformat == VK_FORMAT_UNDEFINED) {

Callers 1

prepareScreenshotDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected