Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/metal-cpp/Metal/MTLBuffer.hpp
21082 views
1
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
//
3
// Metal/MTLBuffer.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 "MTLGPUAddress.hpp"
26
#include "MTLHeaderBridge.hpp"
27
#include "MTLPrivate.hpp"
28
#include "MTLResource.hpp"
29
30
namespace MTL
31
{
32
class Buffer;
33
class Device;
34
class Tensor;
35
class TensorDescriptor;
36
class Texture;
37
class TextureDescriptor;
38
39
class Buffer : public NS::Referencing<Buffer, Resource>
40
{
41
public:
42
void addDebugMarker(const NS::String* marker, NS::Range range);
43
44
void* contents();
45
46
void didModifyRange(NS::Range range);
47
48
GPUAddress gpuAddress() const;
49
50
NS::UInteger length() const;
51
52
Buffer* newRemoteBufferViewForDevice(const MTL::Device* device);
53
54
Tensor* newTensor(const MTL::TensorDescriptor* descriptor, NS::UInteger offset, NS::Error** error);
55
56
Texture* newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow);
57
58
Buffer* remoteStorageBuffer() const;
59
60
void removeAllDebugMarkers();
61
62
BufferSparseTier sparseBufferTier() const;
63
};
64
65
}
66
_MTL_INLINE void MTL::Buffer::addDebugMarker(const NS::String* marker, NS::Range range)
67
{
68
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(addDebugMarker_range_), marker, range);
69
}
70
71
_MTL_INLINE void* MTL::Buffer::contents()
72
{
73
return Object::sendMessage<void*>(this, _MTL_PRIVATE_SEL(contents));
74
}
75
76
_MTL_INLINE void MTL::Buffer::didModifyRange(NS::Range range)
77
{
78
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(didModifyRange_), range);
79
}
80
81
_MTL_INLINE MTL::GPUAddress MTL::Buffer::gpuAddress() const
82
{
83
return Object::sendMessage<MTL::GPUAddress>(this, _MTL_PRIVATE_SEL(gpuAddress));
84
}
85
86
_MTL_INLINE NS::UInteger MTL::Buffer::length() const
87
{
88
return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(length));
89
}
90
91
_MTL_INLINE MTL::Buffer* MTL::Buffer::newRemoteBufferViewForDevice(const MTL::Device* device)
92
{
93
return Object::sendMessage<MTL::Buffer*>(this, _MTL_PRIVATE_SEL(newRemoteBufferViewForDevice_), device);
94
}
95
96
_MTL_INLINE MTL::Tensor* MTL::Buffer::newTensor(const MTL::TensorDescriptor* descriptor, NS::UInteger offset, NS::Error** error)
97
{
98
return Object::sendMessage<MTL::Tensor*>(this, _MTL_PRIVATE_SEL(newTensorWithDescriptor_offset_error_), descriptor, offset, error);
99
}
100
101
_MTL_INLINE MTL::Texture* MTL::Buffer::newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow)
102
{
103
return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_offset_bytesPerRow_), descriptor, offset, bytesPerRow);
104
}
105
106
_MTL_INLINE MTL::Buffer* MTL::Buffer::remoteStorageBuffer() const
107
{
108
return Object::sendMessage<MTL::Buffer*>(this, _MTL_PRIVATE_SEL(remoteStorageBuffer));
109
}
110
111
_MTL_INLINE void MTL::Buffer::removeAllDebugMarkers()
112
{
113
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(removeAllDebugMarkers));
114
}
115
116
_MTL_INLINE MTL::BufferSparseTier MTL::Buffer::sparseBufferTier() const
117
{
118
return Object::sendMessage<MTL::BufferSparseTier>(this, _MTL_PRIVATE_SEL(sparseBufferTier));
119
}
120
121