Skip to content

Commit

Permalink
sampler: Add missing gpu_resource_id() getter
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
  • Loading branch information
MarijnS95 authored and kvark committed Nov 24, 2024
1 parent 658d7d2 commit ef768ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://developer.apple.com/documentation/metal/mtlsamplerminmagfilter>
#[repr(u64)]
Expand Down Expand Up @@ -158,4 +158,8 @@ impl SamplerStateRef {
crate::nsstring_as_str(label)
}
}

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

0 comments on commit ef768ff

Please sign in to comment.