summaryrefslogtreecommitdiffstats
path: root/third_party/rust/metal/src/computepass.rs
blob: 50774d6871e088e985fb11e4d72136f454ceb188 (plain)
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
use super::*;

/// See <https://developer.apple.com/documentation/metal/mtlcomputepassdescriptor>
pub enum MTLComputePassDescriptor {}

foreign_obj_type! {
    type CType = MTLComputePassDescriptor;
    pub struct ComputePassDescriptor;
}

impl ComputePassDescriptor {
    /// Creates a default compute pass descriptor with no attachments.
    pub fn new<'a>() -> &'a ComputePassDescriptorRef {
        unsafe { msg_send![class!(MTLComputePassDescriptor), computePassDescriptor] }
    }
}

impl ComputePassDescriptorRef {
    pub fn sample_buffer_attachments(
        &self,
    ) -> &ComputePassSampleBufferAttachmentDescriptorArrayRef {
        unsafe { msg_send![self, sampleBufferAttachments] }
    }
}

/// See <https://developer.apple.com/documentation/metal/mtlcomputepasssamplebufferattachmentdescriptorarray>
pub enum MTLComputePassSampleBufferAttachmentDescriptorArray {}

foreign_obj_type! {
    type CType = MTLComputePassSampleBufferAttachmentDescriptorArray;
    pub struct ComputePassSampleBufferAttachmentDescriptorArray;
}

impl ComputePassSampleBufferAttachmentDescriptorArrayRef {
    pub fn object_at(
        &self,
        index: NSUInteger,
    ) -> Option<&ComputePassSampleBufferAttachmentDescriptorRef> {
        unsafe { msg_send![self, objectAtIndexedSubscript: index] }
    }

    pub fn set_object_at(
        &self,
        index: NSUInteger,
        attachment: Option<&ComputePassSampleBufferAttachmentDescriptorRef>,
    ) {
        unsafe {
            msg_send![self, setObject:attachment
                     atIndexedSubscript:index]
        }
    }
}

/// See <https://developer.apple.com/documentation/metal/mtlcomputepasssamplebufferattachmentdescriptor>
pub enum MTLComputePassSampleBufferAttachmentDescriptor {}

foreign_obj_type! {
    type CType = MTLComputePassSampleBufferAttachmentDescriptor;
    pub struct ComputePassSampleBufferAttachmentDescriptor;
}

impl ComputePassSampleBufferAttachmentDescriptor {
    pub fn new() -> Self {
        let class = class!(MTLComputePassSampleBufferAttachmentDescriptor);
        unsafe { msg_send![class, new] }
    }
}

impl ComputePassSampleBufferAttachmentDescriptorRef {
    pub fn sample_buffer(&self) -> &CounterSampleBufferRef {
        unsafe { msg_send![self, sampleBuffer] }
    }

    pub fn set_sample_buffer(&self, sample_buffer: &CounterSampleBufferRef) {
        unsafe { msg_send![self, setSampleBuffer: sample_buffer] }
    }

    pub fn start_of_encoder_sample_index(&self) -> NSUInteger {
        unsafe { msg_send![self, startOfEncoderSampleIndex] }
    }

    pub fn set_start_of_encoder_sample_index(&self, start_of_encoder_sample_index: NSUInteger) {
        unsafe {
            msg_send![
                self,
                setStartOfEncoderSampleIndex: start_of_encoder_sample_index
            ]
        }
    }

    pub fn end_of_encoder_sample_index(&self) -> NSUInteger {
        unsafe { msg_send![self, endOfEncoderSampleIndex] }
    }

    pub fn set_end_of_encoder_sample_index(&self, end_of_encoder_sample_index: NSUInteger) {
        unsafe {
            msg_send![
                self,
                setEndOfEncoderSampleIndex: end_of_encoder_sample_index
            ]
        }
    }
}