/ include / Metal / MTLResidencySet.hpp
MTLResidencySet.hpp
  1  //-------------------------------------------------------------------------------------------------------------------------------------------------------------
  2  //
  3  // Metal/MTLResidencySet.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  namespace MTL
 30  {
 31  class ResidencySetDescriptor : public NS::Copying<ResidencySetDescriptor>
 32  {
 33  public:
 34      static class ResidencySetDescriptor* alloc();
 35  
 36      class ResidencySetDescriptor*        init();
 37  
 38      NS::String*                          label() const;
 39      void                                 setLabel(const NS::String* label);
 40  
 41      NS::UInteger                         initialCapacity() const;
 42      void                                 setInitialCapacity(NS::UInteger initialCapacity);
 43  };
 44  
 45  class ResidencySet : public NS::Referencing<ResidencySet>
 46  {
 47  public:
 48      class Device* device() const;
 49  
 50      NS::String*   label() const;
 51  
 52      uint64_t      allocatedSize() const;
 53  
 54      void          requestResidency();
 55  
 56      void          endResidency();
 57  
 58      void          addAllocation(const class Allocation* allocation);
 59  
 60      void          addAllocations(const class Allocation* const allocations[], NS::UInteger count);
 61  
 62      void          removeAllocation(const class Allocation* allocation);
 63  
 64      void          removeAllocations(const class Allocation* const allocations[], NS::UInteger count);
 65  
 66      void          removeAllAllocations();
 67  
 68      bool          containsAllocation(const class Allocation* anAllocation);
 69  
 70      NS::Array*    allAllocations() const;
 71  
 72      NS::UInteger  allocationCount() const;
 73  
 74      void          commit();
 75  };
 76  
 77  }
 78  
 79  // static method: alloc
 80  _MTL_INLINE MTL::ResidencySetDescriptor* MTL::ResidencySetDescriptor::alloc()
 81  {
 82      return NS::Object::alloc<MTL::ResidencySetDescriptor>(_MTL_PRIVATE_CLS(MTLResidencySetDescriptor));
 83  }
 84  
 85  // method: init
 86  _MTL_INLINE MTL::ResidencySetDescriptor* MTL::ResidencySetDescriptor::init()
 87  {
 88      return NS::Object::init<MTL::ResidencySetDescriptor>();
 89  }
 90  
 91  // property: label
 92  _MTL_INLINE NS::String* MTL::ResidencySetDescriptor::label() const
 93  {
 94      return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
 95  }
 96  
 97  _MTL_INLINE void MTL::ResidencySetDescriptor::setLabel(const NS::String* label)
 98  {
 99      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
100  }
101  
102  // property: initialCapacity
103  _MTL_INLINE NS::UInteger MTL::ResidencySetDescriptor::initialCapacity() const
104  {
105      return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(initialCapacity));
106  }
107  
108  _MTL_INLINE void MTL::ResidencySetDescriptor::setInitialCapacity(NS::UInteger initialCapacity)
109  {
110      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setInitialCapacity_), initialCapacity);
111  }
112  
113  // property: device
114  _MTL_INLINE MTL::Device* MTL::ResidencySet::device() const
115  {
116      return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
117  }
118  
119  // property: label
120  _MTL_INLINE NS::String* MTL::ResidencySet::label() const
121  {
122      return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
123  }
124  
125  // property: allocatedSize
126  _MTL_INLINE uint64_t MTL::ResidencySet::allocatedSize() const
127  {
128      return Object::sendMessage<uint64_t>(this, _MTL_PRIVATE_SEL(allocatedSize));
129  }
130  
131  // method: requestResidency
132  _MTL_INLINE void MTL::ResidencySet::requestResidency()
133  {
134      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(requestResidency));
135  }
136  
137  // method: endResidency
138  _MTL_INLINE void MTL::ResidencySet::endResidency()
139  {
140      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(endResidency));
141  }
142  
143  // method: addAllocation:
144  _MTL_INLINE void MTL::ResidencySet::addAllocation(const MTL::Allocation* allocation)
145  {
146      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(addAllocation_), allocation);
147  }
148  
149  // method: addAllocations:count:
150  _MTL_INLINE void MTL::ResidencySet::addAllocations(const MTL::Allocation* const allocations[], NS::UInteger count)
151  {
152      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(addAllocations_count_), allocations, count);
153  }
154  
155  // method: removeAllocation:
156  _MTL_INLINE void MTL::ResidencySet::removeAllocation(const MTL::Allocation* allocation)
157  {
158      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(removeAllocation_), allocation);
159  }
160  
161  // method: removeAllocations:count:
162  _MTL_INLINE void MTL::ResidencySet::removeAllocations(const MTL::Allocation* const allocations[], NS::UInteger count)
163  {
164      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(removeAllocations_count_), allocations, count);
165  }
166  
167  // method: removeAllAllocations
168  _MTL_INLINE void MTL::ResidencySet::removeAllAllocations()
169  {
170      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(removeAllAllocations));
171  }
172  
173  // method: containsAllocation:
174  _MTL_INLINE bool MTL::ResidencySet::containsAllocation(const MTL::Allocation* anAllocation)
175  {
176      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(containsAllocation_), anAllocation);
177  }
178  
179  // property: allAllocations
180  _MTL_INLINE NS::Array* MTL::ResidencySet::allAllocations() const
181  {
182      return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(allAllocations));
183  }
184  
185  // property: allocationCount
186  _MTL_INLINE NS::UInteger MTL::ResidencySet::allocationCount() const
187  {
188      return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(allocationCount));
189  }
190  
191  // method: commit
192  _MTL_INLINE void MTL::ResidencySet::commit()
193  {
194      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(commit));
195  }