Skip to main content

mtl_gpu/encoder/compute_encoder/
pipeline.rs

1//! Pipeline state methods for ComputeCommandEncoder.
2
3use std::ffi::c_void;
4
5use mtl_foundation::Referencing;
6use mtl_sys::{msg_send_0, msg_send_1, sel};
7
8use crate::enums::DispatchType;
9
10use super::ComputeCommandEncoder;
11
12impl ComputeCommandEncoder {
13    /// Set the compute pipeline state.
14    ///
15    /// C++ equivalent: `void setComputePipelineState(const ComputePipelineState*)`
16    #[inline]
17    pub fn set_compute_pipeline_state(&self, state: &crate::ComputePipelineState) {
18        unsafe {
19            msg_send_1::<(), *const c_void>(
20                self.as_ptr(),
21                sel!(setComputePipelineState:),
22                state.as_ptr(),
23            );
24        }
25    }
26
27    /// Get the dispatch type for this encoder.
28    ///
29    /// C++ equivalent: `DispatchType dispatchType() const`
30    #[inline]
31    pub fn dispatch_type(&self) -> DispatchType {
32        unsafe { msg_send_0(self.as_ptr(), sel!(dispatchType)) }
33    }
34}