Skip to content

Commit

Permalink
Fix clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Nov 16, 2024
1 parent be65a3c commit c41413e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 35 deletions.
3 changes: 2 additions & 1 deletion OgreMain/src/OgreTextureGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,8 @@ namespace Ogre
if( this->getInternalWidth() == colourTarget->getInternalWidth() &&
this->getInternalHeight() == colourTarget->getInternalHeight() &&
this->getSampleDescription() == colourTarget->getSampleDescription() &&
this->isTilerMemoryless() == (colourTarget->isTilerMemoryless() || colourTarget->isTilerDepthMemoryless()) &&
this->isTilerMemoryless() ==
( colourTarget->isTilerMemoryless() || colourTarget->isTilerDepthMemoryless() ) &&
this->isRenderWindowSpecific() == colourTarget->isRenderWindowSpecific() )
{
return true;
Expand Down
4 changes: 3 additions & 1 deletion RenderSystems/Metal/src/OgreMetalRenderPassDescriptor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ of this software and associated documentation files (the "Software"), to deal
return MTLLoadActionDontCare;
case LoadAction::Clear:
return MTLLoadActionClear;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS || ( OGRE_PLATFORM == OGRE_PLATFORM_APPLE && OGRE_CPU == OGRE_CPU_ARM && OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 )
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS || \
( OGRE_PLATFORM == OGRE_PLATFORM_APPLE && OGRE_CPU == OGRE_CPU_ARM && \
OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 )
case LoadAction::ClearOnTilers:
return MTLLoadActionClear;
#else
Expand Down
55 changes: 37 additions & 18 deletions RenderSystems/Metal/src/OgreMetalTextureGpu.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ of this software and associated documentation files (the "Software"), to deal
#include "OgreVector2.h"
#include "Vao/OgreVaoManager.h"

#include "OgreRoot.h"
#import "Metal/MTLBlitCommandEncoder.h"
#include "OgreRoot.h"

namespace Ogre
{
Expand All @@ -55,7 +55,10 @@ of this software and associated documentation files (the "Software"), to deal
_setToDisplayDummyTexture();
}
//-----------------------------------------------------------------------------------
MetalTextureGpu::~MetalTextureGpu() { destroyInternalResourcesImpl(); }
MetalTextureGpu::~MetalTextureGpu()
{
destroyInternalResourcesImpl();
}
//-----------------------------------------------------------------------------------
void MetalTextureGpu::createInternalResourcesImpl()
{
Expand All @@ -80,22 +83,26 @@ of this software and associated documentation files (the "Software"), to deal
if( mTextureType == TextureTypes::TypeCube || mTextureType == TextureTypes::TypeCubeArray )
desc.arrayLength /= 6u;

RenderSystem* rs = Root::getSingleton().getRenderSystem();
RenderSystem *rs = Root::getSingleton().getRenderSystem();
const RenderSystemCapabilities *capabilities = rs->getCapabilities();
bool isTiler = capabilities->hasCapability( RSC_IS_TILER );
if(isTiler && isRenderWindowSpecific() && isRenderToTexture())
if( isTiler && isRenderWindowSpecific() && isRenderToTexture() )
{
ConfigOptionMap& options = rs->getConfigOptions();
Ogre::ConfigOptionMap::iterator opt = options.find("WindowMemoryless");
if(opt!=options.end())
isTiler = opt->second.currentValue=="Yes";
ConfigOptionMap &options = rs->getConfigOptions();
Ogre::ConfigOptionMap::iterator opt = options.find( "WindowMemoryless" );
if( opt != options.end() )
isTiler = opt->second.currentValue == "Yes";
}
if(isTiler)
if( isTiler )
{
if(@available(iOS 10, macOS 11, *))
if( @available( iOS 10, macOS 11, * ) )
{
if( (isTilerMemoryless() && isRenderToTexture()) || (isMultisample() && hasMsaaExplicitResolves() && !isTexture() && isRenderToTexture() && isDiscardableContent()) )
if( ( isTilerMemoryless() && isRenderToTexture() ) ||
( isMultisample() && hasMsaaExplicitResolves() && !isTexture() &&
isRenderToTexture() && isDiscardableContent() ) )
{
desc.storageMode = MTLStorageModeMemoryless;
}
}
}
if( isMultisample() && hasMsaaExplicitResolves() )
Expand Down Expand Up @@ -131,12 +138,15 @@ of this software and associated documentation files (the "Software"), to deal

if( isMultisample() && !hasMsaaExplicitResolves() )
{
if(isTiler)
if( isTiler )
{
if(@available(iOS 10, macOS 11, *))
if( @available( iOS 10, macOS 11, * ) )
{
if(((isTilerMemoryless() || isTilerDepthMemoryless()) && isRenderToTexture()) || (!isTexture() && isRenderToTexture() && isDiscardableContent()) )
if( ( ( isTilerMemoryless() || isTilerDepthMemoryless() ) && isRenderToTexture() ) ||
( !isTexture() && isRenderToTexture() && isDiscardableContent() ) )
{
desc.storageMode = MTLStorageModeMemoryless;
}
}
}
desc.textureType = MTLTextureType2DMultisample;
Expand Down Expand Up @@ -476,9 +486,15 @@ of this software and associated documentation files (the "Software"), to deal
mDesiredDepthBufferFormat = desiredDepthBufferFormat;
}
//-----------------------------------------------------------------------------------
uint16 MetalTextureGpuRenderTarget::getDepthBufferPoolId() const { return mDepthBufferPoolId; }
uint16 MetalTextureGpuRenderTarget::getDepthBufferPoolId() const
{
return mDepthBufferPoolId;
}
//-----------------------------------------------------------------------------------
bool MetalTextureGpuRenderTarget::getPreferDepthTexture() const { return mPreferDepthTexture; }
bool MetalTextureGpuRenderTarget::getPreferDepthTexture() const
{
return mPreferDepthTexture;
}
//-----------------------------------------------------------------------------------
PixelFormatGpu MetalTextureGpuRenderTarget::getDesiredDepthBufferFormat() const
{
Expand All @@ -493,6 +509,9 @@ of this software and associated documentation files (the "Software"), to deal
}
//-----------------------------------------------------------------------------------
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0
OrientationMode MetalTextureGpuRenderTarget::getOrientationMode() const { return mOrientationMode; }
OrientationMode MetalTextureGpuRenderTarget::getOrientationMode() const
{
return mOrientationMode;
}
#endif
}
} // namespace Ogre
12 changes: 7 additions & 5 deletions RenderSystems/Metal/src/OgreMetalTextureGpuManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,27 @@ of this software and associated documentation files (the "Software"), to deal
//-----------------------------------------------------------------------------------
TextureGpu *MetalTextureGpuManager::createTextureGpuWindow( MetalWindow *window )
{
const RenderSystemCapabilities *capabilities = Root::getSingleton().getRenderSystem()->getCapabilities();
const RenderSystemCapabilities *capabilities =
Root::getSingleton().getRenderSystem()->getCapabilities();
const bool isTiler = capabilities->hasCapability( RSC_IS_TILER );
return OGRE_NEW MetalTextureGpuWindow( GpuPageOutStrategy::Discard, mVaoManager, "RenderWindow",
TextureFlags::NotTexture | TextureFlags::RenderToTexture |
(isTiler ? TextureFlags::TilerDepthMemoryless : 0) |
( isTiler ? TextureFlags::TilerDepthMemoryless : 0 ) |
TextureFlags::RenderWindowSpecific |
TextureFlags::DiscardableContent,
TextureTypes::Type2D, this, window );
}
//-----------------------------------------------------------------------------------
TextureGpu *MetalTextureGpuManager::createWindowDepthBuffer()
{
const RenderSystemCapabilities *capabilities = Root::getSingleton().getRenderSystem()->getCapabilities();
const RenderSystemCapabilities *capabilities =
Root::getSingleton().getRenderSystem()->getCapabilities();
const bool isTiler = capabilities->hasCapability( RSC_IS_TILER );
return OGRE_NEW MetalTextureGpuRenderTarget(
GpuPageOutStrategy::Discard, mVaoManager, "RenderWindow DepthBuffer",
TextureFlags::NotTexture | TextureFlags::RenderToTexture |
(isTiler ? TextureFlags::TilerMemoryless : 0) |
TextureFlags::RenderWindowSpecific | TextureFlags::DiscardableContent,
( isTiler ? TextureFlags::TilerMemoryless : 0 ) | TextureFlags::RenderWindowSpecific |
TextureFlags::DiscardableContent,
TextureTypes::Type2D, this );
}
//-----------------------------------------------------------------------------------
Expand Down
20 changes: 10 additions & 10 deletions RenderSystems/Metal/src/OgreMetalWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ of this software and associated documentation files (the "Software"), to deal
#include "OgreMetalTextureGpuWindow.h"
#include "OgrePixelFormatGpuUtils.h"
#include "OgreRenderSystem.h"
#include "OgreRoot.h"
#include "OgreStringConverter.h"
#include "OgreViewport.h"
#include "OgreWindowEventUtilities.h"
#include "OgreRoot.h"

