Skip to content

Commit

Permalink
Add override and finality to D3D11 classes (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Dec 27, 2021
1 parent 5288ec4 commit 920e408
Show file tree
Hide file tree
Showing 35 changed files with 482 additions and 487 deletions.
2 changes: 1 addition & 1 deletion OgreMain/src/OgreRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ THE SOFTWARE.
# define WIN32_LEAN_AND_MEAN
# define VC_EXTRALEAN
# define NOMINMAX
# include <Windows.h>
# include <windows.h>
# endif
#endif

Expand Down
16 changes: 8 additions & 8 deletions RenderSystems/Direct3D11/include/OgreD3D11AsyncTextureTicket.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Ogre
{
/** See AsyncTextureTicket
*/
class _OgreD3D11Export D3D11AsyncTextureTicket : public AsyncTextureTicket
class _OgreD3D11Export D3D11AsyncTextureTicket final : public AsyncTextureTicket
{
protected:
ComPtr<ID3D11Resource> mStagingTexture;
Expand All @@ -48,24 +48,24 @@ namespace Ogre
uint32 mMappedSlice;
bool mIsArray2DTexture;

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

virtual bool canMapMoreThanOneSlice() const;
bool canMapMoreThanOneSlice() const override;

void waitForDownloadToFinish();

virtual void downloadFromGpu( TextureGpu *textureSrc, uint8 mipLevel,
bool accurateTracking, TextureBox *srcBox=0 );
void downloadFromGpu( TextureGpu *textureSrc, uint8 mipLevel, bool accurateTracking,
TextureBox *srcBox = 0 ) override;

public:
D3D11AsyncTextureTicket( uint32 width, uint32 height, uint32 depthOrSlices,
TextureTypes::TextureTypes textureType,
PixelFormatGpu pixelFormatFamily,
D3D11VaoManager *vaoManager );
virtual ~D3D11AsyncTextureTicket();
~D3D11AsyncTextureTicket() override;

virtual bool queryIsTransferDone();
bool queryIsTransferDone() override;
};
}

Expand Down
8 changes: 4 additions & 4 deletions RenderSystems/Direct3D11/include/OgreD3D11GpuProgramManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ THE SOFTWARE.

namespace Ogre {

class _OgreD3D11Export D3D11GpuProgramManager : public GpuProgramManager
class _OgreD3D11Export D3D11GpuProgramManager final : public GpuProgramManager
{
protected:
/// @copydoc ResourceManager::createImpl
Resource* createImpl(const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader,
const NameValuePairList* createParams);
const NameValuePairList* createParams) override;
/// Specialised create method with specific parameters
Resource* createImpl(const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader,
GpuProgramType gptype, const String& syntaxCode);
GpuProgramType gptype, const String& syntaxCode) override;
public:
D3D11GpuProgramManager();
~D3D11GpuProgramManager();
~D3D11GpuProgramManager() override;
};

}
Expand Down
55 changes: 27 additions & 28 deletions RenderSystems/Direct3D11/include/OgreD3D11HLSLProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,44 @@ namespace Ogre {
reason for not wanting to use the Cg plugin, I suggest you use Cg instead since that
can produce programs for OpenGL too.
*/
class _OgreD3D11Export D3D11HLSLProgram
: public HighLevelGpuProgram
, protected D3D11DeviceResource
class _OgreD3D11Export D3D11HLSLProgram final : public HighLevelGpuProgram,
protected D3D11DeviceResource
{
public:
/// Command object for setting entry point
class CmdEntryPoint : public ParamCommand
class CmdEntryPoint final : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
String doGet(const void* target) const override;
void doSet(void* target, const String& val) override;
};
/// Command object for setting target assembler
class CmdTarget : public ParamCommand
class CmdTarget final : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
String doGet(const void* target) const override;
void doSet(void* target, const String& val) override;
};
/// Command object for setting macro defines
class CmdPreprocessorDefines : public ParamCommand
class CmdPreprocessorDefines final : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
String doGet(const void* target) const override;
void doSet(void* target, const String& val) override;
};
/// Command object for setting matrix packing in column-major order
class CmdColumnMajorMatrices : public ParamCommand
class CmdColumnMajorMatrices final : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
String doGet(const void* target) const override;
void doSet(void* target, const String& val) override;
};
/// Command object for setting backwards compatibility
class CmdEnableBackwardsCompatibility : public ParamCommand
class CmdEnableBackwardsCompatibility final : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
String doGet(const void* target) const override;
void doSet(void* target, const String& val) override;
};

