/ include / Metal / MTLIOCommandQueue.hpp
MTLIOCommandQueue.hpp
  1  //-------------------------------------------------------------------------------------------------------------------------------------------------------------
  2  //
  3  // Metal/MTLIOCommandQueue.hpp
  4  //
  5  // Copyright 2020-2024 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 "MTLIOCommandQueue.hpp"
 30  
 31  namespace MTL
 32  {
 33  _MTL_ENUM(NS::Integer, IOPriority) {
 34      IOPriorityHigh = 0,
 35      IOPriorityNormal = 1,
 36      IOPriorityLow = 2,
 37  };
 38  
 39  _MTL_ENUM(NS::Integer, IOCommandQueueType) {
 40      IOCommandQueueTypeConcurrent = 0,
 41      IOCommandQueueTypeSerial = 1,
 42  };
 43  
 44  _MTL_CONST(NS::ErrorDomain, IOErrorDomain);
 45  
 46  _MTL_ENUM(NS::Integer, IOError) {
 47      IOErrorURLInvalid = 1,
 48      IOErrorInternal = 2,
 49  };
 50  
 51  class IOCommandQueue : public NS::Referencing<IOCommandQueue>
 52  {
 53  public:
 54      void                   enqueueBarrier();
 55  
 56      class IOCommandBuffer* commandBuffer();
 57  
 58      class IOCommandBuffer* commandBufferWithUnretainedReferences();
 59  
 60      NS::String*            label() const;
 61      void                   setLabel(const NS::String* label);
 62  };
 63  
 64  class IOScratchBuffer : public NS::Referencing<IOScratchBuffer>
 65  {
 66  public:
 67      class Buffer* buffer() const;
 68  };
 69  
 70  class IOScratchBufferAllocator : public NS::Referencing<IOScratchBufferAllocator>
 71  {
 72  public:
 73      class IOScratchBuffer* newScratchBuffer(NS::UInteger minimumSize);
 74  };
 75  
 76  class IOCommandQueueDescriptor : public NS::Copying<IOCommandQueueDescriptor>
 77  {
 78  public:
 79      static class IOCommandQueueDescriptor* alloc();
 80  
 81      class IOCommandQueueDescriptor*        init();
 82  
 83      NS::UInteger                           maxCommandBufferCount() const;
 84      void                                   setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount);
 85  
 86      MTL::IOPriority                        priority() const;
 87      void                                   setPriority(MTL::IOPriority priority);
 88  
 89      MTL::IOCommandQueueType                type() const;
 90      void                                   setType(MTL::IOCommandQueueType type);
 91  
 92      NS::UInteger                           maxCommandsInFlight() const;
 93      void                                   setMaxCommandsInFlight(NS::UInteger maxCommandsInFlight);
 94  
 95      class IOScratchBufferAllocator*        scratchBufferAllocator() const;
 96      void                                   setScratchBufferAllocator(const class IOScratchBufferAllocator* scratchBufferAllocator);
 97  };
 98  
 99  class IOFileHandle : public NS::Referencing<IOFileHandle>
