Commit 0a387ab4 authored by D-AIRY's avatar D-AIRY

Comments; style refactor

parent 1da6165f
This diff is collapsed.
......@@ -7,12 +7,13 @@ class CGXBlendState: public IGXBlendState
{
friend class CGXContext;
CGXBlendState(CGXContext * pRender):m_pRender(pRender)
CGXBlendState(CGXContext *pRender):
m_pRender(pRender)
{
};
~CGXBlendState();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11BlendState *m_pStateBlock = NULL;
GXBLEND_DESC m_desc;
......@@ -20,7 +21,7 @@ class CGXBlendState: public IGXBlendState
void onDevRst();
public:
void Release();
void Release() override;
};
#endif
......@@ -10,7 +10,7 @@ void CGXConstantBuffer::Release()
}
}
CGXConstantBuffer::CGXConstantBuffer(CGXContext * pRender, UINT uSize):
CGXConstantBuffer::CGXConstantBuffer(CGXContext *pRender, UINT uSize):
m_pRender(pRender)
{
D3D11_BUFFER_DESC bufferDesc;
......
......@@ -7,18 +7,18 @@ class CGXConstantBuffer: public IGXConstantBuffer
{
friend class CGXContext;
CGXConstantBuffer(CGXContext * pRender, UINT uSize);
CGXConstantBuffer(CGXContext *pRender, UINT uSize);
~CGXConstantBuffer();
void update(const void *pData);
UINT getSize();
void update(const void *pData) override;
UINT getSize() override;
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11Buffer *m_pBuffer;
UINT m_uSize;
public:
void Release();
void Release() override;
};
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -7,12 +7,13 @@ class CGXDepthStencilState: public IGXDepthStencilState
{
friend class CGXContext;
CGXDepthStencilState(CGXContext * pRender):m_pRender(pRender)
CGXDepthStencilState(CGXContext *pRender):
m_pRender(pRender)
{
};
~CGXDepthStencilState();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11DepthStencilState *m_pStateBlock = NULL;
GXDEPTH_STENCIL_DESC m_desc;
......@@ -20,7 +21,7 @@ class CGXDepthStencilState: public IGXDepthStencilState
void onDevRst();
public:
void Release();
void Release() override;
};
#endif
......@@ -7,12 +7,13 @@ class CGXDepthStencilSurface: public IGXDepthStencilSurface
{
friend class CGXContext;
CGXDepthStencilSurface(CGXContext * pRender):m_pRender(pRender)
CGXDepthStencilSurface(CGXContext * pRender):
m_pRender(pRender)
{
};
}
~CGXDepthStencilSurface();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11DepthStencilView *m_pSurface = NULL;
ID3D11Texture2D *m_pBuffer = NULL;
......@@ -27,7 +28,7 @@ class CGXDepthStencilSurface: public IGXDepthStencilSurface
void onDevRst(UINT uScreenWidth, UINT uScreenHeight);
public:
void Release();
void Release() override;
};
#endif
......@@ -7,12 +7,13 @@ class CGXIndexBuffer: public IGXIndexBuffer
{
friend class CGXContext;
CGXIndexBuffer(CGXContext * pRender):m_pRender(pRender)
CGXIndexBuffer(CGXContext *pRender):
m_pRender(pRender)
{
};
}
~CGXIndexBuffer();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11Buffer *m_pBuffer;
DXGI_FORMAT m_format;
bool m_wasReset = true;
......@@ -21,12 +22,12 @@ class CGXIndexBuffer: public IGXIndexBuffer
bool m_isLockable = true;
public:
void Release();
void Release() override;
bool lock(void **ppData, GXBUFFERLOCK mode);
void unlock();
bool lock(void **ppData, GXBUFFERLOCK mode) override;
void unlock() override;
bool wasReset();
bool wasReset() override;
};
#endif
......@@ -7,12 +7,13 @@ class CGXRasterizerState: public IGXRasterizerState
{
friend class CGXContext;
CGXRasterizerState(CGXContext * pRender):m_pRender(pRender)
CGXRasterizerState(CGXContext *pRender):
m_pRender(pRender)
{
};
}
~CGXRasterizerState();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11RasterizerState *m_pStateBlock = NULL;
BOOL m_isScissorsEnabled = 0;
GXRASTERIZER_DESC m_desc;
......@@ -21,7 +22,7 @@ class CGXRasterizerState: public IGXRasterizerState
void onDevRst();
public:
void Release();
void Release() override;
};
#endif
#include "GXRenderBuffer.h"
CGXRenderBuffer::CGXRenderBuffer(CGXContext * pRender, UINT uCountStreams, IGXVertexBuffer **ppVertexBuffers, IGXVertexDeclaration *pVertexDeclaration):
CGXRenderBuffer::CGXRenderBuffer(CGXContext *pRender, UINT uCountStreams, IGXVertexBuffer **ppVertexBuffers, IGXVertexDeclaration *pVertexDeclaration):
m_pRender(pRender),
m_uStreamCount(uCountStreams),
m_pVertexDeclaration(pVertexDeclaration)
......
......@@ -7,17 +7,17 @@ class CGXRenderBuffer: public IGXRenderBuffer
{
friend class CGXContext;
CGXRenderBuffer(CGXContext * pRender, UINT uCountStreams, IGXVertexBuffer **ppVertexBuffers, IGXVertexDeclaration *pVertexDeclaration);
CGXRenderBuffer(CGXContext *pRender, UINT uCountStreams, IGXVertexBuffer **ppVertexBuffers, IGXVertexDeclaration *pVertexDeclaration);
CGXContext * m_pRender;
CGXContext *m_pRender;
IGXVertexBuffer *m_ppVertexBuffers[MAXGXVSTREAM];
IGXVertexBuffer *m_ppVertexBuffers[GX_MAX_VSTREAM];
IGXVertexDeclaration *m_pVertexDeclaration;
UINT m_uStreamCount;
public:
void Release();
void Release() override;
};
#endif
......@@ -7,11 +7,12 @@ class CGXSamplerState: public IGXSamplerState
{
friend class CGXContext;
CGXSamplerState(CGXContext * pRender):m_pRender(pRender)
CGXSamplerState(CGXContext *pRender):
m_pRender(pRender)
{
};
}
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11SamplerState *m_pStateBlock;
GXSAMPLER_DESC m_desc;
......@@ -19,7 +20,7 @@ class CGXSamplerState: public IGXSamplerState
void onDevRst();
public:
void Release();
void Release() override;
};
#endif
......@@ -7,92 +7,96 @@ class CGXVertexShader: public IGXVertexShader
{
friend class CGXContext;
CGXVertexShader(CGXContext * pRender):m_pRender(pRender)
CGXVertexShader(CGXContext *pRender):
m_pRender(pRender)
{
}
~CGXVertexShader();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11VertexShader *m_pShader = NULL;
ID3DBlob *m_pShaderBlob = NULL;
public:
void Release();
void Release() override;
void setConstantF(UINT uStartRegister, const float *pConstantData, UINT uVector4fCount);
void setConstantI(UINT uStartRegister, const int *pConstantData, UINT uVector4iCount);
UINT getConstantCount();
UINT getConstantLocation(const char *szConstName);
UINT getConstantSizeV4(const char *szConstName);
void setConstantF(UINT uStartRegister, const float *pConstantData, UINT uVector4fCount) override;
void setConstantI(UINT uStartRegister, const int *pConstantData, UINT uVector4iCount) override;
UINT getConstantCount() override;
UINT getConstantLocation(const char *szConstName) override;
UINT getConstantSizeV4(const char *szConstName) override;
void getData(void *pData, UINT *pSize);
void getData(void *pData, UINT *pSize) override;
};
class CGXGeometryShader: public IGXGeometryShader
{
friend class CGXContext;
CGXGeometryShader(CGXContext * pRender):m_pRender(pRender)
CGXGeometryShader(CGXContext *pRender):
m_pRender(pRender)
{}
~CGXGeometryShader();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11GeometryShader *m_pShader = NULL;
ID3DBlob *m_pShaderBlob = NULL;
public:
void Release();
void getData(void *pData, UINT *pSize);
void Release() override;
void getData(void *pData, UINT *pSize) override;
};
class CGXPixelShader: public IGXPixelShader
{
friend class CGXContext;
CGXPixelShader(CGXContext * pRender):m_pRender(pRender)
CGXPixelShader(CGXContext *pRender):
m_pRender(pRender)
{
}
~CGXPixelShader();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11PixelShader *m_pShader = NULL;
ID3DBlob *m_pShaderBlob = NULL;
public:
void Release();
void setConstantF(UINT uStartRegister, const float *pConstantData, UINT uVector4fCount);
void setConstantI(UINT uStartRegister, const int *pConstantData, UINT uVector4iCount);
UINT getConstantCount();
UINT getConstantLocation(const char *szConstName);
UINT getConstantSizeV4(const char *szConstName);
void getData(void *pData, UINT *pSize);
void Release() override;
void setConstantF(UINT uStartRegister, const float *pConstantData, UINT uVector4fCount) override;
void setConstantI(UINT uStartRegister, const int *pConstantData, UINT uVector4iCount) override;
UINT getConstantCount() override;
UINT getConstantLocation(const char *szConstName) override;
UINT getConstantSizeV4(const char *szConstName) override;
void getData(void *pData, UINT *pSize) override;
};
class CGXComputeShader: public IGXComputeShader
{
friend class CGXContext;
CGXComputeShader(CGXContext * pRender):m_pRender(pRender)
CGXComputeShader(CGXContext *pRender):
m_pRender(pRender)
{
}
~CGXComputeShader();
CGXContext * m_pRender;
CGXContext *m_pRender;
ID3D11ComputeShader *m_pShader = NULL;
ID3DBlob *m_pShaderBlob = NULL;
public:
void Release();
void getData(void *pData, UINT *pSize);
void Release() override;
void getData(void *pData, UINT *pSize) override;
};
class CGXShader: public IGXShader
class CGXShader: public IGXShaderSet
{
friend class CGXContext;
CGXShader(CGXContext * pRender, IGXVertexShader *pVS = NULL, IGXPixelShader *pPS = NULL, IGXGeometryShader *pGS = NULL, IGXComputeShader *pCS = NULL):
CGXShader(CGXContext *pRender, IGXVertexShader *pVS = NULL, IGXPixelShader *pPS = NULL, IGXGeometryShader *pGS = NULL, IGXComputeShader *pCS = NULL):
m_pRender(pRender),
m_pVShader((CGXVertexShader*)pVS),
m_pPShader((CGXPixelShader*)pPS),
......@@ -107,28 +111,39 @@ class CGXShader: public IGXShader
{
pPS->AddRef();
}
if(pGS)
{
pGS->AddRef();
}
if(pCS)
{
pCS->AddRef();
}
}
~CGXShader()
{
mem_release(m_pVShader);
mem_release(m_pPShader);
mem_release(m_pGShader);
mem_release(m_pCShader);
}
CGXContext * m_pRender;
CGXContext *m_pRender;
CGXVertexShader *m_pVShader;
CGXPixelShader *m_pPShader;
CGXGeometryShader *m_pGShader;
CGXComputeShader *m_pCShader;
public:
void Release()
void Release() override
{
--m_uRefCount;
if(!m_uRefCount)
{
mem_release(m_pVShader);
mem_release(m_pPShader);
mem_release(m_pGShader);
mem_release(m_pCShader);
delete this;
}
}
IGXPixelShader *getPixelShader()
IGXPixelShader* getPixelShader()
{
if(m_pPShader)
{
......@@ -136,7 +151,7 @@ public:
}
return(m_pPShader);
}
IGXGeometryShader *getGeometryShader()
IGXGeometryShader* getGeometryShader()
{
if(m_pGShader)
{
......@@ -144,7 +159,7 @@ public:
}
return(m_pGShader);
}
IGXVertexShader *getVertexShader()
IGXVertexShader* getVertexShader()
{
if(m_pVShader)
{
......@@ -152,7 +167,7 @@ public:
}
return(m_pVShader);
}
IGXComputeShader *getComputeShader()
IGXComputeShader* getComputeShader()
{
if(m_pCShader)
{
......@@ -160,43 +175,6 @@ public:
}
return(m_pCShader);
}
void setPixelShader(IGXPixelShader *pShader)
{
mem_release(m_pPShader);
m_pPShader = (CGXPixelShader*)pShader;
if(pShader)
{
pShader->AddRef();
}
}
void setGeometryShader(IGXGeometryShader *pShader)
{
mem_release(m_pGShader);
m_pGShader = (CGXGeometryShader*)pShader;
if(pShader)
{
pShader->AddRef();
}
}
void setVertexShader(IGXVertexShader *pShader)
{
mem_release(m_pVShader);
m_pVShader = (CGXVertexShader*)pShader;
if(pShader)
{
pShader->AddRef();
}
}
void setComputeShader(IGXComputeShader *pShader)
{
mem_release(m_pCShader);
m_pCShader = (CGXComputeShader*)pShader;
if(pShader)
{
pShader->AddRef();
}
}
};
#endif
......@@ -11,7 +11,7 @@ class CGXSurface: public IGXSurface
friend class CGXSwapChain;
protected:
CGXContext * m_pRender;
CGXContext *m_pRender;
D3D11_TEXTURE2D_DESC m_descTex2D;
ID3D11Texture2D *m_pSurface = NULL;
......@@ -49,7 +49,7 @@ protected:
~CGXSurface();
public:
CGXSurface(CGXContext * pRender, UINT uWidth, UINT uHeight, GXFORMAT format, ID3D11Texture2D *pSurface):
CGXSurface(CGXContext *pRender, UINT uWidth, UINT uHeight, GXFORMAT format, ID3D11Texture2D *pSurface):
m_pRender(pRender),
m_uWidth(uWidth),
m_uHeight(uHeight),
......@@ -61,11 +61,11 @@ public:
m_descTex2D.Format = m_pRender->getDXFormat(format);
}
void Release();
void Release() override;
UINT getWidth();
UINT getHeight();
GXFORMAT getFormat();
UINT getWidth() override;
UINT getHeight() override;
GXFORMAT getFormat() override;
};
class CGXSurface3D: public CGXSurface
......@@ -81,7 +81,7 @@ class CGXSurface3D: public CGXSurface
ID3D11Texture3D *m_pSurface = NULL;
public:
CGXSurface3D(CGXContext * pRender, UINT uWidth, UINT uHeight, UINT uDepth, GXFORMAT format, ID3D11Texture3D *pSurface):
CGXSurface3D(CGXContext *pRender, UINT uWidth, UINT uHeight, UINT uDepth, GXFORMAT format, ID3D11Texture3D *pSurface):
CGXSurface(pRender, uWidth, uHeight, format, NULL),
m_pSurface(pSurface)
{
......@@ -91,7 +91,7 @@ public:
m_descTex3D.Format = m_pRender->getDXFormat(format);
}
bool is3D()
bool is3D() override
{
return(true);
}
......@@ -110,7 +110,7 @@ class CGXSurfaceCube: public CGXSurface
ID3D11Texture2D *m_pSurface = NULL;
public:
CGXSurfaceCube(CGXContext * pRender, UINT uSize, GXFORMAT format, ID3D11Texture2D *pSurface):
CGXSurfaceCube(CGXContext *pRender, UINT uSize, GXFORMAT format, ID3D11Texture2D *pSurface):
CGXSurface(pRender, uSize, uSize, format, NULL),
m_pSurface(pSurface)
{
......@@ -119,7 +119,7 @@ public:
m_descTex2D.Format = m_pRender->getDXFormat(format);
}
bool isCube()
bool isCube() override
{
return(true);
}
......
......@@ -5,6 +5,12 @@ void CGXSwapChain::onDevLost()
{
mem_release(((CGXSurface*)m_pColorSurface)->m_pSurface);
mem_release(((CGXSurface*)m_pColorSurface)->m_pRTV);
if(m_pSwapChain)
{
m_pSwapChain->SetFullscreenState(FALSE, NULL);
}
mem_release(m_pSwapChain);
}
void CGXSwapChain::onDevRst()
......@@ -44,7 +50,7 @@ void CGXSwapChain::resize(int iWidth, int iHeight, bool isWindowed)
onDevRst();
}
CGXSwapChain::CGXSwapChain(CGXContext * pRender, int iWidth, int iHeight, SXWINDOW wnd, bool isWindowed):m_pRender(pRender)
CGXSwapChain::CGXSwapChain(CGXContext *pRender, int iWidth, int iHeight, SXWINDOW wnd, bool isWindowed):m_pRender(pRender)
{
memset(&m_presentParameters, 0, sizeof(m_presentParameters));
if(iWidth < 1)
......@@ -95,7 +101,7 @@ void CGXSwapChain::swapBuffers()
DX_CALL(m_pSwapChain->Present(NULL, NULL));
}
}
IGXSurface *CGXSwapChain::getColorTarget()
IGXSurface* CGXSwapChain::getColorTarget()
{
m_pColorSurface->AddRef();
return(m_pColorSurface);
......
......@@ -7,10 +7,10 @@ class CGXSwapChain: public IGXSwapChain
{
friend class CGXContext;
CGXSwapChain(CGXContext * pRender, int iWidth, int iHeight, SXWINDOW wnd, bool isWindowed=true);
CGXSwapChain(CGXContext *pRender, int iWidth, int iHeight, SXWINDOW wnd, bool isWindowed=true);
~CGXSwapChain();
CGXContext * m_pRender;
CGXContext *m_pRender;
IDXGISwapChain *m_pSwapChain = NULL;
DXGI_SWAP_CHAIN_DESC m_presentParameters;
IGXSurface *m_pColorSurface;
......@@ -22,9 +22,9 @@ class CGXSwapChain: public IGXSwapChain
void resize(int iWidth, int iHeight, bool isWindowed = true);
public:
void Release();
void swapBuffers();
IGXSurface *getColorTarget();
void Release() override;
void swapBuffers() override;
IGXSurface* getColorTarget() override;
};
#endif
......@@ -42,7 +42,7 @@ void CGXTexture2D::Release()
}
}
IGXSurface *CGXTexture2D::getMipmap(UINT n)
IGXSurface* CGXTexture2D::getMipmap(UINT n)
{
for(UINT i = 0, l = m_apSurfaces.size(); i < l; ++i)
{
......@@ -89,7 +89,7 @@ void CGXTexture2D::update(void *pData)
m_pRender->getDXDeviceContext()->UpdateSubresource(m_pTexture, 0, NULL, pData, m_pRender->getTextureMemPitch(m_uWidth, m_format), 0);
}
ID3D11ShaderResourceView *CGXTexture2D::getDXTexture()
ID3D11ShaderResourceView* CGXTexture2D::getDXTexture()
{
return(m_pSRV);
}
......@@ -169,6 +169,17 @@ GXTEXTURE_TYPE CGXTexture2D::getType()
return(GXTEXTURE_TYPE_2D);
}
IGXSurface* CGXTexture2D::asRenderTarget()
{
if(!(m_descTex2D.BindFlags & D3D11_BIND_RENDER_TARGET))
{
m_pRender->debugMessage(GX_LOG_ERROR, "Unable to use CGXTexture2D::asRenderTarget() on texture created without GX_TEXUSAGE_RENDERTARGET flag!");
return(NULL);
}
return(getMipmap());
}
//##########################################################################
CGXTexture3D::~CGXTexture3D()
......@@ -214,7 +225,7 @@ void CGXTexture3D::Release()
}
}
IGXSurface *CGXTexture3D::asRenderTarget()
IGXSurface* CGXTexture3D::asRenderTarget()
{
if(!(m_descTex3D.BindFlags & D3D11_BIND_RENDER_TARGET))
{
......@@ -243,7 +254,7 @@ void CGXTexture3D::update(void *pData)
m_pRender->getDXDeviceContext()->UpdateSubresource(m_pTexture, 0, NULL, pData, m_pRender->getTextureMemPitch(m_uWidth, m_format), m_pRender->getTextureMemPitch(m_uDepth, m_format) * m_uWidth);
}
ID3D11ShaderResourceView *CGXTexture3D::getDXTexture()
ID3D11ShaderResourceView* CGXTexture3D::getDXTexture()
{
return(m_pSRV);
}
......@@ -277,7 +288,7 @@ void CGXTextureCube::Release()
}
}
IGXSurface *CGXTextureCube::getMipmap(GXCUBEMAP_FACES face, UINT n)
IGXSurface* CGXTextureCube::getMipmap(GXCUBEMAP_FACES face, UINT n)
{
for(UINT i = 0, l = m_apSurfaces.size(); i < l; ++i)
{
......@@ -306,7 +317,7 @@ UINT CGXTextureCube::getSize()
return(m_uSize);
}
ID3D11ShaderResourceView *CGXTextureCube::getDXTexture()
ID3D11ShaderResourceView* CGXTextureCube::getDXTexture()
{
return(m_pSRV);
}
......@@ -389,7 +400,7 @@ GXTEXTURE_TYPE CGXTextureCube::getType()
return(GXTEXTURE_TYPE_CUBE);
}
IGXSurface *CGXTextureCube::asRenderTarget()
IGXSurface* CGXTextureCube::asRenderTarget()
{
if(!(m_descTex2D.BindFlags & D3D11_BIND_RENDER_TARGET))
{
......
......@@ -8,8 +8,9 @@ class CGXTexture2D: public IGXTexture2D
friend class CGXContext;
protected:
CGXContext * m_pRender;
CGXTexture2D(CGXContext * pRender): m_pRender(pRender)
CGXContext *m_pRender;
CGXTexture2D(CGXContext *pRender):
m_pRender(pRender)
{
}
~CGXTexture2D();
......@@ -35,24 +36,26 @@ protected:
Array<IGXSurface*> m_apSurfaces;
public:
void Release();
void Release() override;
IGXSurface *getMipmap(UINT i = 0);
IGXSurface* getMipmap(UINT i = 0) override;
UINT getWidth();
UINT getHeight();
UINT getWidth() override;
UINT getHeight() override;
bool lock(void **ppData, GXTEXLOCK mode);
void unlock();
bool lock(void **ppData, GXTEXLOCK mode) override;
void unlock() override;
void update(void *pData);
void update(void *pData) override;
GXFORMAT getFormat();
bool wasReset();
GXFORMAT getFormat() override;
bool wasReset() override;
ID3D11ShaderResourceView *getDXTexture();
ID3D11ShaderResourceView* getDXTexture();
GXTEXTURE_TYPE getType();
GXTEXTURE_TYPE getType() override;
IGXSurface* asRenderTarget() override;
};
class CGXTexture3D: public IGXTexture3D
......@@ -60,8 +63,9 @@ class CGXTexture3D: public IGXTexture3D
friend class CGXContext;
protected:
CGXContext * m_pRender;
CGXTexture3D(CGXContext * pRender): m_pRender(pRender)
CGXContext *m_pRender;
CGXTexture3D(CGXContext *pRender):
m_pRender(pRender)
{
}