protected:
Expand All @@ -95,14 +94,14 @@ namespace Ogre {
static CmdColumnMajorMatrices msCmdColumnMajorMatrices;
static CmdEnableBackwardsCompatibility msCmdEnableBackwardsCompatibility;

void notifyDeviceLost(D3D11Device* device);
void notifyDeviceRestored(D3D11Device* device, unsigned pass);
void notifyDeviceLost(D3D11Device* device) override;
void notifyDeviceRestored(D3D11Device* device, unsigned pass) override;

/** Internal method for creating an appropriate low-level program from this
high-level program, must be implemented by subclasses. */
void createLowLevelImpl();
void createLowLevelImpl() override;
/// Internal unload implementation, must be implemented by subclasses
void unloadHighLevelImpl();
void unloadHighLevelImpl() override;

// Recursive utility method for populateParameterNames
void processParamElement(String prefix, LPCSTR pName, ID3D11ShaderReflectionType* varRefType);
Expand Down Expand Up @@ -295,7 +294,7 @@ namespace Ogre {
public:
D3D11HLSLProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
~D3D11HLSLProgram();
~D3D11HLSLProgram() override;

/** Sets the entry point for this program ie the first method called. */
void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
Expand All @@ -321,13 +320,13 @@ namespace Ogre {
/** Gets whether backwards compatibility is enabled. */
bool getEnableBackwardsCompatibility() const { return mEnableBackwardsCompatibility; }
/// Overridden from GpuProgram
bool isSupported() const;
bool isSupported() const override;
/// Overridden from GpuProgram
GpuProgramParametersSharedPtr createParameters();
GpuProgramParametersSharedPtr createParameters() override;
/// Overridden from GpuProgram
const String& getLanguage() const;
const String& getLanguage() const override;

virtual void buildConstantDefinitions() const;
void buildConstantDefinitions() const override;
ID3D11VertexShader* getVertexShader() const;
ID3D11PixelShader* getPixelShader() const;
ID3D11GeometryShader* getGeometryShader() const;
Expand All @@ -354,7 +353,7 @@ namespace Ogre {

/** Internal load implementation, must be implemented by subclasses.
*/
void loadFromSource();
void loadFromSource() override;

void reinterpretGSForStreamOut();
bool mReinterpretingGS;
Expand Down
10 changes: 5 additions & 5 deletions RenderSystems/Direct3D11/include/OgreD3D11HLSLProgramFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ THE SOFTWARE.
namespace Ogre
{
/** Factory class for D3D11 HLSL programs. */
class _OgreD3D11Export D3D11HLSLProgramFactory : public HighLevelGpuProgramFactory
class _OgreD3D11Export D3D11HLSLProgramFactory final : public HighLevelGpuProgramFactory
{
protected:
static String sLanguageName;
D3D11Device & mDevice;
public:
D3D11HLSLProgramFactory(D3D11Device & device);
~D3D11HLSLProgramFactory();
~D3D11HLSLProgramFactory() override;
/// Get the name of the language this factory creates programs for
const String& getLanguage() const;
const String& getLanguage() const override;
HighLevelGpuProgram* create(ResourceManager* creator,
const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader);
void destroy(HighLevelGpuProgram* prog);
const String& group, bool isManual, ManualResourceLoader* loader) override;
void destroy(HighLevelGpuProgram* prog) override;

};
}
Expand Down
24 changes: 12 additions & 12 deletions RenderSystems/Direct3D11/include/OgreD3D11HardwareBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace v1 {
/** Base implementation of a D3D11 buffer, dealing with all the common
aspects.
*/
class _OgreD3D11Export D3D11HardwareBuffer : public HardwareBuffer,
protected D3D11DeviceResource
class _OgreD3D11Export D3D11HardwareBuffer final : public HardwareBuffer,
protected D3D11DeviceResource
{
public:
enum BufferType
Expand All @@ -60,29 +60,29 @@ namespace v1 {


/** See HardwareBuffer. */
void* lockImpl(size_t offset, size_t length, LockOptions options);
void* lockImpl(size_t offset, size_t length, LockOptions options) override;
/** See HardwareBuffer. */
void unlockImpl();
void unlockImpl() override;

void notifyDeviceLost( D3D11Device *device );
void notifyDeviceRestored( D3D11Device *device, unsigned pass );
void notifyDeviceLost( D3D11Device *device ) override;
void notifyDeviceRestored( D3D11Device *device, unsigned pass ) override;

public:
D3D11HardwareBuffer(BufferType btype, size_t sizeBytes, HardwareBuffer::Usage usage,
D3D11Device & device, bool useSystemMem, bool useShadowBuffer, bool streamOut);
~D3D11HardwareBuffer();
~D3D11HardwareBuffer() override;
/** See HardwareBuffer. */
void readData(size_t offset, size_t length, void* pDest);
void readData(size_t offset, size_t length, void* pDest) override;
/** See HardwareBuffer. */
void writeData(size_t offset, size_t length, const void* pSource,
bool discardWholeBuffer = false);
bool discardWholeBuffer = false) override;
/** See HardwareBuffer. We perform a hardware copy here. */
void copyData(HardwareBuffer& srcBuffer, size_t srcOffset,
size_t dstOffset, size_t length, bool discardWholeBuffer = false);
size_t dstOffset, size_t length, bool discardWholeBuffer = false) override;
void copyDataImpl(HardwareBuffer& srcBuffer, size_t srcOffset,
size_t dstOffset, size_t length, bool discardWholeBuffer = false);
size_t dstOffset, size_t length, bool discardWholeBuffer = false);
/// Updates the real buffer from the shadow buffer, if required
virtual void _updateFromShadow();
void _updateFromShadow() override;

/// Get the D3D-specific buffer
ID3D11Buffer* getD3DBuffer() { return mlpD3DBuffer.Get(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Ogre {
namespace v1 {

/** Implementation of HardwareBufferManager for D3D11. */
class _OgreD3D11Export D3D11HardwareBufferManagerBase : public HardwareBufferManagerBase
class _OgreD3D11Export D3D11HardwareBufferManagerBase final : public HardwareBufferManagerBase
{
protected:
D3D11Device & mlpD3DDevice;
Expand All @@ -45,33 +45,33 @@ namespace v1 {
~D3D11HardwareBufferManagerBase();
/// Creates a vertex buffer
HardwareVertexBufferSharedPtr
createVertexBuffer(size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
createVertexBuffer(size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false) override;
/// Creates a stream output vertex buffer
HardwareVertexBufferSharedPtr
createStreamOutputVertexBuffer(size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
/// Create a hardware vertex buffer
HardwareIndexBufferSharedPtr
createIndexBuffer(HardwareIndexBuffer::IndexType itype, size_t numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
createIndexBuffer(HardwareIndexBuffer::IndexType itype, size_t numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer = false) override;
/// @copydoc HardwareBufferManager::createUniformBuffer
HardwareUniformBufferSharedPtr createUniformBuffer(size_t sizeBytes,
HardwareBuffer::Usage usage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
bool useShadowBuffer = false, const String& name = "");
bool useShadowBuffer = false, const String& name = "") override;
/// @copydoc HardwareBufferManager::createCounterBuffer
HardwareCounterBufferSharedPtr createCounterBuffer(size_t sizeBytes,
HardwareBuffer::Usage usage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
bool useShadowBuffer = false, const String& name = "");
bool useShadowBuffer = false, const String& name = "") override;
};

/// D3D11HardwareBufferManagerBase as a Singleton
class _OgreD3D11Export D3D11HardwareBufferManager : public HardwareBufferManager
class _OgreD3D11Export D3D11HardwareBufferManager final : public HardwareBufferManager
{
public:
D3D11HardwareBufferManager(D3D11Device & device)
: HardwareBufferManager(OGRE_NEW D3D11HardwareBufferManagerBase(device))
{

}
~D3D11HardwareBufferManager()
~D3D11HardwareBufferManager() override
{
OGRE_DELETE mImpl;
}
Expand Down
18 changes: 9 additions & 9 deletions RenderSystems/Direct3D11/include/OgreD3D11HardwareIndexBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@ THE SOFTWARE.
namespace Ogre {
namespace v1 {

class _OgreD3D11Export D3D11HardwareIndexBuffer : public HardwareIndexBuffer
class _OgreD3D11Export D3D11HardwareIndexBuffer final : public HardwareIndexBuffer
{
protected:
D3D11HardwareBuffer* mBufferImpl;
// have to implement these, but do nothing as overridden lock/unlock
void* lockImpl(size_t offset, size_t length, LockOptions options) {return 0;}
void unlockImpl() {}
void* lockImpl(size_t offset, size_t length, LockOptions options) override {return 0;}
void unlockImpl() override {}

public:
D3D11HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, size_t numIndexes,
HardwareBuffer::Usage usage, D3D11Device & device, bool useSystemMem, bool useShadowBuffer);
~D3D11HardwareIndexBuffer();
~D3D11HardwareIndexBuffer() override;

// override all data-gathering methods
void* lock(size_t offset, size_t length, LockOptions options);
void unlock();
void readData(size_t offset, size_t length, void* pDest);
void* lock(size_t offset, size_t length, LockOptions options) override;
void unlock() override;
void readData(size_t offset, size_t length, void* pDest) override;
void writeData(size_t offset, size_t length, const void* pSource,
bool discardWholeBuffer = false);
bool discardWholeBuffer = false) override;

void copyData(HardwareBuffer& srcBuffer, size_t srcOffset,
size_t dstOffset, size_t length, bool discardWholeBuffer = false);
size_t dstOffset, size_t length, bool discardWholeBuffer = false) override;
bool isLocked() const;

/// Get the D3D-specific index buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Ogre {
* Updated on 12/7/2004 by Chris McGuirk
* Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr
*/
class _OgreD3D11Export D3D11HardwareOcclusionQuery : public HardwareOcclusionQuery
class _OgreD3D11Export D3D11HardwareOcclusionQuery final : public HardwareOcclusionQuery
{
//----------------------------------------------------------------------
// Public methods
Expand All @@ -66,17 +66,17 @@ namespace Ogre {
/**
* Object destructor
*/
~D3D11HardwareOcclusionQuery();
~D3D11HardwareOcclusionQuery() override;

//------------------------------------------------------------------
// Occlusion query functions (see base class documentation for this)
//--

void beginOcclusionQuery();
void endOcclusionQuery();
bool pullOcclusionQuery( unsigned int* NumOfFragments);
void beginOcclusionQuery() override;
void endOcclusionQuery() override;
bool pullOcclusionQuery( unsigned int* NumOfFragments) override;
unsigned int getLastQuerysPixelcount() { return mPixelCount; }
bool isStillOutstanding();
bool isStillOutstanding() override;



Expand Down
Loading

0 comments on commit 920e408

Please sign in to comment.