Skip to content

Commit

Permalink
Apply clang format to D3D11 (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Jan 2, 2022
1 parent de6dc58 commit 26e42aa
Show file tree
Hide file tree
Showing 97 changed files with 7,022 additions and 7,068 deletions.
43 changes: 43 additions & 0 deletions RenderSystems/Direct3D11/include/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
BasedOnStyle: Google
AlignAfterOpenBracket: Align
#AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: DontAlign
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
BinPackParameters: 'true'
BreakBeforeBraces: Custom
ColumnLimit: '105'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
BreakConstructorInitializers: 'AfterColon'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'false'
DerivePointerAlignment: 'false'
IndentCaseLabels: 'false'
IndentWidth: '4'
NamespaceIndentation: All
PointerAlignment: Right
SpaceBeforeParens: Never
SpaceInEmptyParentheses: 'false'
SpacesInParentheses: 'true'
TabWidth: '4'
UseTab: Never
AccessModifierOffset: '-4'
IndentPPDirectives: 'AfterHash'
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false

...
18 changes: 9 additions & 9 deletions RenderSystems/Direct3D11/include/OgreD3D11AsyncTextureTicket.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,27 @@ THE SOFTWARE.
#define _OgreD3D11AsyncTextureTicket_H_

#include "OgreD3D11Prerequisites.h"

#include "OgreAsyncTextureTicket.h"
#include "OgreTextureBox.h"

namespace Ogre
{
/** See AsyncTextureTicket
*/
*/
class _OgreD3D11Export D3D11AsyncTextureTicket final : public AsyncTextureTicket
{
protected:
ComPtr<ID3D11Resource> mStagingTexture;

uint32 mDownloadFrame;
uint32 mDownloadFrame;
ComPtr<ID3D11Query> mAccurateFence;
D3D11VaoManager *mVaoManager;
uint32 mMappedSlice;
bool mIsArray2DTexture;
D3D11VaoManager * mVaoManager;
uint32 mMappedSlice;
bool mIsArray2DTexture;

TextureBox mapImpl( uint32 slice ) override;
void unmapImpl() override;
void unmapImpl() override;

bool canMapMoreThanOneSlice() const override;

Expand All @@ -61,12 +62,11 @@ namespace Ogre
public:
D3D11AsyncTextureTicket( uint32 width, uint32 height, uint32 depthOrSlices,
TextureTypes::TextureTypes textureType,
PixelFormatGpu pixelFormatFamily,
D3D11VaoManager *vaoManager );
PixelFormatGpu pixelFormatFamily, D3D11VaoManager *vaoManager );
~D3D11AsyncTextureTicket() override;

bool queryIsTransferDone() override;
};
}
} // namespace Ogre

#endif
77 changes: 41 additions & 36 deletions RenderSystems/Direct3D11/include/OgreD3D11Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,70 @@ THE SOFTWARE.
#ifndef __D3D11DEVICE_H__
#define __D3D11DEVICE_H__


#include "OgreD3D11Prerequisites.h"

namespace Ogre
{
class _OgreD3D11Export D3D11Device
{
private:
ComPtr<ID3D11DeviceN> mD3D11Device;
ComPtr<ID3D11Device1> mD3D11Device1;
ComPtr<ID3D11DeviceContextN> mImmediateContext;
ComPtr<ID3D11DeviceContext1> mImmediateContext1;
ComPtr<ID3D11ClassLinkage> mClassLinkage;
ComPtr<ID3D11InfoQueue> mInfoQueue;
LARGE_INTEGER mDriverVersion;
ComPtr<IDXGIFactoryN> mDXGIFactory;
ComPtr<IDXGIFactory2> mDXGIFactory2;
ComPtr<ID3D11DeviceN> mD3D11Device;
ComPtr<ID3D11Device1> mD3D11Device1;
ComPtr<ID3D11DeviceContextN> mImmediateContext;
ComPtr<ID3D11DeviceContext1> mImmediateContext1;
ComPtr<ID3D11ClassLinkage> mClassLinkage;
ComPtr<ID3D11InfoQueue> mInfoQueue;
LARGE_INTEGER mDriverVersion;
ComPtr<IDXGIFactoryN> mDXGIFactory;
ComPtr<IDXGIFactory2> mDXGIFactory2;
#if OGRE_D3D11_PROFILING || OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM
ComPtr<ID3DUserDefinedAnnotation> mPerf;
#endif

const D3D11Device& operator=(D3D11Device& device); /* intentionally not implemented */
const D3D11Device &operator=( D3D11Device &device ); /* intentionally not implemented */

public:
D3D11Device();
~D3D11Device();

void ReleaseAll();
void TransferOwnership(ComPtr<ID3D11Device>& device);
void TransferOwnership( ComPtr<ID3D11Device> &device );
bool IsDeviceLost();

bool isNull() { return !mD3D11Device; }
ID3D11DeviceN* get() { return mD3D11Device.Get(); }
ID3D11DeviceContextN* GetImmediateContext() { return mImmediateContext.Get(); }
ID3D11DeviceContext1* GetImmediateContext1() { return mImmediateContext1.Get(); }
ID3D11ClassLinkage* GetClassLinkage() { return mClassLinkage.Get(); }
IDXGIFactoryN* GetDXGIFactory() { return mDXGIFactory.Get(); }
IDXGIFactory2* GetDXGIFactory2() { return mDXGIFactory2.Get(); }
LARGE_INTEGER GetDriverVersion() { return mDriverVersion; }
bool isNull() { return !mD3D11Device; }
ID3D11DeviceN * get() { return mD3D11Device.Get(); }
ID3D11DeviceContextN *GetImmediateContext() { return mImmediateContext.Get(); }
ID3D11DeviceContext1 *GetImmediateContext1() { return mImmediateContext1.Get(); }
ID3D11ClassLinkage * GetClassLinkage() { return mClassLinkage.Get(); }
IDXGIFactoryN * GetDXGIFactory() { return mDXGIFactory.Get(); }
IDXGIFactory2 * GetDXGIFactory2() { return mDXGIFactory2.Get(); }

LARGE_INTEGER GetDriverVersion() { return mDriverVersion; }
#if OGRE_D3D11_PROFILING || OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM
ID3DUserDefinedAnnotation* GetProfiler() { return mPerf.Get(); }
ID3DUserDefinedAnnotation *GetProfiler() { return mPerf.Get(); }
#endif
ID3D11DeviceN* operator->() const

ID3D11DeviceN *operator->() const
{
assert(mD3D11Device);
if (D3D_NO_EXCEPTION != mExceptionsErrorLevel)
assert( mD3D11Device );
if( D3D_NO_EXCEPTION != mExceptionsErrorLevel )
{
clearStoredErrorMessages();
}
return mD3D11Device.Get();
}

void throwIfFailed(HRESULT hr, const char* desc, const char* src);
void throwIfFailed(const char* desc, const char* src) { throwIfFailed(NO_ERROR, desc, src); }
void throwIfFailed( HRESULT hr, const char *desc, const char *src );
void throwIfFailed( const char *desc, const char *src ) { throwIfFailed( NO_ERROR, desc, src ); }

String getErrorDescription(const HRESULT hr = NO_ERROR) const;
void clearStoredErrorMessages() const;
bool _getErrorsFromQueue() const;
String getErrorDescription( const HRESULT hr = NO_ERROR ) const;
void clearStoredErrorMessages() const;
bool _getErrorsFromQueue() const;

bool isError() const { return (D3D_NO_EXCEPTION == mExceptionsErrorLevel) ? false : _getErrorsFromQueue(); }
bool isError() const
{
return ( D3D_NO_EXCEPTION == mExceptionsErrorLevel ) ? false : _getErrorsFromQueue();
}

enum eExceptionsErrorLevel
{
Expand All @@ -101,11 +104,13 @@ namespace Ogre

static eExceptionsErrorLevel mExceptionsErrorLevel;
static eExceptionsErrorLevel getExceptionsErrorLevel();
static void setExceptionsErrorLevel(const eExceptionsErrorLevel exceptionsErrorLevel);
static void setExceptionsErrorLevel(const Ogre::String& exceptionsErrorLevel);
static void setExceptionsErrorLevel( const eExceptionsErrorLevel exceptionsErrorLevel );
static void setExceptionsErrorLevel( const Ogre::String &exceptionsErrorLevel );

static D3D_FEATURE_LEVEL parseFeatureLevel(const Ogre::String& value, D3D_FEATURE_LEVEL fallback);
static D3D_DRIVER_TYPE parseDriverType(const Ogre::String& value, D3D_DRIVER_TYPE fallback = D3D_DRIVER_TYPE_HARDWARE);
static D3D_FEATURE_LEVEL parseFeatureLevel( const Ogre::String &value,
D3D_FEATURE_LEVEL fallback );
static D3D_DRIVER_TYPE parseDriverType( const Ogre::String &value,
D3D_DRIVER_TYPE fallback = D3D_DRIVER_TYPE_HARDWARE );
};
}
} // namespace Ogre
#endif
29 changes: 13 additions & 16 deletions RenderSystems/Direct3D11/include/OgreD3D11DeviceResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,49 @@ THE SOFTWARE.

#include "ogrestd/vector.h"

