MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ create_from_glsl()

bool MayaFlux::Core::VKShaderModule::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.

Parameters
deviceLogical device
glsl_sourceGLSL source code
stageShader stage (determines compiler mode)
entry_pointEntry point function name
enable_reflectionExtract metadata
include_directoriesPaths for #include resolution
definesPreprocessor definitions (e.g., {"DEBUG", "MAX_LIGHTS=4"})
Returns
true if creation succeeded

Compiles GLSL → SPIR-V using shaderc, then calls create_from_spirv(). Requires shaderc library to be available.

Definition at line 208 of file VKShaderModule.cpp.

216{
217 auto spirv_code = compile_glsl_to_spirv(glsl_source, stage, include_directories, defines);
218 if (spirv_code.empty()) {
220 "Failed to compile GLSL to SPIR-V ({} stage)", vk::to_string(stage));
221 return false;
222 }
223
225 "Compiled GLSL to SPIR-V ({} stage, {} bytes)",
226 vk::to_string(stage), spirv_code.size() * 4);
227
228 return create_from_spirv(device, spirv_code, stage, entry_point, enable_reflection);
229}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
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.
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.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

References compile_glsl_to_spirv(), MayaFlux::Journal::Core, create_from_spirv(), MayaFlux::Journal::GraphicsBackend, MF_DEBUG, and MF_ERROR.

Referenced by create_from_glsl_file().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: