Skip to content

Commit

Permalink
Merge #3775
Browse files Browse the repository at this point in the history
3775: expose the underlying metal device r=kvark a=ccbrown

This facilitates the ability to lock and utilize the underlying Metal device directly.

My need is very similar to the one described in #3698, in which it was mentioned that functionality like this could be added to the individual backends and that PRs were appreciated.

PR checklist:
- [x] `make` succeeds (on *nix)
- [x] `make reftests` succeeds
- [x] tested examples with the following backends:


Co-authored-by: Chris Brown <[email protected]>
  • Loading branch information
bors[bot] and ccbrown authored Jun 17, 2021
2 parents 0a0cdaa + 352530b commit edbee4c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/backend/metal/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use objc::{
rc::autoreleasepool,
runtime::{Object, BOOL, NO},
};
use parking_lot::Mutex;
use parking_lot::{Mutex, MutexGuard};

use std::collections::BTreeMap;
#[cfg(feature = "pipeline-cache")]
Expand Down Expand Up @@ -592,6 +592,11 @@ impl LanguageVersion {
}

impl Device {
/// Provides access to the underlying Metal device.
pub fn lock(&self) -> MutexGuard<'_, metal::Device> {
self.shared.device.lock()
}

fn _is_heap_coherent(&self, heap: &n::MemoryHeap) -> bool {
match *heap {
n::MemoryHeap::Private => false,
Expand Down

0 comments on commit edbee4c

Please sign in to comment.