sgns::sgprocessing::ShaderCompiler¶
#include <shader_compiler.hpp>
Public Types¶
| Name | |
|---|---|
| enum class | Error |
Public Functions¶
| Name | |
|---|---|
| outcome::result< CompiledShaderStage > | CompileAndValidate(const std::vector< char > & source_bytes, sgns::Stage stage, sgns::ShaderSourceType type, const std::string & entry_point) |
Detailed Description¶
Standalone, Vulkan-device-free GLSL->SPIR-V compiler + mandatory SPIRV-Tools validation gate. No VkInstance/VkDevice/VkPhysicalDevice member anywhere – pure CPU-side text/bytecode transformation and validation, fully unit-testable in isolation from any Vulkan context.
Every code path – GLSL-compiled or directly-submitted SPIR-V – passes through spvtools::SpirvTools::Validate() before CompileAndValidate() can ever return success. shaderc's CompileGlslToSpv() does NOT run spirv-val internally; "shaderc compiled it" must never be conflated with "SPIRV-Tools validated it."
Public Types Documentation¶
enum Error¶
| Enumerator | Value | Description |
|---|---|---|
| COMPILE_FAILED | 1 | |
| VALIDATION_FAILED | 2 |
Public Functions Documentation¶
function CompileAndValidate¶
outcome::result< CompiledShaderStage > CompileAndValidate(
const std::vector< char > & source_bytes,
sgns::Stage stage,
sgns::ShaderSourceType type,
const std::string & entry_point
)
Parameters:
- source_bytes raw source bytes – GLSL text if type == GLSL, raw SPIR-V bytes if type == SPIRV
- stage which pipeline stage this shader targets
- type whether source_bytes is GLSL text or raw SPIR-V bytes
- entry_point the shader's entry point function name (only meaningful for the GLSL path)
Return: validated SPIR-V words + stage on success, or a structured Error on failure – never throws
Compile (if GLSL) and unconditionally validate a single shader stage's source bytes.
Updated on 2026-09-17 at 06:29:14 +0000