cidre/mtl/
intersection_function_table.rs1use crate::{arc, define_mtl, define_obj_type, mtl, ns, objc};
2
3#[derive(Debug, Copy, Clone, Eq, PartialEq)]
4#[repr(usize)]
5pub enum IntersectionFnSignature {
6 None = 0,
10
11 Instancing = (1 << 0),
16
17 TriangleData = (1 << 1),
22
23 WorldSpaceData = (1 << 2),
28
29 InstanceMotion = (1 << 3),
34
35 PrimitiveMotion = (1 << 4),
40
41 ExtendedLimits = (1 << 5),
46}
47
48define_obj_type!(pub Desc(ns::Id), MTL_INTERSECTION_FUNCTION_TABLE_DESCRIPTOR);
49
50impl Desc {
51 #[objc::msg_send(functionCount)]
53 pub fn fn_count(&self) -> usize;
54
55 #[objc::msg_send(setFunctionCount:)]
56 pub fn set_fn_count(&mut self, val: usize);
57}
58
59define_obj_type!(pub IntersectionFnTable(mtl::Res));
60
61impl IntersectionFnTable {
62 define_mtl!(gpu_res_id);
63
64 #[objc::msg_send(setBuffer:atIndex:)]
65 pub fn set_buf_at(&mut self, buf: Option<&mtl::Buf>, index: usize);
66
67 #[objc::msg_send(setBuffers:offsets:withRange:)]
68 pub fn set_bufs(
69 &mut self,
70 buffers: *const Option<&mtl::Buf>,
71 offsets: *const usize,
72 range: ns::Range,
73 );
74
75 #[objc::msg_send(setFunction:atIndex:)]
76 pub fn set_fn_at<H: mtl::FnHandle>(&mut self, function: Option<&H>, index: usize);
77
78 #[objc::msg_send(setFunctions:withRange:)]
79 pub fn set_fns_with_range<H: mtl::FnHandle>(
80 &mut self,
81 functions: *const Option<&H>,
82 range: ns::Range,
83 );
84
85 #[objc::msg_send(setOpaqueTriangleIntersectionFunctionWithSignature:atIndex:)]
86 pub fn set_opaque_triangle_intersection_fn_with_signature(
87 &mut self,
88 signature: mtl::IntersectionFnSignature,
89 index: usize,
90 );
91
92 #[objc::msg_send(setOpaqueTriangleIntersectionFunctionWithSignature:withRange:)]
93 pub fn set_opaque_triangle_intersection_fn_with_signature_with_range(
94 &mut self,
95 signature: mtl::IntersectionFnSignature,
96 range: ns::Range,
97 );
98
99 #[objc::msg_send(setVisibleFunctionTable:atBufferIndex:)]
100 pub fn set_visible_fn_table(
101 &mut self,
102 function_table: Option<&mtl::VisibleFnTable>,
103 buffer_index: usize,
104 );
105
106 #[objc::msg_send(setVisibleFunctionTables:withBufferRange:)]
107 pub fn set_visible_fn_tables(
108 &mut self,
109 function_tables: *const Option<&mtl::VisibleFnTable>,
110 buffer_range: ns::Range,
111 );
112}
113
114unsafe extern "C" {
115 static MTL_INTERSECTION_FUNCTION_TABLE_DESCRIPTOR: &'static objc::Class<Desc>;
116}