100  {
101  public:
102      NS::String* label() const;
103      void        setLabel(const NS::String* label);
104  };
105  
106  }
107  
108  _MTL_PRIVATE_DEF_WEAK_CONST(NS::ErrorDomain, IOErrorDomain);
109  
110  // method: enqueueBarrier
111  _MTL_INLINE void MTL::IOCommandQueue::enqueueBarrier()
112  {
113      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(enqueueBarrier));
114  }
115  
116  // method: commandBuffer
117  _MTL_INLINE MTL::IOCommandBuffer* MTL::IOCommandQueue::commandBuffer()
118  {
119      return Object::sendMessage<MTL::IOCommandBuffer*>(this, _MTL_PRIVATE_SEL(commandBuffer));
120  }
121  
122  // method: commandBufferWithUnretainedReferences
123  _MTL_INLINE MTL::IOCommandBuffer* MTL::IOCommandQueue::commandBufferWithUnretainedReferences()
124  {
125      return Object::sendMessage<MTL::IOCommandBuffer*>(this, _MTL_PRIVATE_SEL(commandBufferWithUnretainedReferences));
126  }
127  
128  // property: label
129  _MTL_INLINE NS::String* MTL::IOCommandQueue::label() const
130  {
131      return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
132  }
133  
134  _MTL_INLINE void MTL::IOCommandQueue::setLabel(const NS::String* label)
135  {
136      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
137  }
138  
139  // property: buffer
140  _MTL_INLINE MTL::Buffer* MTL::IOScratchBuffer::buffer() const
141  {
142      return Object::sendMessage<MTL::Buffer*>(this, _MTL_PRIVATE_SEL(buffer));
143  }
144  
145  // method: newScratchBufferWithMinimumSize:
146  _MTL_INLINE MTL::IOScratchBuffer* MTL::IOScratchBufferAllocator::newScratchBuffer(NS::UInteger minimumSize)
147  {
148      return Object::sendMessage<MTL::IOScratchBuffer*>(this, _MTL_PRIVATE_SEL(newScratchBufferWithMinimumSize_), minimumSize);
149  }
150  
151  // static method: alloc
152  _MTL_INLINE MTL::IOCommandQueueDescriptor* MTL::IOCommandQueueDescriptor::alloc()
153  {
154      return NS::Object::alloc<MTL::IOCommandQueueDescriptor>(_MTL_PRIVATE_CLS(MTLIOCommandQueueDescriptor));
155  }
156  
157  // method: init
158  _MTL_INLINE MTL::IOCommandQueueDescriptor* MTL::IOCommandQueueDescriptor::init()
159  {
160      return NS::Object::init<MTL::IOCommandQueueDescriptor>();
161  }
162  
163  // property: maxCommandBufferCount
164  _MTL_INLINE NS::UInteger MTL::IOCommandQueueDescriptor::maxCommandBufferCount() const
165  {
166      return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxCommandBufferCount));
167  }
168  
169  _MTL_INLINE void MTL::IOCommandQueueDescriptor::setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount)
170  {
171      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxCommandBufferCount_), maxCommandBufferCount);
172  }
173  
174  // property: priority
175  _MTL_INLINE MTL::IOPriority MTL::IOCommandQueueDescriptor::priority() const
176  {
177      return Object::sendMessage<MTL::IOPriority>(this, _MTL_PRIVATE_SEL(priority));
178  }
179  
180  _MTL_INLINE void MTL::IOCommandQueueDescriptor::setPriority(MTL::IOPriority priority)
181  {
182      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPriority_), priority);
183  }
184  
185  // property: type
186  _MTL_INLINE MTL::IOCommandQueueType MTL::IOCommandQueueDescriptor::type() const
187  {
188      return Object::sendMessage<MTL::IOCommandQueueType>(this, _MTL_PRIVATE_SEL(type));
189  }
190  
191  _MTL_INLINE void MTL::IOCommandQueueDescriptor::setType(MTL::IOCommandQueueType type)
192  {
193      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setType_), type);
194  }
195  
196  // property: maxCommandsInFlight
197  _MTL_INLINE NS::UInteger MTL::IOCommandQueueDescriptor::maxCommandsInFlight() const
198  {
199      return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxCommandsInFlight));
200  }
201  
202  _MTL_INLINE void MTL::IOCommandQueueDescriptor::setMaxCommandsInFlight(NS::UInteger maxCommandsInFlight)
203  {
204      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxCommandsInFlight_), maxCommandsInFlight);
205  }
206  
207  // property: scratchBufferAllocator
208  _MTL_INLINE MTL::IOScratchBufferAllocator* MTL::IOCommandQueueDescriptor::scratchBufferAllocator() const
209  {
210      return Object::sendMessage<MTL::IOScratchBufferAllocator*>(this, _MTL_PRIVATE_SEL(scratchBufferAllocator));
211  }
212  
213  _MTL_INLINE void MTL::IOCommandQueueDescriptor::setScratchBufferAllocator(const MTL::IOScratchBufferAllocator* scratchBufferAllocator)
214  {
215      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setScratchBufferAllocator_), scratchBufferAllocator);
216  }
217  
218  // property: label
219  _MTL_INLINE NS::String* MTL::IOFileHandle::label() const
220  {
221      return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
222  }
223  
224  _MTL_INLINE void MTL::IOFileHandle::setLabel(const NS::String* label)
225  {
226      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
227  }