simvx.graphics.materials.shader_compiler¶
GLSL to SPIR-V compilation via glslc, with include resolution and optional reflection.
Module Contents¶
Functions¶
Recursively resolve |
|
Compile a GLSL file to SPIR-V using glslc. Returns the output path. |
|
Reflect a SPIR-V module. Uses spirv-cross if available, else returns empty. |
Data¶
API¶
- simvx.graphics.materials.shader_compiler.__all__¶
[‘compile_shader’, ‘resolve_includes’, ‘reflect_shader’]
- simvx.graphics.materials.shader_compiler.log¶
‘getLogger(…)’
- simvx.graphics.materials.shader_compiler.resolve_includes(source: str, base_dir: pathlib.Path, _seen: set[str] | None = None) str¶
Recursively resolve
#include "file.glsl"directives in GLSL source.Args: source: GLSL source text. base_dir: Directory to resolve relative include paths against. _seen: Internal set tracking already-included files to prevent cycles.
Returns: Processed GLSL source with all includes inlined.
Raises: FileNotFoundError: If an included file does not exist. RuntimeError: If a circular include is detected.
- simvx.graphics.materials.shader_compiler.compile_shader(src: pathlib.Path, out: pathlib.Path | None = None) pathlib.Path¶
Compile a GLSL file to SPIR-V using glslc. Returns the output path.
Provides improved error messages that include the source file path and annotated line numbers from glslc output.
Args: src: Path to the GLSL source file. out: Optional output path for the SPIR-V binary. Defaults to
src.spv.Returns: Path to the compiled SPIR-V file.
Raises: RuntimeError: If glslc compilation fails, with annotated error details.
- simvx.graphics.materials.shader_compiler.reflect_shader(spirv_path: pathlib.Path) dict¶
Reflect a SPIR-V module. Uses spirv-cross if available, else returns empty.