Path: blob/master/thirdparty/metal-cpp/MetalFX/MTLFXSpatialScaler.hpp
21085 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// MetalFX/MTLFXSpatialScaler.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//-------------------------------------------------------------------------------------------------------------------------------------------------------------2324#include "MTLFXDefines.hpp"25#include "MTLFXPrivate.hpp"2627#include "../Metal/Metal.hpp"2829//-------------------------------------------------------------------------------------------------------------------------------------------------------------3031namespace MTL4FX32{33class SpatialScaler;34}3536namespace MTLFX37{38_MTLFX_ENUM( NS::Integer, SpatialScalerColorProcessingMode )39{40SpatialScalerColorProcessingModePerceptual = 0,41SpatialScalerColorProcessingModeLinear = 1,42SpatialScalerColorProcessingModeHDR = 243};4445class SpatialScalerDescriptor : public NS::Copying< SpatialScalerDescriptor >46{47public:48static class SpatialScalerDescriptor* alloc();49class SpatialScalerDescriptor* init();5051MTL::PixelFormat colorTextureFormat() const;52void setColorTextureFormat( MTL::PixelFormat format );5354MTL::PixelFormat outputTextureFormat() const;55void setOutputTextureFormat( MTL::PixelFormat format );5657NS::UInteger inputWidth() const;58void setInputWidth( NS::UInteger width );5960NS::UInteger inputHeight() const;61void setInputHeight( NS::UInteger height );6263NS::UInteger outputWidth() const;64void setOutputWidth( NS::UInteger width );6566NS::UInteger outputHeight() const;67void setOutputHeight( NS::UInteger height );6869SpatialScalerColorProcessingMode colorProcessingMode() const;70void setColorProcessingMode( SpatialScalerColorProcessingMode mode );7172class SpatialScaler* newSpatialScaler( const MTL::Device* pDevice ) const;73MTL4FX::SpatialScaler* newSpatialScaler( const MTL::Device* pDevice, const MTL4::Compiler* pCompiler ) const;7475static bool supportsDevice( const MTL::Device* pDevice);76static bool supportsMetal4FX( const MTL::Device* pDevice );77};7879class SpatialScalerBase : public NS::Referencing< SpatialScaler >80{81public:82MTL::TextureUsage colorTextureUsage() const;83MTL::TextureUsage outputTextureUsage() const;8485NS::UInteger inputContentWidth() const;86void setInputContentWidth( NS::UInteger width );8788NS::UInteger inputContentHeight() const;89void setInputContentHeight( NS::UInteger height );9091MTL::Texture* colorTexture() const;92void setColorTexture( MTL::Texture* pTexture );9394MTL::Texture* outputTexture() const;95void setOutputTexture( MTL::Texture* pTexture );9697MTL::PixelFormat colorTextureFormat() const;98MTL::PixelFormat outputTextureFormat() const;99NS::UInteger inputWidth() const;100NS::UInteger inputHeight() const;101NS::UInteger outputWidth() const;102NS::UInteger outputHeight() const;103SpatialScalerColorProcessingMode colorProcessingMode() const;104105MTL::Fence* fence() const;106void setFence( MTL::Fence* pFence );107};108109class SpatialScaler : public NS::Referencing< SpatialScaler, SpatialScalerBase >110{111public:112void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer );113};114}115116//-------------------------------------------------------------------------------------------------------------------------------------------------------------117118_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::alloc()119{120return NS::Object::alloc< SpatialScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ) );121}122123//-------------------------------------------------------------------------------------------------------------------------------------------------------------124125_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::init()126{127return NS::Object::init< SpatialScalerDescriptor >();128}129130//-------------------------------------------------------------------------------------------------------------------------------------------------------------131132_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::colorTextureFormat() const133{134return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );135}136137//-------------------------------------------------------------------------------------------------------------------------------------------------------------138139_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format )140{141Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setColorTextureFormat_ ), format );142}143144//-------------------------------------------------------------------------------------------------------------------------------------------------------------145146_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::outputTextureFormat() const147{148return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );149}150151//-------------------------------------------------------------------------------------------------------------------------------------------------------------152153_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format )154{155Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputTextureFormat_ ), format );156}157158//-------------------------------------------------------------------------------------------------------------------------------------------------------------159160_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputWidth() const161{162return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );163}164165//-------------------------------------------------------------------------------------------------------------------------------------------------------------166167_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputWidth( NS::UInteger width )168{169Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputWidth_ ), width );170}171172//-------------------------------------------------------------------------------------------------------------------------------------------------------------173174_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputHeight() const175{176return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );177}178179//-------------------------------------------------------------------------------------------------------------------------------------------------------------180181_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputHeight( NS::UInteger height )182{183Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputHeight_ ), height );184}185186//-------------------------------------------------------------------------------------------------------------------------------------------------------------187188_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputWidth() const189{190return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );191}192193//-------------------------------------------------------------------------------------------------------------------------------------------------------------194195_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputWidth( NS::UInteger width )196{197Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputWidth_ ), width );198}199200//-------------------------------------------------------------------------------------------------------------------------------------------------------------201202_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputHeight() const203{204return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );205}206207//-------------------------------------------------------------------------------------------------------------------------------------------------------------208209_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputHeight( NS::UInteger height )210{211Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputHeight_ ), height );212}213214//-------------------------------------------------------------------------------------------------------------------------------------------------------------215216_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScalerDescriptor::colorProcessingMode() const217{218return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) );219}220221//-------------------------------------------------------------------------------------------------------------------------------------------------------------222223_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorProcessingMode( SpatialScalerColorProcessingMode mode )224{225Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setColorProcessingMode_ ), mode );226}227228//-------------------------------------------------------------------------------------------------------------------------------------------------------------229230_MTLFX_INLINE MTLFX::SpatialScaler* MTLFX::SpatialScalerDescriptor::newSpatialScaler( const MTL::Device* pDevice ) const231{232return Object::sendMessage< SpatialScaler* >( this, _MTLFX_PRIVATE_SEL( newSpatialScalerWithDevice_ ), pDevice );233}234235//-------------------------------------------------------------------------------------------------------------------------------------------------------------236237_MTLFX_INLINE MTL4FX::SpatialScaler* MTLFX::SpatialScalerDescriptor::newSpatialScaler( const MTL::Device* pDevice, const MTL4::Compiler* pCompiler ) const238{239return Object::sendMessage< MTL4FX::SpatialScaler* >( this, _MTLFX_PRIVATE_SEL( newSpatialScalerWithDevice_compiler_ ), pDevice, pCompiler );240}241242//-------------------------------------------------------------------------------------------------------------------------------------------------------------243244_MTLFX_INLINE bool MTLFX::SpatialScalerDescriptor::supportsDevice( const MTL::Device* pDevice )245{246return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice );247}248249//-------------------------------------------------------------------------------------------------------------------------------------------------------------250251_MTLFX_INLINE bool MTLFX::SpatialScalerDescriptor::supportsMetal4FX( const MTL::Device* pDevice )252{253return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsMetal4FX_ ), pDevice );254}255256//-------------------------------------------------------------------------------------------------------------------------------------------------------------257258_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScalerBase::colorTextureUsage() const259{260return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) );261}262263//-------------------------------------------------------------------------------------------------------------------------------------------------------------264265_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScalerBase::outputTextureUsage() const266{267return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) );268}269270//-------------------------------------------------------------------------------------------------------------------------------------------------------------271272_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputContentWidth() const273{274return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) );275}276277//-------------------------------------------------------------------------------------------------------------------------------------------------------------278279_MTLFX_INLINE void MTLFX::SpatialScalerBase::setInputContentWidth( NS::UInteger width )280{281Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputContentWidth_ ), width );282}283284//-------------------------------------------------------------------------------------------------------------------------------------------------------------285286_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputContentHeight() const287{288return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) );289}290291//-------------------------------------------------------------------------------------------------------------------------------------------------------------292293_MTLFX_INLINE void MTLFX::SpatialScalerBase::setInputContentHeight( NS::UInteger height )294{295Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputContentHeight_ ), height );296}297298//-------------------------------------------------------------------------------------------------------------------------------------------------------------299300_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScalerBase::colorTexture() const301{302return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) );303}304305//-------------------------------------------------------------------------------------------------------------------------------------------------------------306307_MTLFX_INLINE void MTLFX::SpatialScalerBase::setColorTexture( MTL::Texture* pTexture )308{309Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setColorTexture_ ), pTexture );310}311312//-------------------------------------------------------------------------------------------------------------------------------------------------------------313314_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScalerBase::outputTexture() const315{316return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) );317}318319//-------------------------------------------------------------------------------------------------------------------------------------------------------------320321_MTLFX_INLINE void MTLFX::SpatialScalerBase::setOutputTexture( MTL::Texture* pTexture )322{323Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputTexture_ ), pTexture );324}325326//-------------------------------------------------------------------------------------------------------------------------------------------------------------327328_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerBase::colorTextureFormat() const329{330return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );331}332333//-------------------------------------------------------------------------------------------------------------------------------------------------------------334335_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerBase::outputTextureFormat() const336{337return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );338}339340//-------------------------------------------------------------------------------------------------------------------------------------------------------------341342_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputWidth() const343{344return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );345}346347//-------------------------------------------------------------------------------------------------------------------------------------------------------------348349_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputHeight() const350{351return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );352}353354//-------------------------------------------------------------------------------------------------------------------------------------------------------------355356_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::outputWidth() const357{358return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );359}360361//-------------------------------------------------------------------------------------------------------------------------------------------------------------362363_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::outputHeight() const364{365return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );366}367368//-------------------------------------------------------------------------------------------------------------------------------------------------------------369370_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScalerBase::colorProcessingMode() const371{372return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) );373}374375//-------------------------------------------------------------------------------------------------------------------------------------------------------------376377_MTLFX_INLINE MTL::Fence* MTLFX::SpatialScalerBase::fence() const378{379return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) );380}381382//-------------------------------------------------------------------------------------------------------------------------------------------------------------383384_MTLFX_INLINE void MTLFX::SpatialScalerBase::setFence( MTL::Fence* pFence )385{386Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setFence_ ), pFence );387}388389//-------------------------------------------------------------------------------------------------------------------------------------------------------------390391_MTLFX_INLINE void MTLFX::SpatialScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer )392{393Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer );394}395396//-------------------------------------------------------------------------------------------------------------------------------------------------------------397398399