MayaFlux 0.4.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 562 of file VKShaderModule.cpp.

563{
564 using BaseType = spirv_cross::SPIRType::BaseType;
565
566 if (type.columns > 1) {
568 "Matrix types are not valid vertex attributes (columns={})",
569 type.columns);
570 return vk::Format::eUndefined;
571 }
572
573 if (type.width != 32) {
575 "Unsupported SPIR-V vertex attribute width {} (only 32-bit supported)",
576 type.width);
577 return vk::Format::eUndefined;
578 }
579
580 const uint32_t vec_size = type.vecsize;
581 if (type.basetype == BaseType::Float) {
582 switch (vec_size) {
583 case 1:
584 return vk::Format::eR32Sfloat;
585 case 2:
586 return vk::Format::eR32G32Sfloat;
587 case 3:
588 return vk::Format::eR32G32B32Sfloat;
589 case 4:
590 return vk::Format::eR32G32B32A32Sfloat;
591 }
592 } else if (type.basetype == BaseType::Int) {
593 switch (vec_size) {
594 case 1:
595 return vk::Format::eR32Sint;
596 case 2:
597 return vk::Format::eR32G32Sint;
598 case 3:
599 return vk::Format::eR32G32B32Sint;
600 case 4:
601 return vk::Format::eR32G32B32A32Sint;
602 }
603 } else if (type.basetype == BaseType::UInt) {
604 switch (vec_size) {
605 case 1:
606 return vk::Format::eR32Uint;
607 case 2:
608 return vk::Format::eR32G32Uint;
609 case 3:
610 return vk::Format::eR32G32B32Uint;
611 case 4:
612 return vk::Format::eR32G32B32A32Uint;
613 }
614 }
615
617 "Unsupported SPIR-V vertex attribute type (basetype={}, vecsize={})",
618 static_cast<int>(type.basetype), vec_size);
619
620 return vk::Format::eUndefined;
621}
#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: