7#include <shaderc/shaderc.hpp>
9#include <spirv-tools/libspirv.h>
10#include <spirv_cross/spirv_cross.hpp>
18 struct ShaderSearchPaths {
19 std::vector<std::string>
user;
23 ShaderSearchPaths get_shader_search_paths()
25 ShaderSearchPaths paths;
27#ifdef MAYAFLUX_PROJECT_SHADER_DIR
28 paths.user.emplace_back(MAYAFLUX_PROJECT_SHADER_DIR);
31 paths.user.insert(paths.user.end(),
32 {
"./shaders",
"./data/shaders",
"../shaders",
"../data/shaders",
"data/shaders" });
34 if (std::string_view(Config::SHADER_EXAMPLE_DIR).
length() > 0) {
35 paths.user.emplace_back(Config::SHADER_EXAMPLE_DIR);
39 Config::SHADER_BUILD_OUTPUT_DIR,
40 Config::SHADER_INSTALL_DIR,
41 Config::SHADER_SOURCE_DIR
47 std::string resolve_shader_path(
const std::string& filename)
49 namespace fs = std::filesystem;
51 if (fs::path(filename).is_absolute() || fs::exists(filename)) {
55 const auto paths = get_shader_search_paths();
58 for (
const auto& search_path : paths.
user) {
59 fs::path full_path = fs::path(search_path) / filename;
60 if (!fs::exists(full_path, ec)) {
64 for (
const auto& library_path : paths.
library) {
65 fs::path shadowed = fs::path(library_path) / filename;
66 if (fs::exists(shadowed, ec) && !fs::equivalent(full_path, shadowed, ec)) {
68 "Shader '{}' at '{}' shadows library shader '{}'",
69 filename, full_path.string(), shadowed.string());
75 "Resolved shader '{}' -> '{}'", filename, full_path.string());
76 return full_path.string();
79 for (
const auto& search_path : paths.
library) {
80 fs::path full_path = fs::path(search_path) / filename;
81 if (fs::exists(full_path, ec)) {
83 "Resolved shader '{}' -> '{}'", filename, full_path.string());
84 return full_path.string();
91 vk::DescriptorType spirv_to_vk_descriptor_type(spirv_cross::SPIRType::BaseType base_type,
92 const spirv_cross::SPIRType&
type,
95 if (
type.image.dim != spv::DimMax) {
96 if (
type.image.sampled == 2) {
97 return vk::DescriptorType::eStorageImage;
100 if (
type.image.sampled == 1) {
101 return is_storage ? vk::DescriptorType::eSampledImage
102 : vk::DescriptorType::eCombinedImageSampler;
107 return vk::DescriptorType::eStorageBuffer;
110 return vk::DescriptorType::eUniformBuffer;
113 class FileIncluder :
public shaderc::CompileOptions::IncluderInterface {
115 explicit FileIncluder(
const std::vector<std::string>& dirs)
120 shaderc_include_result* GetInclude(
121 const char* requested_source,
122 shaderc_include_type ,
126 namespace fs = std::filesystem;
127 auto* result =
new shaderc_include_result {};
129 for (
const auto& dir :
m_dirs) {
130 fs::path full = fs::path(dir) / requested_source;
131 if (fs::exists(full)) {
132 auto* container =
new std::string(full.string());
133 auto* content =
new std::string(read_file(full.string()));
134 result->source_name = container->c_str();
135 result->source_name_length = container->size();
136 result->content = content->c_str();
137 result->content_length = content->size();
138 result->user_data =
new std::pair<std::string*, std::string*>(container, content);
143 static const std::string err =
"include not found";
144 result->source_name =
"";
145 result->source_name_length = 0;
146 result->content = err.c_str();
147 result->content_length = err.size();
148 result->user_data =
nullptr;
152 void ReleaseInclude(shaderc_include_result* result)
override
154 if (result->user_data) {
155 auto* p =
static_cast<std::pair<std::string*, std::string*>*
>(result->user_data);
166 static std::string read_file(
const std::string& path)
168 std::ifstream f(path);
169 return { std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>() };
182 "VKShaderModule destroyed without cleanup() - potential leak");
187 : m_module(other.m_module)
188 , m_stage(other.m_stage)
189 , m_entry_point(std::move(other.m_entry_point))
190 , m_reflection(std::move(other.m_reflection))
191 , m_active_bindings(std::move(other.m_active_bindings))
192 , m_spirv_code(std::move(other.m_spirv_code))
193 , m_preserve_spirv(other.m_preserve_spirv)
194 , m_specialization_map(std::move(other.m_specialization_map))
195 , m_specialization_entries(std::move(other.m_specialization_entries))
196 , m_specialization_data(std::move(other.m_specialization_data))
197 , m_specialization_info(other.m_specialization_info)
199 other.m_module =
nullptr;
204 if (
this != &other) {
207 "VKShaderModule move-assigned without cleanup() - potential leak");
210 m_module = other.m_module;
211 m_stage = other.m_stage;
212 m_entry_point = std::move(other.m_entry_point);
213 m_reflection = std::move(other.m_reflection);
214 m_active_bindings = std::move(other.m_active_bindings);
215 m_spirv_code = std::move(other.m_spirv_code);
216 m_preserve_spirv = other.m_preserve_spirv;
217 m_specialization_map = std::move(other.m_specialization_map);
218 m_specialization_entries = std::move(other.m_specialization_entries);
219 m_specialization_data = std::move(other.m_specialization_data);
220 m_specialization_info = other.m_specialization_info;
222 other.m_module =
nullptr;
234 "Shader module cleaned up ({} stage)", vk::to_string(
m_stage));
251 const std::vector<uint32_t>& spirv_code,
252 vk::ShaderStageFlagBits stage,
253 const std::string& entry_point,
254 bool enable_reflection)
256 if (spirv_code.empty()) {
258 "Cannot create shader module from empty SPIR-V code");
262 if (spirv_code[0] != 0x07230203) {
264 "Invalid SPIR-V magic number: 0x{:08X} (expected 0x07230203)",
269 vk::ShaderModuleCreateInfo create_info;
270 create_info.codeSize = spirv_code.size() *
sizeof(uint32_t);
271 create_info.pCode = spirv_code.data();
275 }
catch (
const vk::SystemError& e) {
277 "Failed to create shader module: {}", e.what());
288 if (enable_reflection) {
291 "Shader reflection failed - descriptor layouts must be manually specified");
296 "Shader module created ({} stage, {} bytes SPIR-V, entry='{}')",
297 vk::to_string(stage), spirv_code.size() * 4, entry_point);
304 const std::string& spirv_path,
305 vk::ShaderStageFlagBits stage,
306 const std::string& entry_point,
307 bool enable_reflection)
309 std::string resolved_path = resolve_shader_path(spirv_path);
312 if (spirv_code.empty()) {
314 "Failed to read SPIR-V file: '{}'", spirv_path);
319 "Loaded SPIR-V from file: '{}'", spirv_path);
326 const std::string& spirv_asm,
327 vk::ShaderStageFlagBits stage,
328 const std::string& entry_point,
329 bool enable_reflection)
331 spv_context ctx = spvContextCreate(SPV_ENV_VULKAN_1_3);
332 spv_binary binary =
nullptr;
333 spv_diagnostic diag =
nullptr;
335 const spv_result_t result = spvTextToBinary(
342 if (result != SPV_SUCCESS) {
344 "SPIR-V assembly failed: {}",
345 (diag && diag->error) ? diag->error :
"unknown error");
346 spvDiagnosticDestroy(diag);
347 spvContextDestroy(ctx);
351 std::vector<uint32_t> words(binary->code, binary->code + binary->wordCount);
353 spvBinaryDestroy(binary);
354 spvDiagnosticDestroy(diag);
356 spv_const_binary_t bin { .code = words.data(), .wordCount = words.size() };
357 spv_diagnostic val_diag =
nullptr;
358 const spv_result_t val = spvValidate(ctx, &bin, &val_diag);
359 if (val != SPV_SUCCESS) {
361 "SPIR-V validation failed: {}",
362 (val_diag && val_diag->error) ? val_diag->error :
"unknown");
363 spvDiagnosticDestroy(val_diag);
364 spvContextDestroy(ctx);
367 spvDiagnosticDestroy(val_diag);
368 spvContextDestroy(ctx);
371 "Assembled and validated SPIR-V ({} words)", words.size());
382 const std::string& glsl_source,
383 vk::ShaderStageFlagBits stage,
384 const std::string& entry_point,
385 bool enable_reflection,
386 const std::vector<std::string>& include_directories,
387 const std::unordered_map<std::string, std::string>& defines)
390 if (spirv_code.empty()) {
392 "Failed to compile GLSL to SPIR-V ({} stage)", vk::to_string(stage));
397 "Compiled GLSL to SPIR-V ({} stage, {} bytes)",
398 vk::to_string(stage), spirv_code.size() * 4);
405 const std::string& glsl_path,
406 std::optional<vk::ShaderStageFlagBits> stage,
407 const std::string& entry_point,
408 bool enable_reflection,
409 const std::vector<std::string>& include_directories,
410 const std::unordered_map<std::string, std::string>& defines)
412 std::string resolved_path = resolve_shader_path(glsl_path);
414 if (!stage.has_value()) {
416 if (!stage.has_value()) {
418 "Cannot auto-detect shader stage from file extension: '{}'", glsl_path);
422 "Auto-detected {} stage from file extension", vk::to_string(*stage));
426 if (glsl_source.empty()) {
428 "Failed to read GLSL file: '{}'", glsl_path);
433 "Loaded GLSL from file: '{}' ({} bytes)", glsl_path, glsl_source.size());
436 enable_reflection, include_directories, defines);
447 "Cannot get stage create info from invalid shader module");
451 vk::PipelineShaderStageCreateInfo stage_info;
469 const std::unordered_map<uint32_t, uint32_t>& constants)
474 "Set {} specialization constants for {} stage",
475 constants.size(), vk::to_string(
m_stage));
495 vk::SpecializationMapEntry entry;
496 entry.constantID = constant_id;
498 entry.size =
sizeof(uint32_t);
502 offset +=
sizeof(uint32_t);
518 spirv_cross::Compiler compiler(spirv_code);
519 spirv_cross::ShaderResources resources = compiler.get_shader_resources();
521 auto reflect_resources = [&](
const spirv_cross::SmallVector<spirv_cross::Resource>& res_vec,
522 bool is_storage =
false) {
523 for (
const auto& resource : res_vec) {
525 desc.
set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
526 desc.
binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
528 desc.
name = resource.name;
530 const auto&
type = compiler.get_type(resource.type_id);
532 desc.
type = spirv_to_vk_descriptor_type(
type.basetype,
type, is_storage);
538 reflect_resources(resources.uniform_buffers,
false);
540 reflect_resources(resources.storage_buffers,
true);
542 reflect_resources(resources.sampled_images,
false);
544 reflect_resources(resources.storage_images,
true);
546 reflect_resources(resources.separate_images,
false);
547 reflect_resources(resources.separate_samplers,
false);
550 const spirv_cross::ShaderResources used = compiler.get_shader_resources(
551 compiler.get_active_interface_variables());
553 auto collect_active = [&](
const spirv_cross::SmallVector<spirv_cross::Resource>& res_vec,
555 for (
const auto& resource : res_vec) {
557 desc.
set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
558 desc.
binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
560 const std::string block_name = compiler.get_name(resource.base_type_id);
561 desc.
name = block_name.empty() ? resource.name : block_name;
563 const auto&
type = compiler.get_type(resource.type_id);
565 desc.
type = spirv_to_vk_descriptor_type(
type.basetype,
type, is_storage);
571 collect_active(used.uniform_buffers,
false);
572 collect_active(used.storage_buffers,
true);
573 collect_active(used.sampled_images,
false);
574 collect_active(used.storage_images,
true);
575 collect_active(used.separate_images,
false);
576 collect_active(used.separate_samplers,
false);
577 }
catch (
const std::exception& e) {
580 "Active descriptor binding analysis failed: {}", e.what());
588 for (
const auto& pc_buffer : resources.push_constant_buffers) {
589 const auto&
type = compiler.get_type(pc_buffer.type_id);
594 range.size =
static_cast<uint32_t
>(compiler.get_declared_struct_size(
type));
604 auto spec_constants = compiler.get_specialization_constants();
605 for (
const auto& spec : spec_constants) {
608 sc.
name = compiler.get_name(spec.id);
610 const auto&
type = compiler.get_type(compiler.get_constant(spec.id).constant_type);
611 sc.
size =
type.basetype == spirv_cross::SPIRType::Boolean
612 ?
static_cast<uint32_t
>(
sizeof(vk::Bool32))
620 "Reflected {} specialization constants",
624 if (
m_stage == vk::ShaderStageFlagBits::eCompute
625 ||
m_stage == vk::ShaderStageFlagBits::eMeshEXT
626 ||
m_stage == vk::ShaderStageFlagBits::eTaskEXT) {
627 auto entry_points = compiler.get_entry_points_and_stages();
629 for (
const auto& ep : entry_points) {
630 if (ep.name ==
m_entry_point && ep.execution_model == spv::ExecutionModelGLCompute) {
632 std::array<uint32_t, 3> workgroup_size {
633 compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 0),
634 compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 1),
635 compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 2)
638 if (!workgroup_size.empty() && workgroup_size.size() >= 3) {
646 "Compute shader workgroup size: [{}, {}, {}]",
647 workgroup_size[0], workgroup_size[1], workgroup_size[2]);
654 if (
m_stage == vk::ShaderStageFlagBits::eVertex) {
655 for (
const auto&
input : resources.stage_inputs) {
656 uint32_t location = compiler.get_decoration(
input.id, spv::DecorationLocation);
657 const auto&
type = compiler.get_type(
input.type_id);
659 vk::VertexInputAttributeDescription attr;
660 attr.location = location;
670 "Reflected {} vertex input attributes",
677 }
catch (
const spirv_cross::CompilerError& e) {
679 "SPIRV-Cross reflection failed: {}", e.what());
686 using BaseType = spirv_cross::SPIRType::BaseType;
688 if (
type.columns > 1) {
690 "Matrix types are not valid vertex attributes (columns={})",
692 return vk::Format::eUndefined;
695 if (
type.width != 32) {
697 "Unsupported SPIR-V vertex attribute width {} (only 32-bit supported)",
699 return vk::Format::eUndefined;
702 const uint32_t vec_size =
type.vecsize;
703 if (
type.basetype == BaseType::Float) {
706 return vk::Format::eR32Sfloat;
708 return vk::Format::eR32G32Sfloat;
710 return vk::Format::eR32G32B32Sfloat;
712 return vk::Format::eR32G32B32A32Sfloat;
714 }
else if (
type.basetype == BaseType::Int) {
717 return vk::Format::eR32Sint;
719 return vk::Format::eR32G32Sint;
721 return vk::Format::eR32G32B32Sint;
723 return vk::Format::eR32G32B32A32Sint;
725 }
else if (
type.basetype == BaseType::UInt) {
728 return vk::Format::eR32Uint;
730 return vk::Format::eR32G32Uint;
732 return vk::Format::eR32G32B32Uint;
734 return vk::Format::eR32G32B32A32Uint;
739 "Unsupported SPIR-V vertex attribute type (basetype={}, vecsize={})",
740 static_cast<int>(
type.basetype), vec_size);
742 return vk::Format::eUndefined;
750 const std::string& filepath)
752 std::filesystem::path path(filepath);
753 std::string ext = path.extension().string();
755 std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
757 static const std::unordered_map<std::string, vk::ShaderStageFlagBits> extension_map = {
758 {
".comp", vk::ShaderStageFlagBits::eCompute },
759 {
".vert", vk::ShaderStageFlagBits::eVertex },
760 {
".frag", vk::ShaderStageFlagBits::eFragment },
761 {
".geom", vk::ShaderStageFlagBits::eGeometry },
762 {
".tesc", vk::ShaderStageFlagBits::eTessellationControl },
763 {
".tese", vk::ShaderStageFlagBits::eTessellationEvaluation },
764 {
".rgen", vk::ShaderStageFlagBits::eRaygenKHR },
765 {
".rint", vk::ShaderStageFlagBits::eIntersectionKHR },
766 {
".rahit", vk::ShaderStageFlagBits::eAnyHitKHR },
767 {
".rchit", vk::ShaderStageFlagBits::eClosestHitKHR },
768 {
".rmiss", vk::ShaderStageFlagBits::eMissKHR },
769 {
".rcall", vk::ShaderStageFlagBits::eCallableKHR },
770 {
".mesh", vk::ShaderStageFlagBits::eMeshEXT },
771 {
".task", vk::ShaderStageFlagBits::eTaskEXT }
774 auto it = extension_map.find(ext);
775 if (it != extension_map.end()) {
783 const std::string& glsl_source,
784 vk::ShaderStageFlagBits stage,
785 const std::vector<std::string>& include_directories,
786 const std::unordered_map<std::string, std::string>& defines)
788 shaderc::Compiler compiler;
789 shaderc::CompileOptions options;
791 options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_3);
792 options.SetTargetSpirv(shaderc_spirv_version_1_6);
793 options.SetOptimizationLevel(shaderc_optimization_level_performance);
794 options.SetIncluder(std::make_unique<FileIncluder>(include_directories));
796 for (
const auto& [
name,
value] : defines) {
800 shaderc_shader_kind shader_kind;
802 case vk::ShaderStageFlagBits::eVertex:
803 shader_kind = shaderc_glsl_vertex_shader;
805 case vk::ShaderStageFlagBits::eFragment:
806 shader_kind = shaderc_glsl_fragment_shader;
808 case vk::ShaderStageFlagBits::eCompute:
809 shader_kind = shaderc_glsl_compute_shader;
811 case vk::ShaderStageFlagBits::eGeometry:
812 shader_kind = shaderc_glsl_geometry_shader;
814 case vk::ShaderStageFlagBits::eTessellationControl:
815 shader_kind = shaderc_glsl_tess_control_shader;
817 case vk::ShaderStageFlagBits::eTessellationEvaluation:
818 shader_kind = shaderc_glsl_tess_evaluation_shader;
820 case vk::ShaderStageFlagBits::eMeshEXT:
821 shader_kind = shaderc_glsl_mesh_shader;
823 case vk::ShaderStageFlagBits::eTaskEXT:
824 shader_kind = shaderc_glsl_task_shader;
828 "Unsupported shader stage for GLSL compilation: {}", vk::to_string(stage));
832 shaderc::SpvCompilationResult result = compiler.CompileGlslToSpv(
838 if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
840 "GLSL compilation failed:\n{}", result.GetErrorMessage());
844 std::vector<uint32_t> spirv(result.cbegin(), result.cend());
847 "Compiled GLSL ({} stage) -> {} bytes SPIR-V",
848 vk::to_string(stage), spirv.size() * 4);
855 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
856 if (!file.is_open()) {
858 "Failed to open SPIR-V file: '{}'", filepath);
862 size_t file_size =
static_cast<size_t>(file.tellg());
863 if (file_size == 0) {
865 "SPIR-V file is empty: '{}'", filepath);
869 if (file_size %
sizeof(uint32_t) != 0) {
871 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
872 file_size, filepath);
876 std::vector<uint32_t>
buffer(file_size /
sizeof(uint32_t));
878 file.read(
reinterpret_cast<char*
>(
buffer.data()), file_size);
882 "Failed to read SPIR-V file: '{}'", filepath);
891 std::ifstream file(filepath);
892 if (!file.is_open()) {
894 "Failed to open file: '{}'", filepath);
899 (std::istreambuf_iterator<char>(file)),
900 std::istreambuf_iterator<char>());
902 if (content.empty()) {
904 "File is empty: '{}'", filepath);
913 case vk::ShaderStageFlagBits::eCompute:
915 case vk::ShaderStageFlagBits::eVertex:
917 case vk::ShaderStageFlagBits::eFragment:
919 case vk::ShaderStageFlagBits::eGeometry:
921 case vk::ShaderStageFlagBits::eTessellationControl:
923 case vk::ShaderStageFlagBits::eTessellationEvaluation:
925 case vk::ShaderStageFlagBits::eMeshEXT:
927 case vk::ShaderStageFlagBits::eTaskEXT:
931 "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
std::shared_ptr< NetworkGeometryBuffer > buffer
vk::PhysicalDevice device
vk::PhysicalDeviceType type
std::vector< std::string > library
std::vector< std::string > user
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.
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.
bool create_from_spirv_asm(vk::Device device, const std::string &spirv_asm, vk::ShaderStageFlagBits stage, const std::string &entry_point="main", bool enable_reflection=true)
Create shader module from SPIR-V assembly text.
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
std::vector< ShaderReflection::DescriptorBinding > m_active_bindings
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.