shdrlib 0.2.0

High-level shader compilation and rendering library built on wgpu and naga
Documentation
use crate::front::compiler::{IR, Language};

#[derive(Clone)]
pub struct ShaderObject {
    pub ir: IR,
    pub spirv_binary: Vec<u32>,
    pub is_spirv: bool,
}

impl ShaderObject {
    /// Creates a ShaderObject from a compiled IR and, optionally, a SPIR-V binary.
    /// 
    /// Note: The original 'language' and 'metadata' are derived from the 'ir'.
    pub fn new(ir: IR, spirv_binary: Vec<u32>) -> Self {
        // We check the language from the IR's metadata
        let is_spirv = matches!(ir.metadata.language, Language::SPIRV);

        ShaderObject {
            ir,
            spirv_binary,
            is_spirv,
        }
    }
}