MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ spirv_type_to_vk_format()

vk::Format MayaFlux::Core::VKShaderModule::spirv_type_to_vk_format ( const spirv_cross::SPIRType &  type)
staticprivate

Convert SPIRV-Cross type to Vulkan vertex attribute format.

Parameters
typeSPIR-V type information
Returns
Corresponding Vulkan format

Definition at line 613 of file VKShaderModule.cpp.

614{
615 using BaseType = spirv_cross::SPIRType::BaseType;
616
617 if (type.columns > 1) {
619 "Matrix types are not valid vertex attributes (columns={})",
620 type.columns);
621 return vk::Format::eUndefined;
622 }
623
624 if (type.width != 32) {
626 "Unsupported SPIR-V vertex attribute width {} (only 32-bit supported)",
627 type.width);
628 return vk::Format::eUndefined;
629 }
630
631 const uint32_t vec_size = type.vecsize;
632 if (type.basetype == BaseType::Float) {
633 switch (vec_size) {
634 case 1:
635 return vk::Format::eR32Sfloat;
636 case 2:
637 return vk::Format::eR32G32Sfloat;
638 case 3:
639 return vk::Format::eR32G32B32Sfloat;
640 case 4:
641 return vk::Format::eR32G32B32A32Sfloat;
642 }
643 } else if (type.basetype == BaseType::Int) {
644 switch (vec_size) {
645 case 1:
646 return vk::Format::eR32Sint;
647 case 2:
648 return vk::Format::eR32G32Sint;
649 case 3:
650 return vk::Format::eR32G32B32Sint;
651 case 4:
652 return vk::Format::eR32G32B32A32Sint;
653 }
654 } else if (type.basetype == BaseType::UInt) {
655 switch (vec_size) {
656 case 1:
657 return vk::Format::eR32Uint;
658 case 2:
659 return vk::Format::eR32G32Uint;
660 case 3:
661 return vk::Format::eR32G32B32Uint;
662 case 4:
663 return vk::Format::eR32G32B32A32Uint;
664 }
665 }
666
668 "Unsupported SPIR-V vertex attribute type (basetype={}, vecsize={})",
669 static_cast<int>(type.basetype), vec_size);
670
671 return vk::Format::eUndefined;
672}
#define MF_WARN(comp, ctx,...)
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Journal::GraphicsBackend, and MF_WARN.

Referenced by reflect_spirv().

+ Here is the caller graph for this function: