Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: Disable default link feature on metal crate #21

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ targets = [
]

[dependencies]
metal = "0.29"
metal = { version = "0.29", default-features = false }
6 changes: 4 additions & 2 deletions runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[![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]).
[`saxaboom-runtime`] provides the runtime `repr(C)` definitions for structures and interop with the [`metal`] crate needed to make use of the `metallib` shaders generated by [`saxaboom`] (bindings for [Metal shader converter]).

## Usage

Expand All @@ -21,11 +21,13 @@ Add this to your `Cargo.toml`:
saxaboom-runtime = "0.1.0"
```

Example to create a descriptor to a buffer:

```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 metadata = IRDescriptorTableEntry::buffer_metadata(todo!("Fill saxaboom_runtime::BufferView"));
let buffer_descriptor = IRDescriptorTableEntry::buffer(gpu_address, metadata);
```

Expand Down
10 changes: 7 additions & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Contains `repr(C)` definitions for structures used at runtime.
#![doc = include_str!("../README.md")]

#[allow(
clippy::useless_transmute,
Expand Down Expand Up @@ -30,8 +30,12 @@ impl ffi::IRDescriptorTableEntry {
///
/// This function is a port of the `IRDescriptorTableSetBuffer` function in the `metal_irconverter_runtime.h` header.
/// See <https://developer.apple.com/metal/shader-converter/> for more info.
// TODO: The docs say "buffer view" for metadata: can we take a BufferView struct and set `Self::buffer_metadata()` instead?
// There are special constructors for atomic/counter buffers after all...
// TODO: This function seems to have no reason to exist, in favour of `buffer_view()` the
// `metadata` argument here needs to be constructed in the exact same way. However, for a
// full buffer descriptor, setting the metadata to `0` seems to be fine?
// TODO: The docs say "buffer view" for metadata: can we take a BufferView struct and set
// `Self::buffer_metadata()` instead? There are special constructors for atomic/counter buffers
// after all...
#[doc(alias = "IRDescriptorTableSetBuffer")]
pub fn buffer(gpu_address: u64, metadata: u64) -> Self {
Self {
Expand Down