/ include / Metal / MTLBinaryArchive.hpp
MTLBinaryArchive.hpp
  1  //-------------------------------------------------------------------------------------------------------------------------------------------------------------
  2  //
  3  // Metal/MTLBinaryArchive.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  _MTL_ENUM(NS::UInteger, BinaryArchiveError) {
 32      BinaryArchiveErrorNone = 0,
 33      BinaryArchiveErrorInvalidFile = 1,
 34      BinaryArchiveErrorUnexpectedElement = 2,
 35      BinaryArchiveErrorCompilationFailure = 3,
 36      BinaryArchiveErrorInternalError = 4,
 37  };
 38  
 39  class BinaryArchiveDescriptor : public NS::Copying<BinaryArchiveDescriptor>
 40  {
 41  public:
 42      static class BinaryArchiveDescriptor* alloc();
 43  
 44      class BinaryArchiveDescriptor*        init();
 45  
 46      NS::URL*                              url() const;
 47      void                                  setUrl(const NS::URL* url);
 48  };
 49  
 50  class BinaryArchive : public NS::Referencing<BinaryArchive>
 51  {
 52  public:
 53      NS::String*   label() const;
 54      void          setLabel(const NS::String* label);
 55  
 56      class Device* device() const;
 57  
 58      bool          addComputePipelineFunctions(const class ComputePipelineDescriptor* descriptor, NS::Error** error);
 59  
 60      bool          addRenderPipelineFunctions(const class RenderPipelineDescriptor* descriptor, NS::Error** error);
 61  
 62      bool          addTileRenderPipelineFunctions(const class TileRenderPipelineDescriptor* descriptor, NS::Error** error);
 63  
 64      bool          addMeshRenderPipelineFunctions(const class MeshRenderPipelineDescriptor* descriptor, NS::Error** error);
 65  
 66      bool          addLibrary(const class StitchedLibraryDescriptor* descriptor, NS::Error** error);
 67  
 68      bool          serializeToURL(const NS::URL* url, NS::Error** error);
 69  
 70      bool          addFunction(const class FunctionDescriptor* descriptor, const class Library* library, NS::Error** error);
 71  };
 72  
 73  }
 74  
 75  // static method: alloc
 76  _MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::alloc()
 77  {
 78      return NS::Object::alloc<MTL::BinaryArchiveDescriptor>(_MTL_PRIVATE_CLS(MTLBinaryArchiveDescriptor));
 79  }
 80  
 81  // method: init
 82  _MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::init()
 83  {
 84      return NS::Object::init<MTL::BinaryArchiveDescriptor>();
 85  }
 86  
 87  // property: url
 88  _MTL_INLINE NS::URL* MTL::BinaryArchiveDescriptor::url() const
 89  {
 90      return Object::sendMessage<NS::URL*>(this, _MTL_PRIVATE_SEL(url));
 91  }
 92  
 93  _MTL_INLINE void MTL::BinaryArchiveDescriptor::setUrl(const NS::URL* url)
 94  {
 95      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setUrl_), url);
 96  }
 97  
 98  // property: label
 99  _MTL_INLINE NS::String* MTL::BinaryArchive::label() const
100  {
101      return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
102  }
103  
104  _MTL_INLINE void MTL::BinaryArchive::setLabel(const NS::String* label)
105  {
106      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
107  }
108  
109  // property: device
110  _MTL_INLINE MTL::Device* MTL::BinaryArchive::device() const
111  {
112      return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
113  }
114  
115  // method: addComputePipelineFunctionsWithDescriptor:error:
116  _MTL_INLINE bool MTL::BinaryArchive::addComputePipelineFunctions(const MTL::ComputePipelineDescriptor* descriptor, NS::Error** error)
117  {
118      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addComputePipelineFunctionsWithDescriptor_error_), descriptor, error);
119  }
120  
121  // method: addRenderPipelineFunctionsWithDescriptor:error:
122  _MTL_INLINE bool MTL::BinaryArchive::addRenderPipelineFunctions(const MTL::RenderPipelineDescriptor* descriptor, NS::Error** error)
123  {
124      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addRenderPipelineFunctionsWithDescriptor_error_), descriptor, error);
125  }
126  
127  // method: addTileRenderPipelineFunctionsWithDescriptor:error:
128  _MTL_INLINE bool MTL::BinaryArchive::addTileRenderPipelineFunctions(const MTL::TileRenderPipelineDescriptor* descriptor, NS::Error** error)
129  {
130      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addTileRenderPipelineFunctionsWithDescriptor_error_), descriptor, error);
131  }
132  
133  // method: addMeshRenderPipelineFunctionsWithDescriptor:error:
134  _MTL_INLINE bool MTL::BinaryArchive::addMeshRenderPipelineFunctions(const MTL::MeshRenderPipelineDescriptor* descriptor, NS::Error** error)
135  {
136      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addMeshRenderPipelineFunctionsWithDescriptor_error_), descriptor, error);
137  }
138  
139  // method: addLibraryWithDescriptor:error:
140  _MTL_INLINE bool MTL::BinaryArchive::addLibrary(const MTL::StitchedLibraryDescriptor* descriptor, NS::Error** error)
141  {
142      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addLibraryWithDescriptor_error_), descriptor, error);
143  }
144  
145  // method: serializeToURL:error:
146  _MTL_INLINE bool MTL::BinaryArchive::serializeToURL(const NS::URL* url, NS::Error** error)
147  {
148      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(serializeToURL_error_), url, error);
149  }
150  
151  // method: addFunctionWithDescriptor:library:error:
152  _MTL_INLINE bool MTL::BinaryArchive::addFunction(const MTL::FunctionDescriptor* descriptor, const MTL::Library* library, NS::Error** error)
153  {
154      return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addFunctionWithDescriptor_library_error_), descriptor, library, error);
155  }