Skip to content

Small helper library around the `metal_irconverter` to create metal shader libraries from DXIL files.

License

Notifications You must be signed in to change notification settings

Traverse-Research/saxaboom

Repository files navigation

🤘 Saxaboom

Actions Status Latest version Documentation Apache Contributor Covenant

Banner

saxaboom is a small helper library around Metal shader converter to create metal shader libraries from DXIL files (HLSL source code). See also saxaboom-runtime which provides the runtime structures and interop with the metal crate needed to make use of the resulting metallib shaders.

Usage

Add this to your Cargo.toml:

[dependencies]
saxaboom = "0.2.0-beta.1"

Example to compile DXIL to metallib:

use saxaboom::{ffi, MetalIrConverter};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load the library
    let metal_irconverter = MetalIrConverter::new("libmetalirconverter.dylib").unwrap();
    // Create an instance of IRCompiler
    let mut compiler = metal_irconverter.create_compiler();
    // Create an object containing DXIL bytes, replace &[0u8] with your DXIL data
    let dxil = metal_irconverter.create_object_from_dxil(&[0u8]);

    // See `IRCompiler` docs for possible state that can be set on the compiler before compiling
    // DXIL source, such as a global root signatures and various raytracing parameters.

    // Compile the `dxil` data blob with entrypoint `main` into mtllib
    let mtllib = compiler.alloc_compile_and_link(c"main", &dxil)?;

    let reflection = mtllib.reflection();
    let mtl_binary = mtllib
        .metal_lib_binary()
        .expect("Compiled object should contain a `metallib`");
    let bytecode = mtl_binary.byte_code();

    Ok(())
}

For using the loaded metallib shaders at runtime most effectively, consult saxaboom-runtime.

About

Small helper library around the `metal_irconverter` to create metal shader libraries from DXIL files.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy