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

◆ create_from_glsl_file()

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

Parameters
deviceLogical device
glsl_pathPath to .comp/.vert/.frag/.geom file
stageShader stage (auto-detected from extension if not specified)
entry_pointEntry point function name
enable_reflectionExtract metadata
include_directoriesPaths for #include resolution
definesPreprocessor definitions
Returns
true if creation succeeded

Reads file, compiles GLSL → SPIR-V, calls create_from_spirv(). Stage auto-detection: .comp → Compute .vert → Vertex .frag → Fragment .geom → Geometry .tesc → Tessellation Control .tese → Tessellation Evaluation

Definition at line 231 of file VKShaderModule.cpp.

239{
240 std::string resolved_path = resolve_shader_path(glsl_path);
241
242 if (!stage.has_value()) {
243 stage = detect_stage_from_extension(glsl_path);
244 if (!stage.has_value()) {
246 "Cannot auto-detect shader stage from file extension: '{}'", glsl_path);
247 return false;
248 }
250 "Auto-detected {} stage from file extension", vk::to_string(*stage));
251 }
252
253 auto glsl_source = read_text_file(resolved_path);
254 if (glsl_source.empty()) {
256 "Failed to read GLSL file: '{}'", glsl_path);
257 return false;
258 }
259
261 "Loaded GLSL from file: '{}' ({} bytes)", glsl_path, glsl_source.size());
262
263 return create_from_glsl(device, glsl_source, *stage, entry_point,
264 enable_reflection, include_directories, defines);
265}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
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.
static std::string read_text_file(const std::string &filepath)
Read text file into string.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, create_from_glsl(), detect_stage_from_extension(), MayaFlux::Journal::GraphicsBackend, MF_DEBUG, MF_ERROR, and read_text_file().

+ Here is the call graph for this function: