Path: blob/master/thirdparty/metal-cpp/Metal/MTLCaptureManager.hpp
21082 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Metal/MTLCaptureManager.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"2627namespace MTL28{29class CaptureDescriptor;30class CaptureManager;31class CaptureScope;32class CommandQueue;33class Device;34}3536namespace MTL437{38class CommandQueue;39}4041namespace MTL42{43_MTL_ENUM(NS::Integer, CaptureError) {44CaptureErrorNotSupported = 1,45CaptureErrorAlreadyCapturing = 2,46CaptureErrorInvalidDescriptor = 3,47};4849_MTL_ENUM(NS::Integer, CaptureDestination) {50CaptureDestinationDeveloperTools = 1,51CaptureDestinationGPUTraceDocument = 2,52};5354class CaptureDescriptor : public NS::Copying<CaptureDescriptor>55{56public:57static CaptureDescriptor* alloc();5859NS::Object* captureObject() const;6061CaptureDestination destination() const;6263CaptureDescriptor* init();6465NS::URL* outputURL() const;6667void setCaptureObject(NS::Object* captureObject);6869void setDestination(MTL::CaptureDestination destination);7071void setOutputURL(const NS::URL* outputURL);72};73class CaptureManager : public NS::Referencing<CaptureManager>74{75public:76static CaptureManager* alloc();7778CaptureScope* defaultCaptureScope() const;7980CaptureManager* init();8182bool isCapturing() const;8384CaptureScope* newCaptureScope(const MTL::Device* device);85CaptureScope* newCaptureScope(const MTL::CommandQueue* commandQueue);86CaptureScope* newCaptureScope(const MTL4::CommandQueue* commandQueue);8788void setDefaultCaptureScope(const MTL::CaptureScope* defaultCaptureScope);8990static CaptureManager* sharedCaptureManager();9192bool startCapture(const MTL::CaptureDescriptor* descriptor, NS::Error** error);93void startCapture(const MTL::Device* device);94void startCapture(const MTL::CommandQueue* commandQueue);95void startCapture(const MTL::CaptureScope* captureScope);9697void stopCapture();9899bool supportsDestination(MTL::CaptureDestination destination);100};101102}103_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::alloc()104{105return NS::Object::alloc<MTL::CaptureDescriptor>(_MTL_PRIVATE_CLS(MTLCaptureDescriptor));106}107108_MTL_INLINE NS::Object* MTL::CaptureDescriptor::captureObject() const109{110return Object::sendMessage<NS::Object*>(this, _MTL_PRIVATE_SEL(captureObject));111}112113_MTL_INLINE MTL::CaptureDestination MTL::CaptureDescriptor::destination() const114{115return Object::sendMessage<MTL::CaptureDestination>(this, _MTL_PRIVATE_SEL(destination));116}117118_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::init()119{120return NS::Object::init<MTL::CaptureDescriptor>();121}122123_MTL_INLINE NS::URL* MTL::CaptureDescriptor::outputURL() const124{125return Object::sendMessage<NS::URL*>(this, _MTL_PRIVATE_SEL(outputURL));126}127128_MTL_INLINE void MTL::CaptureDescriptor::setCaptureObject(NS::Object* captureObject)129{130Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCaptureObject_), captureObject);131}132133_MTL_INLINE void MTL::CaptureDescriptor::setDestination(MTL::CaptureDestination destination)134{135Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDestination_), destination);136}137138_MTL_INLINE void MTL::CaptureDescriptor::setOutputURL(const NS::URL* outputURL)139{140Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOutputURL_), outputURL);141}142143_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::alloc()144{145return NS::Object::alloc<MTL::CaptureManager>(_MTL_PRIVATE_CLS(MTLCaptureManager));146}147148_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::defaultCaptureScope() const149{150return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(defaultCaptureScope));151}152153_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::init()154{155return NS::Object::init<MTL::CaptureManager>();156}157158_MTL_INLINE bool MTL::CaptureManager::isCapturing() const159{160return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isCapturing));161}162163_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::Device* device)164{165return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(newCaptureScopeWithDevice_), device);166}167168_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::CommandQueue* commandQueue)169{170return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(newCaptureScopeWithCommandQueue_), commandQueue);171}172173_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL4::CommandQueue* commandQueue)174{175return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(newCaptureScopeWithMTL4CommandQueue_), commandQueue);176}177178_MTL_INLINE void MTL::CaptureManager::setDefaultCaptureScope(const MTL::CaptureScope* defaultCaptureScope)179{180Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDefaultCaptureScope_), defaultCaptureScope);181}182183_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::sharedCaptureManager()184{185return Object::sendMessage<MTL::CaptureManager*>(_MTL_PRIVATE_CLS(MTLCaptureManager), _MTL_PRIVATE_SEL(sharedCaptureManager));186}187188_MTL_INLINE bool MTL::CaptureManager::startCapture(const MTL::CaptureDescriptor* descriptor, NS::Error** error)189{190return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(startCaptureWithDescriptor_error_), descriptor, error);191}192193_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::Device* device)194{195Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(startCaptureWithDevice_), device);196}197198_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CommandQueue* commandQueue)199{200Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(startCaptureWithCommandQueue_), commandQueue);201}202203_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CaptureScope* captureScope)204{205Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(startCaptureWithScope_), captureScope);206}207208_MTL_INLINE void MTL::CaptureManager::stopCapture()209{210Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(stopCapture));211}212213_MTL_INLINE bool MTL::CaptureManager::supportsDestination(MTL::CaptureDestination destination)214{215return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportsDestination_), destination);216}217218219