Path: blob/master/thirdparty/metal-cpp/Metal/MTLBinaryArchive.hpp
21082 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Metal/MTLBinaryArchive.hpp3//4// Copyright 2020-2025 Apple Inc.5//6// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.17//18//-------------------------------------------------------------------------------------------------------------------------------------------------------------1920#pragma once2122#include "../Foundation/Foundation.hpp"23#include "MTLDefines.hpp"24#include "MTLHeaderBridge.hpp"25#include "MTLPrivate.hpp"2627namespace MTL28{29class BinaryArchiveDescriptor;30class ComputePipelineDescriptor;31class Device;32class FunctionDescriptor;33class Library;34class MeshRenderPipelineDescriptor;35class RenderPipelineDescriptor;36class StitchedLibraryDescriptor;37class TileRenderPipelineDescriptor;38_MTL_ENUM(NS::UInteger, BinaryArchiveError) {39BinaryArchiveErrorNone = 0,40BinaryArchiveErrorInvalidFile = 1,41BinaryArchiveErrorUnexpectedElement = 2,42BinaryArchiveErrorCompilationFailure = 3,43BinaryArchiveErrorInternalError = 4,44};4546_MTL_CONST(NS::ErrorDomain, BinaryArchiveDomain);47class BinaryArchiveDescriptor : public NS::Copying<BinaryArchiveDescriptor>48{49public:50static BinaryArchiveDescriptor* alloc();5152BinaryArchiveDescriptor* init();5354void setUrl(const NS::URL* url);55NS::URL* url() const;56};57class BinaryArchive : public NS::Referencing<BinaryArchive>58{59public:60bool addComputePipelineFunctions(const MTL::ComputePipelineDescriptor* descriptor, NS::Error** error);6162bool addFunction(const MTL::FunctionDescriptor* descriptor, const MTL::Library* library, NS::Error** error);6364bool addLibrary(const MTL::StitchedLibraryDescriptor* descriptor, NS::Error** error);6566bool addMeshRenderPipelineFunctions(const MTL::MeshRenderPipelineDescriptor* descriptor, NS::Error** error);6768bool addRenderPipelineFunctions(const MTL::RenderPipelineDescriptor* descriptor, NS::Error** error);6970bool addTileRenderPipelineFunctions(const MTL::TileRenderPipelineDescriptor* descriptor, NS::Error** error);7172Device* device() const;7374NS::String* label() const;7576bool serializeToURL(const NS::URL* url, NS::Error** error);7778void setLabel(const NS::String* label);79};8081}82_MTL_PRIVATE_DEF_CONST(NS::ErrorDomain, BinaryArchiveDomain);83_MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::alloc()84{85return NS::Object::alloc<MTL::BinaryArchiveDescriptor>(_MTL_PRIVATE_CLS(MTLBinaryArchiveDescriptor));86}8788_MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::init()89{90return NS::Object::init<MTL::BinaryArchiveDescriptor>();91}9293_MTL_INLINE void MTL::BinaryArchiveDescriptor::setUrl(const NS::URL* url)94{95Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setUrl_), url);96}9798_MTL_INLINE NS::URL* MTL::BinaryArchiveDescriptor::url() const99{100return Object::sendMessage<NS::URL*>(this, _MTL_PRIVATE_SEL(url));101}102103_MTL_INLINE bool MTL::BinaryArchive::addComputePipelineFunctions(const MTL::ComputePipelineDescriptor* descriptor, NS::Error** error)104{105return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addComputePipelineFunctionsWithDescriptor_error_), descriptor, error);106}107108_MTL_INLINE bool MTL::BinaryArchive::addFunction(const MTL::FunctionDescriptor* descriptor, const MTL::Library* library, NS::Error** error)109{110return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addFunctionWithDescriptor_library_error_), descriptor, library, error);111}112113_MTL_INLINE bool MTL::BinaryArchive::addLibrary(const MTL::StitchedLibraryDescriptor* descriptor, NS::Error** error)114{115return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addLibraryWithDescriptor_error_), descriptor, error);116}117118_MTL_INLINE bool MTL::BinaryArchive::addMeshRenderPipelineFunctions(const MTL::MeshRenderPipelineDescriptor* descriptor, NS::Error** error)119{120return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addMeshRenderPipelineFunctionsWithDescriptor_error_), descriptor, error);121}122123_MTL_INLINE bool MTL::BinaryArchive::addRenderPipelineFunctions(const MTL::RenderPipelineDescriptor* descriptor, NS::Error** error)124{125return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addRenderPipelineFunctionsWithDescriptor_error_), descriptor, error);126}127128_MTL_INLINE bool MTL::BinaryArchive::addTileRenderPipelineFunctions(const MTL::TileRenderPipelineDescriptor* descriptor, NS::Error** error)129{130return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(addTileRenderPipelineFunctionsWithDescriptor_error_), descriptor, error);131}132133_MTL_INLINE MTL::Device* MTL::BinaryArchive::device() const134{135return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));136}137138_MTL_INLINE NS::String* MTL::BinaryArchive::label() const139{140return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));141}142143_MTL_INLINE bool MTL::BinaryArchive::serializeToURL(const NS::URL* url, NS::Error** error)144{145return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(serializeToURL_error_), url, error);146}147148_MTL_INLINE void MTL::BinaryArchive::setLabel(const NS::String* label)149{150Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);151}152153154