-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce number of
crates.io
keywords and improve README (#20)
crates.io refuses crates with >5 keywords (we had 6). Also improve the readme slightly, which was and still is very light (i.e. no code example showing how to use `saxaboom` and `saxaboom-runtime`).
- Loading branch information
Showing
7 changed files
with
137 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Contributing to this repository | ||
|
||
Useful steps to work on the source code and generated bindings in this repository. | ||
|
||
## Regenerating Bindings | ||
|
||
This crate contains bindings generated by `bindgen`. Typically, the included bindings can be used as-is, but if needed they can be regenerated by running `cargo run -p bindings_generator`. Updated headers and licenses should be copied to the `./bindings_generator/vendor/` folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,56 @@ | ||
# 🤘 Saxaboom | ||
|
||
[![Actions Status](https://github.com/Traverse-Research/saxaboom/actions/workflows/ci.yml/badge.svg)](https://github.com/Traverse-Research/saxaboom/actions) | ||
[![Latest version](https://img.shields.io/crates/v/saxaboom.svg?logo=rust)](https://crates.io/crates/saxaboom) | ||
[![Documentation](https://docs.rs/saxaboom/badge.svg)](https://docs.rs/saxaboom) | ||
[![Lines of code](https://tokei.rs/b1/github/Traverse-Research/saxaboom)](https://github.com/Traverse-Research/saxaboom) | ||
![MIT](https://img.shields.io/badge/license-MIT-blue.svg) | ||
[![Latest version](https://img.shields.io/crates/v/saxaboom.svg?logo=rust)][`saxaboom`] | ||
[![Documentation](https://img.shields.io/docsrs/saxaboom/latest?logo=docs.rs)](https://docs.rs/saxaboom) | ||
![Apache](https://img.shields.io/badge/license-Apache-blue.svg) | ||
[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4%20adopted-ff69b4.svg)](./CODE_OF_CONDUCT.md) | ||
|
||
[![Banner](banner.png)](https://traverseresearch.nl) | ||
|
||
Small helper library around [Metal shader converter] to create metal shader libraries from DXIL files. | ||
|
||
[Metal shader converter]: https://developer.apple.com/metal/shader-converter/ | ||
[`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: | ||
Add this to your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
saxaboom = "0.1.0" | ||
``` | ||
|
||
```rust | ||
// A code example | ||
Example to compile `DXIL` to `metallib`: | ||
|
||
```rust,no_run | ||
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(()) | ||
} | ||
``` | ||
## Regenerating Bindings | ||
|
||
This crate contains bindings generated by `bindgen`. Typically, the included bindings can be used as-is, but if needed | ||
they can be regenerated by running `cargo run -p bindings_generator`. | ||
For using the loaded `metallib` shaders at runtime most effectively, consult [`saxaboom-runtime`]. | ||
|
||
[Metal shader converter]: https://developer.apple.com/metal/shader-converter/ | ||
[`saxaboom`]: https://crates.io/crates/saxaboom | ||
[`saxaboom-runtime`]: https://crates.io/crates/saxaboom-runtime | ||
[`metal`]: https://crates.io/crates/metal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 🤘 Saxaboom runtime | ||
|
||
[![Actions Status](https://github.com/Traverse-Research/saxaboom/actions/workflows/ci.yml/badge.svg)](https://github.com/Traverse-Research/saxaboom/actions) | ||
[![Latest version](https://img.shields.io/crates/v/saxaboom-runtime.svg?logo=rust)][`saxaboom-runtime`] | ||
[![Documentation](https://img.shields.io/docsrs/saxaboom-runtime/latest?logo=docs.rs)](https://docs.rs/saxaboom-runtime) | ||
![Apache](https://img.shields.io/badge/license-Apache-blue.svg) | ||
[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4%20adopted-ff69b4.svg)](../CODE_OF_CONDUCT.md) | ||
|
||
[![Banner](../banner.png)](https://traverseresearch.nl) | ||
|
||
[`saxaboom-runtime`] provides the runtime structures and interop with the [`metal`] crate needed to make use of the `metallib` shaders generated by [`saxaboom`] (bindings for [Metal shader converter]). | ||
|
||
## Usage | ||
|
||
After compiling your `DXIL` shaders to `metallib` using [`saxaboom`], follow these steps in your render backend. | ||
|
||
Add this to your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
saxaboom-runtime = "0.1.0" | ||
``` | ||
|
||
```rust,no_run | ||
use saxaboom_runtime::ffi::IRDescriptorTableEntry; | ||
let gpu_address = 0; // TODO: Read from metal::Buffer::gpu_address() | ||
let metadata = IRDescriptorTableEntry::buffer_metadata(&todo!("Fill saxaboom_runtime::BufferView")); | ||
let buffer_descriptor = IRDescriptorTableEntry::buffer(gpu_address, metadata); | ||
``` | ||
|
||
[Metal shader converter]: https://developer.apple.com/metal/shader-converter/ | ||
[`saxaboom`]: https://crates.io/crates/saxaboom | ||
[`saxaboom-runtime`]: https://crates.io/crates/saxaboom-runtime | ||
[`metal`]: https://crates.io/crates/metal |