Skip to content

Commit

Permalink
sampler: Add missing gpu_resource_id() getter and set_label() setter
Browse files Browse the repository at this point in the history
According to the upstream docs and the Metal Shader Converter
implementation the `SamplerState` type has a way to get access to its
`MTLResourceID` on the GPU:
https://developer.apple.com/documentation/metal/mtlsamplerstate/3974101-gpuresourceid

And if other Metal types in this crate are to be believed, the label is
settable to be able to assign an identifier to it in the first place.
  • Loading branch information
MarijnS95 committed Jul 13, 2024
1 parent 864417d commit 9d00e40
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,15 @@ impl SamplerStateRef {
crate::nsstring_as_str(label)
}
}

pub fn set_label(&self, label: &str) {
unsafe {
let nslabel = crate::nsstring_from_str(label);
let () = msg_send![self, setLabel: nslabel];
}
}

pub fn gpu_resource_id(&self) -> MTLResourceID {
unsafe { msg_send![self, gpuResourceID] }
}
}

0 comments on commit 9d00e40

Please sign in to comment.