#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS

Expand Down Expand Up @@ -198,20 +198,20 @@ static void SetupMetalWindowListeners( Ogre::MetalWindow *metalWindow, NSWindow
desc.sampleCount = mSampleDescription.getColourSamples();
desc.usage = MTLTextureUsageRenderTarget;
desc.storageMode = MTLStorageModePrivate;
RenderSystem* rs = Root::getSingleton().getRenderSystem();
assert(rs);
RenderSystem *rs = Root::getSingleton().getRenderSystem();
assert( rs );
const RenderSystemCapabilities *capabilities = rs->getCapabilities();
bool isTiler = capabilities->hasCapability( RSC_IS_TILER );
if(isTiler)
if( isTiler )
{
ConfigOptionMap& options = rs->getConfigOptions();
Ogre::ConfigOptionMap::iterator opt = options.find("WindowMemoryless");
if(opt!=options.end())
isTiler = opt->second.currentValue=="Yes";
ConfigOptionMap &options = rs->getConfigOptions();
Ogre::ConfigOptionMap::iterator opt = options.find( "WindowMemoryless" );
if( opt != options.end() )
isTiler = opt->second.currentValue == "Yes";
}
if(isTiler)
if( isTiler )
{
if(@available(iOS 10, macOS 11, *))
if( @available( iOS 10, macOS 11, * ) )
desc.storageMode = MTLStorageModeMemoryless;
}

Expand Down

0 comments on commit c41413e

Please sign in to comment.