MayaFlux 1.0.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 684 of file VKShaderModule.cpp.

685{
686 using BaseType = spirv_cross::SPIRType::BaseType;
687
688 if (type.columns > 1) {
690 "Matrix types are not valid vertex attributes (columns={})",
691 type.columns);
692 return vk::Format::eUndefined;
693 }
694
695 if (type.width != 32) {
697 "Unsupported SPIR-V vertex attribute width {} (only 32-bit supported)",
698 type.width);
699 return vk::Format::eUndefined;
700 }
701
702 const uint32_t vec_size = type.vecsize;
703 if (type.basetype == BaseType::Float) {
704 switch (vec_size) {
705 case 1:
706 return vk::Format::eR32Sfloat;
707 case 2:
708 return vk::Format::eR32G32Sfloat;
709 case 3:
710 return vk::Format::eR32G32B32Sfloat;
711 case 4:
712 return vk::Format::eR32G32B32A32Sfloat;
713 }
714 } else if (type.basetype == BaseType::Int) {
715 switch (vec_size) {
716 case 1:
717 return vk::Format::eR32Sint;
718 case 2:
719 return vk::Format::eR32G32Sint;
720 case 3:
721 return vk::Format::eR32G32B32Sint;
722 case 4:
723 return vk::Format::eR32G32B32A32Sint;
724 }
725 } else if (type.basetype == BaseType::UInt) {
726 switch (vec_size) {
727 case 1:
728 return vk::Format::eR32Uint;
729 case 2:
730 return vk::Format::eR32G32Uint;
731 case 3:
732 return vk::Format::eR32G32B32Uint;
733 case 4:
734 return vk::Format::eR32G32B32A32Uint;
735 }
736 }
737
739 "Unsupported SPIR-V vertex attribute type (basetype={}, vecsize={})",
740 static_cast<int>(type.basetype), vec_size);
741
742 return vk::Format::eUndefined;
743}
#define MF_WARN(comp, ctx,...)
vk::PhysicalDeviceType type
Definition VKDevice.cpp:126
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

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

Referenced by reflect_spirv().

+ Here is the caller graph for this function: