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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
use objc2::{
extern_class, extern_conformance, extern_methods,
rc::{Allocated, Retained},
};
use objc2_foundation::{CopyingHelper, NSCopying, NSObject, NSObjectProtocol};
use crate::*;
extern_class!(
/// Describes a compute pipeline state.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4computepipelinedescriptor?language=objc)
#[unsafe(super(MTL4PipelineDescriptor, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTL4ComputePipelineDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTL4ComputePipelineDescriptor {}
);
unsafe impl CopyingHelper for MTL4ComputePipelineDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTL4ComputePipelineDescriptor {}
);
impl MTL4ComputePipelineDescriptor {
extern_methods!(
/// A descriptor representing the compute pipeline's function.
///
/// You don't assign instances of ``MTL4FunctionDescriptor`` to this property directly, instead
/// assign an instance of one of its subclasses, such as ``MTL4LibraryFunctionDescriptor``, which
/// represents a function from a Metal library.
#[unsafe(method(computeFunctionDescriptor))]
#[unsafe(method_family = none)]
pub fn compute_function_descriptor(&self) -> Option<Retained<MTL4FunctionDescriptor>>;
/// Setter for [`computeFunctionDescriptor`][Self::computeFunctionDescriptor].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setComputeFunctionDescriptor:))]
#[unsafe(method_family = none)]
pub fn set_compute_function_descriptor(
&self,
compute_function_descriptor: Option<&MTL4FunctionDescriptor>,
);
/// A boolean value indicating whether each dimension of the threadgroup size is a multiple of its
/// corresponding thread execution width.
#[unsafe(method(threadGroupSizeIsMultipleOfThreadExecutionWidth))]
#[unsafe(method_family = none)]
pub fn thread_group_size_is_multiple_of_thread_execution_width(&self) -> bool;
/// Setter for [`threadGroupSizeIsMultipleOfThreadExecutionWidth`][Self::threadGroupSizeIsMultipleOfThreadExecutionWidth].
#[unsafe(method(setThreadGroupSizeIsMultipleOfThreadExecutionWidth:))]
#[unsafe(method_family = none)]
pub fn set_thread_group_size_is_multiple_of_thread_execution_width(
&self,
thread_group_size_is_multiple_of_thread_execution_width: bool,
);
/// The maximum total number of threads that Metal can execute in a single threadgroup for the
/// compute function.
#[unsafe(method(maxTotalThreadsPerThreadgroup))]
#[unsafe(method_family = none)]
pub fn max_total_threads_per_threadgroup(&self) -> usize;
/// Setter for [`maxTotalThreadsPerThreadgroup`][Self::maxTotalThreadsPerThreadgroup].
#[unsafe(method(setMaxTotalThreadsPerThreadgroup:))]
#[unsafe(method_family = none)]
pub fn set_max_total_threads_per_threadgroup(
&self,
max_total_threads_per_threadgroup: usize,
);
/// The required number of threads per threadgroup for compute dispatches.
///
/// When you set this value, you are responsible for ensuring that the `threadsPerThreadgroup` argument of any compute
/// dispatch matches it.
///
/// Setting this property is optional, except in cases where the pipeline uses *CooperativeTensors*.
///
/// This property's default value is `0`, which disables its effect.
#[unsafe(method(requiredThreadsPerThreadgroup))]
#[unsafe(method_family = none)]
pub fn required_threads_per_threadgroup(&self) -> MTLSize;
/// Setter for [`requiredThreadsPerThreadgroup`][Self::requiredThreadsPerThreadgroup].
#[unsafe(method(setRequiredThreadsPerThreadgroup:))]
#[unsafe(method_family = none)]
pub fn set_required_threads_per_threadgroup(
&self,
required_threads_per_threadgroup: MTLSize,
);
/// A boolean value indicating whether the compute pipeline supports linking binary functions.
#[unsafe(method(supportBinaryLinking))]
#[unsafe(method_family = none)]
pub fn support_binary_linking(&self) -> bool;
/// Setter for [`supportBinaryLinking`][Self::supportBinaryLinking].
#[unsafe(method(setSupportBinaryLinking:))]
#[unsafe(method_family = none)]
pub fn set_support_binary_linking(
&self,
support_binary_linking: bool,
);
/// An object that contains information about functions to link to the compute pipeline.
#[unsafe(method(staticLinkingDescriptor))]
#[unsafe(method_family = none)]
pub fn static_linking_descriptor(&self) -> Option<Retained<MTL4StaticLinkingDescriptor>>;
/// Setter for [`staticLinkingDescriptor`][Self::staticLinkingDescriptor].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setStaticLinkingDescriptor:))]
#[unsafe(method_family = none)]
pub fn set_static_linking_descriptor(
&self,
static_linking_descriptor: Option<&MTL4StaticLinkingDescriptor>,
);
/// A value indicating whether the pipeline supports Metal indirect command buffers.
#[unsafe(method(supportIndirectCommandBuffers))]
#[unsafe(method_family = none)]
pub fn support_indirect_command_buffers(&self) -> MTL4IndirectCommandBufferSupportState;
/// Setter for [`supportIndirectCommandBuffers`][Self::supportIndirectCommandBuffers].
#[unsafe(method(setSupportIndirectCommandBuffers:))]
#[unsafe(method_family = none)]
pub fn set_support_indirect_command_buffers(
&self,
support_indirect_command_buffers: MTL4IndirectCommandBufferSupportState,
);
/// Resets the descriptor to its default values.
#[unsafe(method(reset))]
#[unsafe(method_family = none)]
pub fn reset(&self);
);
}
/// Methods declared on superclass `NSObject`.
impl MTL4ComputePipelineDescriptor {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}