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