summaryrefslogtreecommitdiffstats
path: root/third_party/rust/metal/src/counters.rs
blob: 0a39752d2d610070903a1448ec4439e36f447997 (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
use crate::MTLStorageMode;

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

foreign_obj_type! {
    type CType = MTLCounterSampleBufferDescriptor;
    pub struct CounterSampleBufferDescriptor;
}

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

impl CounterSampleBufferDescriptorRef {
    pub fn counter_set(&self) -> &CounterSetRef {
        unsafe { msg_send![self, counterSet] }
    }

    pub fn set_counter_set(&self, counter_set: &CounterSetRef) {
        unsafe { msg_send![self, setCounterSet: counter_set] }
    }

    pub fn label(&self) -> &str {
        unsafe {
            let label = msg_send![self, label];
            crate::nsstring_as_str(label)
        }
    }

    pub fn set_label(&self, label: &str) {
        unsafe {
            let nslabel = crate::nsstring_from_str(label);
            let () = msg_send![self, setLabel: nslabel];
        }
    }

    pub fn sample_count(&self) -> u64 {
        unsafe { msg_send![self, sampleCount] }
    }

    pub fn set_sample_count(&self, sample_count: u64) {
        unsafe { msg_send![self, setSampleCount: sample_count] }
    }

    pub fn storage_mode(&self) -> MTLStorageMode {
        unsafe { msg_send![self, storageMode] }
    }

    pub fn set_storage_mode(&self, storage_mode: MTLStorageMode) {
        unsafe { msg_send![self, setStorageMode: storage_mode] }
    }
}

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

foreign_obj_type! {
    type CType = MTLCounterSampleBuffer;
    pub struct CounterSampleBuffer;
}

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

foreign_obj_type! {
    type CType = MTLCounter;
    pub struct Counter;
}

impl CounterRef {}

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

foreign_obj_type! {
    type CType = MTLCounterSet;
    pub struct CounterSet;
}

impl CounterSetRef {
    pub fn name(&self) -> &str {
        unsafe {
            let name = msg_send![self, name];
            crate::nsstring_as_str(name)
        }
    }
}

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

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

foreign_obj_type! {
    type CType = MTLCommonCounter;
    pub struct CommonCounter;
}