Sign in

    moon_wgsl

    User-facing facade for WGSL preprocess and composer utilities aligned with naga_oil.

    wgsl
    shader
    Download zip
    Author
    Version
    0.15.3
    License
    Apache-2.0
    Last updated
    3 months ago
    Downloads
    438

    #Milky2018/moon_wgsl

    Thin user-facing facade for WGSL preprocessing and composition.

    Install this module when your application wants naga-oil-style shader preprocessing without importing internal parser, IR, writer, or rewrite packages directly.

    The facade depends on:

    • Milky2018/wgsl for WGSL parsing, IR, and validation
    • Milky2018/moon_wgsl_naga_oil for preprocessing and composition

    Legacy internal package paths from the old single-module layout are not preserved. Import lower-level modules explicitly when you need their ownership boundary.

    ///|
    test "compose a shader through the facade" {
    let composer = Composer::default()
    let util_source =
    #|#define_import_path test::util
    #|
    #|fn value() -> u32 {
    #| return 1u;
    #|}
    #|
    composer.register_source("util.wgsl", util_source)
    let root_source =
    #|#import test::util::value
    #|
    #|fn root() -> u32 {
    #| return value();
    #|}
    #|
    composer.register_source("root.wgsl", root_source)
    let source = composer.compose_wgsl("root.wgsl", WgslComposeOptions::default())
    assert_true(source.contains("fn root"))
    }

    ComposableModuleDescriptor

    ImportDefWithOffset

    ImportDefinition

    PreparedWgslSource

    PreprocessOutput

    PreprocessorMetaData

    ShaderDefValue

    WgslComposeOptions

    WgslDiagnostic

    WgslDiagnosticSeverity

    WgslDirectives

    WgslExportOptions

    WgslExportOutput

    WgslSourceCatalogEntry

    WgslSourceFile

    WgslSourceMapEntry

    WgslSourceOriginEntry

    WgslSourceOriginKind

    WgslSourceScanOptions

    WgslSymbolRedirect

    apply_wgsl_ifdefs_strict

    fn apply_wgsl_ifdefs_strict(source : String, shader_defs : Map[String,
    ShaderDefValue
    ]) -> String raise
    PreprocessError

    apply_wgsl_template_consts

    fn apply_wgsl_template_consts(source : String, value_defines : Map[String,
    ShaderDefValue
    ]) -> String

    collect_wgsl_source_local_shader_defines

    fn collect_wgsl_source_local_shader_defines(source : String) -> Map[String,
    ShaderDefValue
    ]

    default_shader_rel_path_for_module_path

    fn default_shader_rel_path_for_module_path(module_path : String) -> String

    default_wgsl_value_defines

    fn default_wgsl_value_defines() -> Map[String,
    ShaderDefValue
    ]

    get_preprocessor_metadata

    fn get_preprocessor_metadata(source : String, allow_defines? : Bool, collect_import_uses? : Bool) ->
    PreprocessorMetaData
    raise
    MetadataError

    normalize_shader_rel_path

    fn normalize_shader_rel_path(rel : String) -> String

    wgsl_source_define_import_path

    fn wgsl_source_define_import_path(source : String) -> String?

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io