7#ifdef MAYAFLUX_USE_SHADERC
8#include <shaderc/shaderc.hpp>
11#include <spirv_cross/spirv_cross.hpp>
16 std::vector<std::string> get_shader_search_paths()
18 std::vector<std::string> paths {
19 SHADER_BUILD_OUTPUT_DIR,
29 if (std::string_view(SHADER_EXAMPLE_DIR).length() > 0) {
30 paths.emplace_back(SHADER_EXAMPLE_DIR);
33#ifdef MAYAFLUX_PROJECT_SHADER_DIR
34 paths.emplace_back(MAYAFLUX_PROJECT_SHADER_DIR);
40 std::string resolve_shader_path(
const std::string& filename)
42 namespace fs = std::filesystem;
44 if (fs::path(filename).is_absolute() || fs::exists(filename)) {
48 for (
const auto& search_path : get_shader_search_paths()) {
49 fs::path full_path = fs::path(search_path) / filename;
50 if (fs::exists(full_path)) {
52 "Resolved shader '{}' -> '{}'", filename, full_path.string());
53 return full_path.string();
60 vk::DescriptorType spirv_to_vk_descriptor_type(spirv_cross::SPIRType::BaseType base_type,
61 const spirv_cross::SPIRType& type,
64 if (type.image.dim != spv::DimMax) {
65 if (type.image.sampled == 2) {
66 return vk::DescriptorType::eStorageImage;
69 if (type.image.sampled == 1) {
70 return is_storage ? vk::DescriptorType::eSampledImage
71 : vk::DescriptorType::eCombinedImageSampler;
76 return vk::DescriptorType::eStorageBuffer;
79 return vk::DescriptorType::eUniformBuffer;
82 class FileIncluder :
public shaderc::CompileOptions::IncluderInterface {
84 explicit FileIncluder(
const std::vector<std::string>& dirs)
89 shaderc_include_result* GetInclude(
90 const char* requested_source,
91 shaderc_include_type ,
95 namespace fs = std::filesystem;
96 auto* result =
new shaderc_include_result {};
98 for (
const auto& dir :
m_dirs) {
99 fs::path full = fs::path(dir) / requested_source;
100 if (fs::exists(full)) {
101 auto* container =
new std::string(full.string());
102 auto* content =
new std::string(read_file(full.string()));
103 result->source_name = container->c_str();
104 result->source_name_length = container->size();
105 result->content = content->c_str();
106 result->content_length = content->size();
107 result->user_data =
new std::pair<std::string*, std::string*>(container, content);
112 static const std::string err =
"include not found";
113 result->source_name =
"";
114 result->source_name_length = 0;
115 result->content = err.c_str();
116 result->content_length = err.size();
117 result->user_data =
nullptr;
121 void ReleaseInclude(shaderc_include_result* result)
override
123 if (result->user_data) {
124 auto* p =
static_cast<std::pair<std::string*, std::string*>*
>(result->user_data);
135 static std::string read_file(
const std::string& path)
137 std::ifstream f(path);
138 return { std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>() };
151 "VKShaderModule destroyed without cleanup() - potential leak");
156 : m_module(other.m_module)
157 , m_stage(other.m_stage)
158 , m_entry_point(std::move(other.m_entry_point))
159 , m_reflection(std::move(other.m_reflection))
160 , m_spirv_code(std::move(other.m_spirv_code))
161 , m_preserve_spirv(other.m_preserve_spirv)
162 , m_specialization_map(std::move(other.m_specialization_map))
163 , m_specialization_entries(std::move(other.m_specialization_entries))
164 , m_specialization_data(std::move(other.m_specialization_data))
165 , m_specialization_info(other.m_specialization_info)
167 other.m_module =
nullptr;
172 if (
this != &other) {
175 "VKShaderModule move-assigned without cleanup() - potential leak");
178 m_module = other.m_module;
179 m_stage = other.m_stage;
180 m_entry_point = std::move(other.m_entry_point);
181 m_reflection = std::move(other.m_reflection);
182 m_spirv_code = std::move(other.m_spirv_code);
183 m_preserve_spirv = other.m_preserve_spirv;
184 m_specialization_map = std::move(other.m_specialization_map);
185 m_specialization_entries = std::move(other.m_specialization_entries);
186 m_specialization_data = std::move(other.m_specialization_data);
187 m_specialization_info = other.m_specialization_info;
189 other.m_module =
nullptr;
197 device.destroyShaderModule(
m_module);
201 "Shader module cleaned up ({} stage)", vk::to_string(
m_stage));
217 const std::vector<uint32_t>& spirv_code,
218 vk::ShaderStageFlagBits stage,
219 const std::string& entry_point,
220 bool enable_reflection)
222 if (spirv_code.empty()) {
224 "Cannot create shader module from empty SPIR-V code");
228 if (spirv_code[0] != 0x07230203) {
230 "Invalid SPIR-V magic number: 0x{:08X} (expected 0x07230203)",
235 vk::ShaderModuleCreateInfo create_info;
236 create_info.codeSize = spirv_code.size() *
sizeof(uint32_t);
237 create_info.pCode = spirv_code.data();
240 m_module = device.createShaderModule(create_info);
241 }
catch (
const vk::SystemError& e) {
243 "Failed to create shader module: {}", e.what());
254 if (enable_reflection) {
257 "Shader reflection failed - descriptor layouts must be manually specified");
262 "Shader module created ({} stage, {} bytes SPIR-V, entry='{}')",
263 vk::to_string(stage), spirv_code.size() * 4, entry_point);
270 const std::string& spirv_path,
271 vk::ShaderStageFlagBits stage,
272 const std::string& entry_point,
273 bool enable_reflection)
275 std::string resolved_path = resolve_shader_path(spirv_path);
278 if (spirv_code.empty()) {
280 "Failed to read SPIR-V file: '{}'", spirv_path);
285 "Loaded SPIR-V from file: '{}'", spirv_path);
287 return create_from_spirv(device, spirv_code, stage, entry_point, enable_reflection);
296 const std::string& glsl_source,
297 vk::ShaderStageFlagBits stage,
298 const std::string& entry_point,
299 bool enable_reflection,
300 const std::vector<std::string>& include_directories,
301 const std::unordered_map<std::string, std::string>& defines)
304 if (spirv_code.empty()) {
306 "Failed to compile GLSL to SPIR-V ({} stage)", vk::to_string(stage));
311 "Compiled GLSL to SPIR-V ({} stage, {} bytes)",
312 vk::to_string(stage), spirv_code.size() * 4);
314 return create_from_spirv(device, spirv_code, stage, entry_point, enable_reflection);
319 const std::string& glsl_path,
320 std::optional<vk::ShaderStageFlagBits> stage,
321 const std::string& entry_point,
322 bool enable_reflection,
323 const std::vector<std::string>& include_directories,
324 const std::unordered_map<std::string, std::string>& defines)
326 std::string resolved_path = resolve_shader_path(glsl_path);
328 if (!stage.has_value()) {
330 if (!stage.has_value()) {
332 "Cannot auto-detect shader stage from file extension: '{}'", glsl_path);
336 "Auto-detected {} stage from file extension", vk::to_string(*stage));
340 if (glsl_source.empty()) {
342 "Failed to read GLSL file: '{}'", glsl_path);
347 "Loaded GLSL from file: '{}' ({} bytes)", glsl_path, glsl_source.size());
350 enable_reflection, include_directories, defines);
361 "Cannot get stage create info from invalid shader module");
365 vk::PipelineShaderStageCreateInfo stage_info;
383 const std::unordered_map<uint32_t, uint32_t>& constants)
388 "Set {} specialization constants for {} stage",
389 constants.size(), vk::to_string(
m_stage));
409 vk::SpecializationMapEntry entry;
410 entry.constantID = constant_id;
411 entry.offset = offset;
412 entry.size =
sizeof(uint32_t);
416 offset +=
sizeof(uint32_t);
432 spirv_cross::Compiler compiler(spirv_code);
433 spirv_cross::ShaderResources resources = compiler.get_shader_resources();
435 auto reflect_resources = [&](
const spirv_cross::SmallVector<spirv_cross::Resource>& res_vec,
436 bool is_storage =
false) {
437 for (
const auto& resource : res_vec) {
439 desc.
set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
440 desc.
binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
442 desc.
name = resource.name;
444 const auto& type = compiler.get_type(resource.type_id);
445 desc.
count = type.array.empty() ? 1 : type.array[0];
446 desc.
type = spirv_to_vk_descriptor_type(type.basetype, type, is_storage);
452 reflect_resources(resources.uniform_buffers,
false);
454 reflect_resources(resources.storage_buffers,
true);
456 reflect_resources(resources.sampled_images,
false);
458 reflect_resources(resources.storage_images,
true);
460 reflect_resources(resources.separate_images,
false);
461 reflect_resources(resources.separate_samplers,
false);
468 for (
const auto& pc_buffer : resources.push_constant_buffers) {
469 const auto& type = compiler.get_type(pc_buffer.type_id);
474 range.size =
static_cast<uint32_t
>(compiler.get_declared_struct_size(type));
484 auto spec_constants = compiler.get_specialization_constants();
485 for (
const auto& spec : spec_constants) {
488 sc.
name = compiler.get_name(spec.id);
490 const auto& type = compiler.get_type(compiler.get_constant(spec.id).constant_type);
491 sc.
size =
static_cast<uint32_t
>(compiler.get_declared_struct_size(type));
498 "Reflected {} specialization constants",
502 if (
m_stage == vk::ShaderStageFlagBits::eCompute
503 ||
m_stage == vk::ShaderStageFlagBits::eMeshEXT
504 ||
m_stage == vk::ShaderStageFlagBits::eTaskEXT) {
505 auto entry_points = compiler.get_entry_points_and_stages();
507 for (
const auto& ep : entry_points) {
508 if (ep.name ==
m_entry_point && ep.execution_model == spv::ExecutionModelGLCompute) {
510 std::array<uint32_t, 3> workgroup_size {
511 compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 0),
512 compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 1),
513 compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 2)
516 if (!workgroup_size.empty() && workgroup_size.size() >= 3) {
524 "Compute shader workgroup size: [{}, {}, {}]",
525 workgroup_size[0], workgroup_size[1], workgroup_size[2]);
532 if (
m_stage == vk::ShaderStageFlagBits::eVertex) {
533 for (
const auto&
input : resources.stage_inputs) {
534 uint32_t location = compiler.get_decoration(
input.id, spv::DecorationLocation);
535 const auto& type = compiler.get_type(
input.type_id);
537 vk::VertexInputAttributeDescription attr;
538 attr.location = location;
548 "Reflected {} vertex input attributes",
555 }
catch (
const spirv_cross::CompilerError& e) {
557 "SPIRV-Cross reflection failed: {}", e.what());
564 using BaseType = spirv_cross::SPIRType::BaseType;
566 if (type.columns > 1) {
568 "Matrix types are not valid vertex attributes (columns={})",
570 return vk::Format::eUndefined;
573 if (type.width != 32) {
575 "Unsupported SPIR-V vertex attribute width {} (only 32-bit supported)",
577 return vk::Format::eUndefined;
580 const uint32_t vec_size = type.vecsize;
581 if (type.basetype == BaseType::Float) {
584 return vk::Format::eR32Sfloat;
586 return vk::Format::eR32G32Sfloat;
588 return vk::Format::eR32G32B32Sfloat;
590 return vk::Format::eR32G32B32A32Sfloat;
592 }
else if (type.basetype == BaseType::Int) {
595 return vk::Format::eR32Sint;
597 return vk::Format::eR32G32Sint;
599 return vk::Format::eR32G32B32Sint;
601 return vk::Format::eR32G32B32A32Sint;
603 }
else if (type.basetype == BaseType::UInt) {
606 return vk::Format::eR32Uint;
608 return vk::Format::eR32G32Uint;
610 return vk::Format::eR32G32B32Uint;
612 return vk::Format::eR32G32B32A32Uint;
617 "Unsupported SPIR-V vertex attribute type (basetype={}, vecsize={})",
618 static_cast<int>(type.basetype), vec_size);
620 return vk::Format::eUndefined;
628 const std::string& filepath)
630 std::filesystem::path path(filepath);
631 std::string ext = path.extension().string();
633 std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
635 static const std::unordered_map<std::string, vk::ShaderStageFlagBits> extension_map = {
636 {
".comp", vk::ShaderStageFlagBits::eCompute },
637 {
".vert", vk::ShaderStageFlagBits::eVertex },
638 {
".frag", vk::ShaderStageFlagBits::eFragment },
639 {
".geom", vk::ShaderStageFlagBits::eGeometry },
640 {
".tesc", vk::ShaderStageFlagBits::eTessellationControl },
641 {
".tese", vk::ShaderStageFlagBits::eTessellationEvaluation },
642 {
".rgen", vk::ShaderStageFlagBits::eRaygenKHR },
643 {
".rint", vk::ShaderStageFlagBits::eIntersectionKHR },
644 {
".rahit", vk::ShaderStageFlagBits::eAnyHitKHR },
645 {
".rchit", vk::ShaderStageFlagBits::eClosestHitKHR },
646 {
".rmiss", vk::ShaderStageFlagBits::eMissKHR },
647 {
".rcall", vk::ShaderStageFlagBits::eCallableKHR },
648 {
".mesh", vk::ShaderStageFlagBits::eMeshEXT },
649 {
".task", vk::ShaderStageFlagBits::eTaskEXT }
652 auto it = extension_map.find(ext);
653 if (it != extension_map.end()) {
661 const std::string& glsl_source,
662 vk::ShaderStageFlagBits stage,
663 const std::vector<std::string>& include_directories,
664 const std::unordered_map<std::string, std::string>& defines)
666#ifdef MAYAFLUX_USE_SHADERC
667 shaderc::Compiler compiler;
668 shaderc::CompileOptions options;
670 options.SetOptimizationLevel(shaderc_optimization_level_performance);
671 options.SetIncluder(std::make_unique<FileIncluder>(include_directories));
673 for (
const auto& [name, value] : defines) {
674 options.AddMacroDefinition(name, value);
677 shaderc_shader_kind shader_kind;
679 case vk::ShaderStageFlagBits::eVertex:
680 shader_kind = shaderc_glsl_vertex_shader;
682 case vk::ShaderStageFlagBits::eFragment:
683 shader_kind = shaderc_glsl_fragment_shader;
685 case vk::ShaderStageFlagBits::eCompute:
686 shader_kind = shaderc_glsl_compute_shader;
688 case vk::ShaderStageFlagBits::eGeometry:
689 shader_kind = shaderc_glsl_geometry_shader;
691 case vk::ShaderStageFlagBits::eTessellationControl:
692 shader_kind = shaderc_glsl_tess_control_shader;
694 case vk::ShaderStageFlagBits::eTessellationEvaluation:
695 shader_kind = shaderc_glsl_tess_evaluation_shader;
697 case vk::ShaderStageFlagBits::eMeshEXT:
698 shader_kind = shaderc_glsl_mesh_shader;
700 case vk::ShaderStageFlagBits::eTaskEXT:
701 shader_kind = shaderc_glsl_task_shader;
705 "Unsupported shader stage for GLSL compilation: {}", vk::to_string(stage));
709 shaderc::SpvCompilationResult result = compiler.CompileGlslToSpv(
715 if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
717 "GLSL compilation failed:\n{}", result.GetErrorMessage());
721 std::vector<uint32_t> spirv(result.cbegin(), result.cend());
724 "Compiled GLSL ({} stage) -> {} bytes SPIR-V",
725 vk::to_string(stage), spirv.size() * 4);
736 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
737 if (!file.is_open()) {
739 "Failed to open SPIR-V file: '{}'", filepath);
743 size_t file_size =
static_cast<size_t>(file.tellg());
744 if (file_size == 0) {
746 "SPIR-V file is empty: '{}'", filepath);
750 if (file_size %
sizeof(uint32_t) != 0) {
752 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
753 file_size, filepath);
757 std::vector<uint32_t> buffer(file_size /
sizeof(uint32_t));
759 file.read(
reinterpret_cast<char*
>(buffer.data()), file_size);
763 "Failed to read SPIR-V file: '{}'", filepath);
772 std::ifstream file(filepath);
773 if (!file.is_open()) {
775 "Failed to open file: '{}'", filepath);
780 (std::istreambuf_iterator<char>(file)),
781 std::istreambuf_iterator<char>());
783 if (content.empty()) {
785 "File is empty: '{}'", filepath);
791#ifndef MAYAFLUX_USE_SHADERC
793 bool is_command_available(
const std::string& command)
795#if defined(MAYAFLUX_PLATFORM_WINDOWS)
796 std::string check_cmd =
"where " + command +
" >nul 2>&1";
798 std::string check_cmd =
"command -v " + command +
" >/dev/null 2>&1";
800 return std::system(check_cmd.c_str()) == 0;
803 std::string get_null_device()
805#if defined(MAYAFLUX_PLATFORM_WINDOWS)
814 const std::string& glsl_source,
815 vk::ShaderStageFlagBits stage,
816 const std::vector<std::string>& include_directories,
817 const std::unordered_map<std::string, std::string>& defines)
819 namespace fs = std::filesystem;
821 if (!is_command_available(
"glslc")) {
823 "glslc compiler not found in PATH. Install Vulkan SDK or enable MAYAFLUX_USE_SHADERC");
827 fs::path temp_dir = fs::temp_directory_path();
828 fs::path glsl_temp = temp_dir /
"mayaflux_shader_temp.glsl";
829 fs::path spirv_temp = temp_dir /
"mayaflux_shader_temp.spv";
832 std::ofstream out(glsl_temp);
833 if (!out.is_open()) {
835 "Failed to create temporary GLSL file: '{}'", glsl_temp.string());
841 std::string stage_flag;
843 case vk::ShaderStageFlagBits::eVertex:
844 stage_flag =
"-fshader-stage=vertex";
846 case vk::ShaderStageFlagBits::eFragment:
847 stage_flag =
"-fshader-stage=fragment";
849 case vk::ShaderStageFlagBits::eCompute:
850 stage_flag =
"-fshader-stage=compute";
852 case vk::ShaderStageFlagBits::eGeometry:
853 stage_flag =
"-fshader-stage=geometry";
855 case vk::ShaderStageFlagBits::eTessellationControl:
856 stage_flag =
"-fshader-stage=tesscontrol";
858 case vk::ShaderStageFlagBits::eTessellationEvaluation:
859 stage_flag =
"-fshader-stage=tesseval";
861 case vk::ShaderStageFlagBits::eMeshEXT:
862 stage_flag =
"-fshader-stage=mesh";
864 case vk::ShaderStageFlagBits::eTaskEXT:
865 stage_flag =
"-fshader-stage=task";
869 "Unsupported shader stage for external compilation: {}", vk::to_string(stage));
870 fs::remove(glsl_temp);
874#if defined(MAYAFLUX_PLATFORM_WINDOWS)
875 std::string
cmd =
"glslc " + stage_flag +
" \"" + glsl_temp.string() +
"\" -o \"" + spirv_temp.string() +
"\"";
877 std::string
cmd =
"glslc " + stage_flag +
" '" + glsl_temp.string() +
"' -o '" + spirv_temp.string() +
"'";
880 for (
const auto& dir : include_directories) {
881#if defined(MAYAFLUX_PLATFORM_WINDOWS)
882 cmd +=
" -I\"" + dir +
"\"";
884 cmd +=
" -I'" + dir +
"'";
888 for (
const auto& [name, value] : defines) {
890 if (!value.empty()) {
895 std::string null_device = get_null_device();
898 "Invoking external glslc : {}",
cmd);
900 int result = std::system(
cmd.c_str());
902 fs::remove(glsl_temp);
906 "External glslc compilation failed (exit code: {})", result);
908 "Make sure Vulkan SDK is installed or enable MAYAFLUX_USE_SHADERC for runtime compilation");
909 fs::remove(spirv_temp);
915 fs::remove(spirv_temp);
917 if (!spirv_code.empty()) {
919 "Compiled GLSL ({} stage) via external glslc -> {} bytes SPIR-V",
920 vk::to_string(stage), spirv_code.size() * 4);
930 case vk::ShaderStageFlagBits::eCompute:
932 case vk::ShaderStageFlagBits::eVertex:
934 case vk::ShaderStageFlagBits::eFragment:
936 case vk::ShaderStageFlagBits::eGeometry:
938 case vk::ShaderStageFlagBits::eTessellationControl:
940 case vk::ShaderStageFlagBits::eTessellationEvaluation:
942 case vk::ShaderStageFlagBits::eMeshEXT:
944 case vk::ShaderStageFlagBits::eTaskEXT:
948 "Unknown shader stage: {}", vk::to_string(
m_stage));
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
Core::GlobalInputConfig input
const std::vector< std::string > & m_dirs
vk::SpecializationInfo m_specialization_info
bool create_from_glsl_file(vk::Device device, const std::string &glsl_path, std::optional< vk::ShaderStageFlagBits > stage=std::nullopt, const std::string &entry_point="main", bool enable_reflection=true, const std::vector< std::string > &include_directories={}, const std::unordered_map< std::string, std::string > &defines={})
Create shader module from GLSL file.
bool create_from_glsl(vk::Device device, const std::string &glsl_source, vk::ShaderStageFlagBits stage, const std::string &entry_point="main", bool enable_reflection=true, const std::vector< std::string > &include_directories={}, const std::unordered_map< std::string, std::string > &defines={})
Create shader module from GLSL source string.
static std::optional< vk::ShaderStageFlagBits > detect_stage_from_extension(const std::string &filepath)
Auto-detect shader stage from file extension.
bool reflect_spirv(const std::vector< uint32_t > &spirv_code)
Perform reflection on SPIR-V bytecode.
bool create_from_spirv(vk::Device device, const std::vector< uint32_t > &spirv_code, vk::ShaderStageFlagBits stage, const std::string &entry_point="main", bool enable_reflection=true)
Create shader module from SPIR-V binary.
vk::PipelineShaderStageCreateInfo get_stage_create_info() const
Get pipeline shader stage create info.
static std::vector< uint32_t > compile_glsl_to_spirv_external(const std::string &glsl_source, vk::ShaderStageFlagBits stage, const std::vector< std::string > &include_directories={}, const std::unordered_map< std::string, std::string > &defines={})
std::vector< vk::SpecializationMapEntry > m_specialization_entries
VKShaderModule & operator=(const VKShaderModule &)=delete
vk::ShaderStageFlagBits m_stage
bool create_from_spirv_file(vk::Device device, const std::string &spirv_path, vk::ShaderStageFlagBits stage, const std::string &entry_point="main", bool enable_reflection=true)
Create shader module from SPIR-V file.
void update_specialization_info()
Update specialization info from current map Called before get_stage_create_info() to ensure fresh dat...
std::vector< uint32_t > compile_glsl_to_spirv(const std::string &glsl_source, vk::ShaderStageFlagBits stage, const std::vector< std::string > &include_directories, const std::unordered_map< std::string, std::string > &defines)
Compile GLSL to SPIR-V using shaderc.
static std::string read_text_file(const std::string &filepath)
Read text file into string.
void set_specialization_constants(const std::unordered_map< uint32_t, uint32_t > &constants)
Set specialization constants.
ShaderReflection m_reflection
static std::vector< uint32_t > read_spirv_file(const std::string &filepath)
Read binary file into vector.
static vk::Format spirv_type_to_vk_format(const spirv_cross::SPIRType &type)
Convert SPIRV-Cross type to Vulkan vertex attribute format.
std::vector< uint32_t > m_specialization_data
vk::ShaderModule m_module
std::string m_entry_point
void cleanup(vk::Device device)
Cleanup shader module.
std::unordered_map< uint32_t, uint32_t > m_specialization_map
Stage get_stage_type() const
Get shader stage type.
std::vector< uint32_t > m_spirv_code
Preserved SPIR-V (if enabled)
Wrapper for Vulkan shader module with lifecycle and reflection.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.
std::string name
Variable name in shader.
vk::ShaderStageFlags stage
Stage visibility.
uint32_t set
Descriptor set index.
uint32_t count
Array size (1 for non-arrays)
uint32_t binding
Binding point within set.
vk::DescriptorType type
Type (uniform buffer, storage buffer, etc.)
uint32_t constant_id
Specialization constant ID.
std::string name
Variable name in shader.
uint32_t size
Size in bytes.
std::vector< SpecializationConstant > specialization_constants
std::vector< DescriptorBinding > bindings
std::vector< PushConstantRange > push_constants
std::vector< vk::VertexInputAttributeDescription > vertex_attributes
std::optional< std::array< uint32_t, 3 > > workgroup_size
local_size_x/y/z
Metadata extracted from shader module.