From ef768ff9d742ae6a0f4e83ddc8031264e7d460c4 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 13 Jul 2024 22:35:16 +0200 Subject: [PATCH] sampler: Add missing `gpu_resource_id()` getter 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 --- src/sampler.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sampler.rs b/src/sampler.rs index e9f6416..c93f652 100644 --- a/src/sampler.rs +++ b/src/sampler.rs @@ -5,7 +5,7 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use super::{depthstencil::MTLCompareFunction, DeviceRef, NSUInteger}; +use super::{depthstencil::MTLCompareFunction, DeviceRef, MTLResourceID, NSUInteger}; /// See #[repr(u64)] @@ -158,4 +158,8 @@ impl SamplerStateRef { crate::nsstring_as_str(label) } } + + pub fn gpu_resource_id(&self) -> MTLResourceID { + unsafe { msg_send![self, gpuResourceID] } + } }