MayaFlux 0.2.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 487 of file VKShaderModule.cpp.

488{
489 using BaseType = spirv_cross::SPIRType::BaseType;
490
491 if (type.columns > 1) {
493 "Matrix types are not valid vertex attributes (columns={})",
494 type.columns);
495 return vk::Format::eUndefined;
496 }
497
498 if (type.width != 32) {
500 "Unsupported SPIR-V vertex attribute width {} (only 32-bit supported)",
501 type.width);
502 return vk::Format::eUndefined;
503 }
504
505 const uint32_t vec_size = type.vecsize;
506 if (type.basetype == BaseType::Float) {
507 switch (vec_size) {
508 case 1:
509 return vk::Format::eR32Sfloat;
510 case 2:
511 return vk::Format::eR32G32Sfloat;
512 case 3:
513 return vk::Format::eR32G32B32Sfloat;
514 case 4:
515 return vk::Format::eR32G32B32A32Sfloat;
516 }
517 } else if (type.basetype == BaseType::Int) {
518 switch (vec_size) {
519 case 1:
520 return vk::Format::eR32Sint;
521 case 2:
522 return vk::Format::eR32G32Sint;
523 case 3:
524 return vk::Format::eR32G32B32Sint;
525 case 4:
526 return vk::Format::eR32G32B32A32Sint;
527 }
528 } else if (type.basetype == BaseType::UInt) {
529 switch (vec_size) {
530 case 1:
531 return vk::Format::eR32Uint;
532 case 2:
533 return vk::Format::eR32G32Uint;
534 case 3:
535 return vk::Format::eR32G32B32Uint;
536 case 4:
537 return vk::Format::eR32G32B32A32Uint;
538 }
539 }
540
542 "Unsupported SPIR-V vertex attribute type (basetype={}, vecsize={})",
543 static_cast<int>(type.basetype), vec_size);
544
545 return vk::Format::eUndefined;
546}
#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: