Path: blob/master/thirdparty/metal-cpp/Metal/MTL4CommandBuffer.hpp
21066 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Metal/MTL4CommandBuffer.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 "MTL4RenderCommandEncoder.hpp"24#include "MTLAccelerationStructureTypes.hpp"25#include "MTLDefines.hpp"26#include "MTLHeaderBridge.hpp"27#include "MTLPrivate.hpp"2829namespace MTL430{31class CommandAllocator;32class CommandBufferOptions;33class ComputeCommandEncoder;34class CounterHeap;35class MachineLearningCommandEncoder;36class RenderCommandEncoder;37class RenderPassDescriptor;38}3940namespace MTL41{42class Device;43class Fence;44class LogState;45class ResidencySet;46}4748namespace MTL449{50class CommandBufferOptions : public NS::Copying<CommandBufferOptions>51{52public:53static CommandBufferOptions* alloc();5455CommandBufferOptions* init();5657MTL::LogState* logState() const;58void setLogState(const MTL::LogState* logState);59};60class CommandBuffer : public NS::Referencing<CommandBuffer>61{62public:63void beginCommandBuffer(const MTL4::CommandAllocator* allocator);64void beginCommandBuffer(const MTL4::CommandAllocator* allocator, const MTL4::CommandBufferOptions* options);6566ComputeCommandEncoder* computeCommandEncoder();6768MTL::Device* device() const;6970void endCommandBuffer();7172NS::String* label() const;7374MachineLearningCommandEncoder* machineLearningCommandEncoder();7576void popDebugGroup();7778void pushDebugGroup(const NS::String* string);7980RenderCommandEncoder* renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor);81RenderCommandEncoder* renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor, MTL4::RenderEncoderOptions options);8283void resolveCounterHeap(const MTL4::CounterHeap* counterHeap, NS::Range range, const MTL4::BufferRange bufferRange, const MTL::Fence* fenceToWait, const MTL::Fence* fenceToUpdate);8485void setLabel(const NS::String* label);8687void useResidencySet(const MTL::ResidencySet* residencySet);88void useResidencySets(const MTL::ResidencySet* const residencySets[], NS::UInteger count);8990void writeTimestampIntoHeap(const MTL4::CounterHeap* counterHeap, NS::UInteger index);91};9293}94_MTL_INLINE MTL4::CommandBufferOptions* MTL4::CommandBufferOptions::alloc()95{96return NS::Object::alloc<MTL4::CommandBufferOptions>(_MTL_PRIVATE_CLS(MTL4CommandBufferOptions));97}9899_MTL_INLINE MTL4::CommandBufferOptions* MTL4::CommandBufferOptions::init()100{101return NS::Object::init<MTL4::CommandBufferOptions>();102}103104_MTL_INLINE MTL::LogState* MTL4::CommandBufferOptions::logState() const105{106return Object::sendMessage<MTL::LogState*>(this, _MTL_PRIVATE_SEL(logState));107}108109_MTL_INLINE void MTL4::CommandBufferOptions::setLogState(const MTL::LogState* logState)110{111Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLogState_), logState);112}113114_MTL_INLINE void MTL4::CommandBuffer::beginCommandBuffer(const MTL4::CommandAllocator* allocator)115{116Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(beginCommandBufferWithAllocator_), allocator);117}118119_MTL_INLINE void MTL4::CommandBuffer::beginCommandBuffer(const MTL4::CommandAllocator* allocator, const MTL4::CommandBufferOptions* options)120{121Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(beginCommandBufferWithAllocator_options_), allocator, options);122}123124_MTL_INLINE MTL4::ComputeCommandEncoder* MTL4::CommandBuffer::computeCommandEncoder()125{126return Object::sendMessage<MTL4::ComputeCommandEncoder*>(this, _MTL_PRIVATE_SEL(computeCommandEncoder));127}128129_MTL_INLINE MTL::Device* MTL4::CommandBuffer::device() const130{131return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));132}133134_MTL_INLINE void MTL4::CommandBuffer::endCommandBuffer()135{136Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(endCommandBuffer));137}138139_MTL_INLINE NS::String* MTL4::CommandBuffer::label() const140{141return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));142}143144_MTL_INLINE MTL4::MachineLearningCommandEncoder* MTL4::CommandBuffer::machineLearningCommandEncoder()145{146return Object::sendMessage<MTL4::MachineLearningCommandEncoder*>(this, _MTL_PRIVATE_SEL(machineLearningCommandEncoder));147}148149_MTL_INLINE void MTL4::CommandBuffer::popDebugGroup()150{151Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(popDebugGroup));152}153154_MTL_INLINE void MTL4::CommandBuffer::pushDebugGroup(const NS::String* string)155{156Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string);157}158159_MTL_INLINE MTL4::RenderCommandEncoder* MTL4::CommandBuffer::renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor)160{161return Object::sendMessage<MTL4::RenderCommandEncoder*>(this, _MTL_PRIVATE_SEL(renderCommandEncoderWithDescriptor_), descriptor);162}163164_MTL_INLINE MTL4::RenderCommandEncoder* MTL4::CommandBuffer::renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor, MTL4::RenderEncoderOptions options)165{166return Object::sendMessage<MTL4::RenderCommandEncoder*>(this, _MTL_PRIVATE_SEL(renderCommandEncoderWithDescriptor_options_), descriptor, options);167}168169_MTL_INLINE void MTL4::CommandBuffer::resolveCounterHeap(const MTL4::CounterHeap* counterHeap, NS::Range range, const MTL4::BufferRange bufferRange, const MTL::Fence* fenceToWait, const MTL::Fence* fenceToUpdate)170{171Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(resolveCounterHeap_withRange_intoBuffer_waitFence_updateFence_), counterHeap, range, bufferRange, fenceToWait, fenceToUpdate);172}173174_MTL_INLINE void MTL4::CommandBuffer::setLabel(const NS::String* label)175{176Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);177}178179_MTL_INLINE void MTL4::CommandBuffer::useResidencySet(const MTL::ResidencySet* residencySet)180{181Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResidencySet_), residencySet);182}183184_MTL_INLINE void MTL4::CommandBuffer::useResidencySets(const MTL::ResidencySet* const residencySets[], NS::UInteger count)185{186Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResidencySets_count_), residencySets, count);187}188189_MTL_INLINE void MTL4::CommandBuffer::writeTimestampIntoHeap(const MTL4::CounterHeap* counterHeap, NS::UInteger index)190{191Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(writeTimestampIntoHeap_atIndex_), counterHeap, index);192}193194195