namespace Ogre {

namespace Ogre
{
/** Represents a Direct3D rendering resource.
Provide unified interface to handle various device states.
This class is intended to be used as protected base.
*/
class D3D11DeviceResource
{
public:

// Called immediately after the Direct3D device has entered a removed state.
// This is the place to release device depended resources.
virtual void notifyDeviceLost(D3D11Device* device) = 0;
virtual void notifyDeviceLost( D3D11Device *device ) = 0;

// Called immediately after the Direct3D device has been reset.
// This is the place to create device depended resources.
virtual void notifyDeviceRestored(D3D11Device* device, unsigned pass) = 0;
virtual void notifyDeviceRestored( D3D11Device *device, unsigned pass ) = 0;

protected:
D3D11DeviceResource();
~D3D11DeviceResource(); // protected and non-virtual
~D3D11DeviceResource(); // protected and non-virtual
};


/** Singleton that is used to propagate device state changed notifications.
This class is intended to be used as protected base.
*/
class D3D11DeviceResourceManager
{
public:
void notifyResourceCreated( D3D11DeviceResource *deviceResource );
void notifyResourceDestroyed( D3D11DeviceResource *deviceResource );

void notifyResourceCreated(D3D11DeviceResource* deviceResource);
void notifyResourceDestroyed(D3D11DeviceResource* deviceResource);

void notifyDeviceLost(D3D11Device* device);
void notifyDeviceRestored(D3D11Device* device);
void notifyDeviceLost( D3D11Device *device );
void notifyDeviceRestored( D3D11Device *device );

static D3D11DeviceResourceManager* get();
static D3D11DeviceResourceManager *get();

protected:
D3D11DeviceResourceManager();
~D3D11DeviceResourceManager(); // protected and non-virtual
~D3D11DeviceResourceManager(); // protected and non-virtual

private:
vector<D3D11DeviceResource*>::type mResources, mResourcesCopy;
vector<D3D11DeviceResource *>::type mResources, mResourcesCopy;
};

}
} // namespace Ogre
#endif
21 changes: 11 additions & 10 deletions RenderSystems/Direct3D11/include/OgreD3D11Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,36 @@ THE SOFTWARE.
#define __D3D11DRIVER_H__

#include "OgreD3D11Prerequisites.h"

#include "OgreSharedPtr.h"

namespace Ogre
{

class D3D11VideoModeList;
class D3D11VideoMode;

class _OgreD3D11Export D3D11Driver
{
private:
ComPtr<IDXGIAdapterN> mDXGIAdapter;
DXGI_ADAPTER_DESC1 mAdapterIdentifier;
unsigned mSameNameAdapterIndex;
ComPtr<IDXGIAdapterN> mDXGIAdapter;
DXGI_ADAPTER_DESC1 mAdapterIdentifier;
unsigned mSameNameAdapterIndex;
SharedPtr<D3D11VideoModeList> mVideoModeList;

public:
// Constructors
D3D11Driver(); // Default
D3D11Driver( IDXGIAdapterN* pDXGIAdapter, const DXGI_ADAPTER_DESC1& desc, unsigned sameNameIndex);
D3D11Driver(); // Default
D3D11Driver( IDXGIAdapterN *pDXGIAdapter, const DXGI_ADAPTER_DESC1 &desc,
unsigned sameNameIndex );
~D3D11Driver();

// Information accessors
String DriverDescription() const;

// change the device
const DXGI_ADAPTER_DESC1& getAdapterIdentifier() const;
IDXGIAdapterN* getDeviceAdapter() const;
D3D11VideoModeList* getVideoModeList();
const DXGI_ADAPTER_DESC1 &getAdapterIdentifier() const;
IDXGIAdapterN * getDeviceAdapter() const;
D3D11VideoModeList * getVideoModeList();
};
}
} // namespace Ogre
#endif
18 changes: 10 additions & 8 deletions RenderSystems/Direct3D11/include/OgreD3D11DriverList.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,32 @@ THE SOFTWARE.
#define __D3D11DRIVERLIST_H__

#include "OgreD3D11Prerequisites.h"

#include "OgreSharedPtr.h"

#include "ogrestd/vector.h"

namespace Ogre
namespace Ogre
{
class _OgreD3D11Export D3D11DriverList
{
public:
D3D11DriverList(); // does nothing, call refresh() to initialize
D3D11DriverList(); // does nothing, call refresh() to initialize
~D3D11DriverList();

void refresh();
void clear();

size_t count() const; /// does not include hidden drivers like NVPerfHUD
D3D11Driver* item( size_t index );
D3D11Driver* item( const String &name );
size_t count() const; /// does not include hidden drivers like NVPerfHUD
D3D11Driver *item( size_t index );
D3D11Driver *item( const String &name );

D3D11Driver* findByName( const String &name ); // never fail but can return default driver if requested is not found
D3D11Driver *findByName(
const String &name ); // never fail but can return default driver if requested is not found

private:
vector<SharedPtr<D3D11Driver> >::type mDriverList;
unsigned mHiddenDriversCount;
unsigned mHiddenDriversCount;
};
}
} // namespace Ogre
#endif
Loading

0 comments on commit 26e42aa

Please sign in to comment.