1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use objc2::{Encode, Encoding, RefEncode};
/// Signature defining what data is provided to an intersection function (from `MTLIntersectionFunctionSignature`).
///
/// Availability: macOS 11.0+, iOS 14.0+, tvOS 16.0+
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLIntersectionFunctionSignature(pub u64);
bitflags::bitflags! {
impl MTLIntersectionFunctionSignature: u64 {
/// Availability: macOS 11.0+, iOS 14.0+, tvOS 16.0+
const None = 0;
/// Intersection functions can read the built-in `instance_id`.
/// Availability: macOS 11.0+, iOS 14.0+, tvOS 16.0+
const Instancing = 1<<0;
/// Triangle intersection functions can read `barycentric_coord` and `front_facing`.
/// Availability: macOS 11.0+, iOS 14.0+, tvOS 16.0+
const TriangleData = 1<<1;
/// Intersection functions can query `world_space_origin` and `world_space_direction`.
/// Availability: macOS 11.0+, iOS 14.0+, tvOS 16.0+
const WorldSpaceData = 1<<2;
/// May be called from intersectors using the `instance_motion` tag.
/// Availability: macOS 12.0+, iOS 15.0+, tvOS 16.0+
const InstanceMotion = 1<<3;
/// Can query `time`, `motion_start_time`, `motion_end_time`, `key_frame_count`.
/// Availability: macOS 12.0+, iOS 15.0+, tvOS 16.0+
const PrimitiveMotion = 1<<4;
/// May be called from intersectors using the `extended_limits` tag.
/// Availability: macOS 12.0+, iOS 15.0+, tvOS 16.0+
const ExtendedLimits = 1<<5;
/// May be called from intersectors using the `max_levels` tag.
/// Availability: macOS 14.0+, iOS 17.0+
const MaxLevels = 1<<6;
/// Curve intersection functions can read `curve_parameter`.
/// Availability: macOS 14.0+, iOS 17.0+
const CurveData = 1<<7;
/// Intersection function will be used with intersection function buffers.
/// Availability: macOS 26.0+, iOS 26.0+
const IntersectionFunctionBuffer = 1<<8;
/// Intersection function uses the intersection function buffer `user_data` pointer.
/// Availability: macOS 26.0+, iOS 26.0+
const UserData = 1<<9;
}
}
unsafe impl Encode for MTLIntersectionFunctionSignature {
const ENCODING: Encoding = u64::ENCODING;
}
unsafe impl RefEncode for MTLIntersectionFunctionSignature {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(test)]
mod tests {
use super::MTLIntersectionFunctionSignature;
#[test]
fn signature_bits_match_the_xcode_27_header() {
assert_eq!(MTLIntersectionFunctionSignature::None.bits(), 0);
assert_eq!(MTLIntersectionFunctionSignature::Instancing.bits(), 1 << 0);
assert_eq!(MTLIntersectionFunctionSignature::TriangleData.bits(), 1 << 1);
assert_eq!(MTLIntersectionFunctionSignature::WorldSpaceData.bits(), 1 << 2);
assert_eq!(MTLIntersectionFunctionSignature::InstanceMotion.bits(), 1 << 3);
assert_eq!(MTLIntersectionFunctionSignature::PrimitiveMotion.bits(), 1 << 4);
assert_eq!(MTLIntersectionFunctionSignature::ExtendedLimits.bits(), 1 << 5);
assert_eq!(MTLIntersectionFunctionSignature::MaxLevels.bits(), 1 << 6);
assert_eq!(MTLIntersectionFunctionSignature::CurveData.bits(), 1 << 7);
assert_eq!(MTLIntersectionFunctionSignature::IntersectionFunctionBuffer.bits(), 1 << 8);
assert_eq!(MTLIntersectionFunctionSignature::UserData.bits(), 1 << 9);
}
}