yum-mirror/VkFFT

git clone https://git.yummers.dev/yum-mirror/VkFFT

Tolmachev DmitriiMetal support in VkFFTba7001c

develop
8.9 KiB258 linesraw
1//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2//
3// Metal/MTLCounters.hpp
4//
5// Copyright 2020-2021 Apple Inc.
6//
7// Licensed under the Apache License, Version 2.0 (the "License");
8// you may not use this file except in compliance with the License.
9// You may obtain a copy of the License at
10//
11//     http://www.apache.org/licenses/LICENSE-2.0
12//
13// Unless required by applicable law or agreed to in writing, software
14// distributed under the License is distributed on an "AS IS" BASIS,
15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16// See the License for the specific language governing permissions and
17// limitations under the License.
18//
19//-------------------------------------------------------------------------------------------------------------------------------------------------------------
20
21#pragma once
22
23#include "MTLDefines.hpp"
24#include "MTLHeaderBridge.hpp"
25#include "MTLPrivate.hpp"
26
27#include <Foundation/Foundation.hpp>
28
29#include "MTLResource.hpp"
30
31namespace MTL
32{
33
34_MTL_CONST( NS::ErrorDomain, CounterErrorDomain );
35
36using CommonCounter = NS::String*;
37
38_MTL_CONST( CommonCounter, CommonCounterTimestamp );
39_MTL_CONST( CommonCounter, CommonCounterTessellationInputPatches );
40_MTL_CONST( CommonCounter, CommonCounterVertexInvocations );
41_MTL_CONST( CommonCounter, CommonCounterPostTessellationVertexInvocations );
42_MTL_CONST( CommonCounter, CommonCounterClipperInvocations );
43_MTL_CONST( CommonCounter, CommonCounterClipperPrimitivesOut );
44_MTL_CONST( CommonCounter, CommonCounterFragmentInvocations );
45_MTL_CONST( CommonCounter, CommonCounterFragmentsPassed );
46_MTL_CONST( CommonCounter, CommonCounterComputeKernelInvocations );
47_MTL_CONST( CommonCounter, CommonCounterTotalCycles );
48_MTL_CONST( CommonCounter, CommonCounterVertexCycles );
49_MTL_CONST( CommonCounter, CommonCounterTessellationCycles );
50_MTL_CONST( CommonCounter, CommonCounterPostTessellationVertexCycles );
51_MTL_CONST( CommonCounter, CommonCounterFragmentCycles );
52_MTL_CONST( CommonCounter, CommonCounterRenderTargetWriteCycles );
53
54using CommonCounterSet = NS::String*;
55
56_MTL_CONST( CommonCounterSet, CommonCounterSetTimestamp );
57_MTL_CONST( CommonCounterSet, CommonCounterSetStageUtilization );
58_MTL_CONST( CommonCounterSet, CommonCounterSetStatistic );
59
60struct CounterResultTimestamp
61{
62    uint64_t timestamp;
63} _MTL_PACKED;
64
65struct CounterResultStageUtilization
66{
67    uint64_t totalCycles;
68    uint64_t vertexCycles;
69    uint64_t tessellationCycles;
70    uint64_t postTessellationVertexCycles;
71    uint64_t fragmentCycles;
72    uint64_t renderTargetCycles;
73} _MTL_PACKED;
74
75struct CounterResultStatistic
76{
77    uint64_t tessellationInputPatches;
78    uint64_t vertexInvocations;
79    uint64_t postTessellationVertexInvocations;
80    uint64_t clipperInvocations;
81    uint64_t clipperPrimitivesOut;
82    uint64_t fragmentInvocations;
83    uint64_t fragmentsPassed;
84    uint64_t computeKernelInvocations;
85} _MTL_PACKED;
86
87class Counter : public NS::Referencing<Counter>
88{
89public:
90    NS::String* name() const;
91};
92
93class CounterSet : public NS::Referencing<CounterSet>
94{
95public:
96    NS::String* name() const;
97
98    NS::Array*  counters() const;
99};
100
101class CounterSampleBufferDescriptor : public NS::Copying<CounterSampleBufferDescriptor>
102{
103public:
104    static class CounterSampleBufferDescriptor* alloc();
105
106    class CounterSampleBufferDescriptor*        init();
107
108    class CounterSet*                           counterSet() const;
109    void                                        setCounterSet(const class CounterSet* counterSet);
110
111    NS::String*                                 label() const;
112    void                                        setLabel(const NS::String* label);
113
114    MTL::StorageMode                            storageMode() const;
115    void                                        setStorageMode(MTL::StorageMode storageMode);
116
117    NS::UInteger                                sampleCount() const;
118    void                                        setSampleCount(NS::UInteger sampleCount);
119};
120
121class CounterSampleBuffer : public NS::Referencing<CounterSampleBuffer>
122{
123public:
124    class Device* device() const;
125
126    NS::String*   label() const;
127
128    NS::UInteger  sampleCount() const;
129
130    NS::Data*     resolveCounterRange(NS::Range range);
131};
132
133_MTL_ENUM(NS::Integer, CounterSampleBufferError) {
134    CounterSampleBufferErrorOutOfMemory = 0,
135    CounterSampleBufferErrorInvalid = 1,
136};
137
138}
139
140_MTL_PRIVATE_DEF_STR( NS::ErrorDomain, CounterErrorDomain );
141
142_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterTimestamp );
143_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterTessellationInputPatches );
144_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterVertexInvocations );
145_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterPostTessellationVertexInvocations );
146_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterClipperInvocations );
147_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterClipperPrimitivesOut );
148_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterFragmentInvocations );
149_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterFragmentsPassed );
150_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterComputeKernelInvocations );
151_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterTotalCycles );
152_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterVertexCycles );
153_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterTessellationCycles );
154_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterPostTessellationVertexCycles );
155_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterFragmentCycles );
156_MTL_PRIVATE_DEF_STR( MTL::CommonCounter, CommonCounterRenderTargetWriteCycles );
157
158_MTL_PRIVATE_DEF_STR( MTL::CommonCounterSet, CommonCounterSetTimestamp );
159_MTL_PRIVATE_DEF_STR( MTL::CommonCounterSet, CommonCounterSetStageUtilization );
160_MTL_PRIVATE_DEF_STR( MTL::CommonCounterSet, CommonCounterSetStatistic );
161
162// property: name
163_MTL_INLINE NS::String* MTL::Counter::name() const
164{
165    return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name));
166}
167
168// property: name
169_MTL_INLINE NS::String* MTL::CounterSet::name() const
170{
171    return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name));
172}
173
174// property: counters
175_MTL_INLINE NS::Array* MTL::CounterSet::counters() const
176{
177    return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(counters));
178}
179
180// static method: alloc
181_MTL_INLINE MTL::CounterSampleBufferDescriptor* MTL::CounterSampleBufferDescriptor::alloc()
182{
183    return NS::Object::alloc<MTL::CounterSampleBufferDescriptor>(_MTL_PRIVATE_CLS(MTLCounterSampleBufferDescriptor));
184}
185
186// method: init
187_MTL_INLINE MTL::CounterSampleBufferDescriptor* MTL::CounterSampleBufferDescriptor::init()
188{
189    return NS::Object::init<MTL::CounterSampleBufferDescriptor>();
190}
191
192// property: counterSet
193_MTL_INLINE MTL::CounterSet* MTL::CounterSampleBufferDescriptor::counterSet() const
194{
195    return Object::sendMessage<MTL::CounterSet*>(this, _MTL_PRIVATE_SEL(counterSet));
196}
197
198_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setCounterSet(const MTL::CounterSet* counterSet)
199{
200    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCounterSet_), counterSet);
201}
202
203// property: label
204_MTL_INLINE NS::String* MTL::CounterSampleBufferDescriptor::label() const
205{
206    return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
207}
208
209_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setLabel(const NS::String* label)
210{
211    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
212}
213
214// property: storageMode
215_MTL_INLINE MTL::StorageMode MTL::CounterSampleBufferDescriptor::storageMode() const
216{
217    return Object::sendMessage<MTL::StorageMode>(this, _MTL_PRIVATE_SEL(storageMode));
218}
219
220_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setStorageMode(MTL::StorageMode storageMode)
221{
222    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode);
223}
224
225// property: sampleCount
226_MTL_INLINE NS::UInteger MTL::CounterSampleBufferDescriptor::sampleCount() const
227{
228    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(sampleCount));
229}
230
231_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setSampleCount(NS::UInteger sampleCount)
232{
233    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount);
234}
235
236// property: device
237_MTL_INLINE MTL::Device* MTL::CounterSampleBuffer::device() const
238{
239    return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
240}
241
242// property: label
243_MTL_INLINE NS::String* MTL::CounterSampleBuffer::label() const
244{
245    return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
246}
247
248// property: sampleCount
249_MTL_INLINE NS::UInteger MTL::CounterSampleBuffer::sampleCount() const
250{
251    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(sampleCount));
252}
253
254// method: resolveCounterRange:
255_MTL_INLINE NS::Data* MTL::CounterSampleBuffer::resolveCounterRange(NS::Range range)
256{
257    return Object::sendMessage<NS::Data*>(this, _MTL_PRIVATE_SEL(resolveCounterRange_), range);
258}