Path: blob/master/thirdparty/metal-cpp/Metal/MTL4Counters.hpp
21155 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Metal/MTL4Counters.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"26#include <cstdint>2728#include <cstdint>2930namespace MTL431{32class CounterHeapDescriptor;33_MTL_ENUM(NS::Integer, CounterHeapType) {34CounterHeapTypeInvalid,35CounterHeapTypeTimestamp,36};3738_MTL_ENUM(NS::Integer, TimestampGranularity) {39TimestampGranularityRelaxed = 0,40TimestampGranularityPrecise = 1,41};4243struct TimestampHeapEntry44{45uint64_t timestamp;46} _MTL_PACKED;4748class CounterHeapDescriptor : public NS::Copying<CounterHeapDescriptor>49{50public:51static CounterHeapDescriptor* alloc();5253NS::UInteger count() const;5455CounterHeapDescriptor* init();5657void setCount(NS::UInteger count);5859void setType(MTL4::CounterHeapType type);60CounterHeapType type() const;61};62class CounterHeap : public NS::Referencing<CounterHeap>63{64public:65NS::UInteger count() const;66void invalidateCounterRange(NS::Range range);6768NS::String* label() const;6970NS::Data* resolveCounterRange(NS::Range range);7172void setLabel(const NS::String* label);7374CounterHeapType type() const;75};7677}7879_MTL_INLINE MTL4::CounterHeapDescriptor* MTL4::CounterHeapDescriptor::alloc()80{81return NS::Object::alloc<MTL4::CounterHeapDescriptor>(_MTL_PRIVATE_CLS(MTL4CounterHeapDescriptor));82}8384_MTL_INLINE NS::UInteger MTL4::CounterHeapDescriptor::count() const85{86return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(count));87}8889_MTL_INLINE MTL4::CounterHeapDescriptor* MTL4::CounterHeapDescriptor::init()90{91return NS::Object::init<MTL4::CounterHeapDescriptor>();92}9394_MTL_INLINE void MTL4::CounterHeapDescriptor::setCount(NS::UInteger count)95{96Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCount_), count);97}9899_MTL_INLINE void MTL4::CounterHeapDescriptor::setType(MTL4::CounterHeapType type)100{101Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setType_), type);102}103104_MTL_INLINE MTL4::CounterHeapType MTL4::CounterHeapDescriptor::type() const105{106return Object::sendMessage<MTL4::CounterHeapType>(this, _MTL_PRIVATE_SEL(type));107}108109_MTL_INLINE NS::UInteger MTL4::CounterHeap::count() const110{111return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(count));112}113114_MTL_INLINE void MTL4::CounterHeap::invalidateCounterRange(NS::Range range)115{116Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(invalidateCounterRange_), range);117}118119_MTL_INLINE NS::String* MTL4::CounterHeap::label() const120{121return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));122}123124_MTL_INLINE NS::Data* MTL4::CounterHeap::resolveCounterRange(NS::Range range)125{126return Object::sendMessage<NS::Data*>(this, _MTL_PRIVATE_SEL(resolveCounterRange_), range);127}128129_MTL_INLINE void MTL4::CounterHeap::setLabel(const NS::String* label)130{131Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);132}133134_MTL_INLINE MTL4::CounterHeapType MTL4::CounterHeap::type() const135{136return Object::sendMessage<MTL4::CounterHeapType>(this, _MTL_PRIVATE_SEL(type));137}138139140