Path: blob/master/thirdparty/metal-cpp/Metal/MTLBuffer.hpp
21082 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Metal/MTLBuffer.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 "MTLGPUAddress.hpp"25#include "MTLHeaderBridge.hpp"26#include "MTLPrivate.hpp"27#include "MTLResource.hpp"2829namespace MTL30{31class Buffer;32class Device;33class Tensor;34class TensorDescriptor;35class Texture;36class TextureDescriptor;3738class Buffer : public NS::Referencing<Buffer, Resource>39{40public:41void addDebugMarker(const NS::String* marker, NS::Range range);4243void* contents();4445void didModifyRange(NS::Range range);4647GPUAddress gpuAddress() const;4849NS::UInteger length() const;5051Buffer* newRemoteBufferViewForDevice(const MTL::Device* device);5253Tensor* newTensor(const MTL::TensorDescriptor* descriptor, NS::UInteger offset, NS::Error** error);5455Texture* newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow);5657Buffer* remoteStorageBuffer() const;5859void removeAllDebugMarkers();6061BufferSparseTier sparseBufferTier() const;62};6364}65_MTL_INLINE void MTL::Buffer::addDebugMarker(const NS::String* marker, NS::Range range)66{67Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(addDebugMarker_range_), marker, range);68}6970_MTL_INLINE void* MTL::Buffer::contents()71{72return Object::sendMessage<void*>(this, _MTL_PRIVATE_SEL(contents));73}7475_MTL_INLINE void MTL::Buffer::didModifyRange(NS::Range range)76{77Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(didModifyRange_), range);78}7980_MTL_INLINE MTL::GPUAddress MTL::Buffer::gpuAddress() const81{82return Object::sendMessage<MTL::GPUAddress>(this, _MTL_PRIVATE_SEL(gpuAddress));83}8485_MTL_INLINE NS::UInteger MTL::Buffer::length() const86{87return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(length));88}8990_MTL_INLINE MTL::Buffer* MTL::Buffer::newRemoteBufferViewForDevice(const MTL::Device* device)91{92return Object::sendMessage<MTL::Buffer*>(this, _MTL_PRIVATE_SEL(newRemoteBufferViewForDevice_), device);93}9495_MTL_INLINE MTL::Tensor* MTL::Buffer::newTensor(const MTL::TensorDescriptor* descriptor, NS::UInteger offset, NS::Error** error)96{97return Object::sendMessage<MTL::Tensor*>(this, _MTL_PRIVATE_SEL(newTensorWithDescriptor_offset_error_), descriptor, offset, error);98}99100_MTL_INLINE MTL::Texture* MTL::Buffer::newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow)101{102return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_offset_bytesPerRow_), descriptor, offset, bytesPerRow);103}104105_MTL_INLINE MTL::Buffer* MTL::Buffer::remoteStorageBuffer() const106{107return Object::sendMessage<MTL::Buffer*>(this, _MTL_PRIVATE_SEL(remoteStorageBuffer));108}109110_MTL_INLINE void MTL::Buffer::removeAllDebugMarkers()111{112Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(removeAllDebugMarkers));113}114115_MTL_INLINE MTL::BufferSparseTier MTL::Buffer::sparseBufferTier() const116{117return Object::sendMessage<MTL::BufferSparseTier>(this, _MTL_PRIVATE_SEL(sparseBufferTier));118}119120121