Commit 1b61ddaa authored by D-AIRY's avatar D-AIRY

Updated DX11 impl to new header

parent 90b238c3
......@@ -25,7 +25,7 @@ virtual IGXShaderBase* createShader(GX_SHADER_TYPE type, const char * szFile, GX
//##########################################################################
//! тип 32 битного (4 байта) цвета, на каждую компоненту 8 бит [0, 255]
typedef UINT32 GXCOLOR;
typedef UINT GXCOLOR;
#ifndef MAKEFOURCC
......@@ -58,7 +58,7 @@ typedef UINT32 GXCOLOR;
GXCOLOR_RGBA((UINT)((r)*255.f),(UINT)((g)*255.f),(UINT)((b)*255.f),(UINT)((a)*255.f))
//! преобразование цвета float4 с компонентами [0.f, 1.f] в GXCOLOR, XYZW -> RGBA
#define GXCOLOR_F4_TO_COLOR(vec) GXCOLOR_COLORVALUE((vec).x, (vec).y, (vec).z, (vec).w)
#define GXCOLOR_F4_TO_COLOR(vec) GXCOLOR_FLOAT_RGBA((vec).x, (vec).y, (vec).z, (vec).w)
//! преобразование GXCOLOR в float4_t с компонентами [0.f, 1.f] RGBA -> XYZW
#define GXCOLOR_COLOR_TO_F4(val) float4_t( \
......
......@@ -27,18 +27,18 @@ void CGXBlendState::onDevRst()
auto m_pDevice = m_pRender->getDXDevice();
D3D11_BLEND_DESC blendDesc;
blendDesc.AlphaToCoverageEnable = m_desc.bAlphaToCoverageEnable;
blendDesc.IndependentBlendEnable = m_desc.bIndependentBlendEnabled;
blendDesc.AlphaToCoverageEnable = m_desc.useAlphaToCoverage;
blendDesc.IndependentBlendEnable = m_desc.useIndependentBlend;
for(int i = 0; i < (blendDesc.IndependentBlendEnable ? 8 : 1); ++i)
{
if(blendDesc.RenderTarget[i].BlendEnable = m_desc.renderTarget[i].bBlendEnable)
if(blendDesc.RenderTarget[i].BlendEnable = m_desc.renderTarget[i].useBlend)
{
blendDesc.RenderTarget[i].SrcBlend = (D3D11_BLEND)m_desc.renderTarget[i].srcBlend;
blendDesc.RenderTarget[i].DestBlend = (D3D11_BLEND)m_desc.renderTarget[i].destBlend;
blendDesc.RenderTarget[i].BlendOp = (D3D11_BLEND_OP)m_desc.renderTarget[i].blendOp;
blendDesc.RenderTarget[i].SrcBlend = (D3D11_BLEND)m_desc.renderTarget[i].blendSrcColor;
blendDesc.RenderTarget[i].DestBlend = (D3D11_BLEND)m_desc.renderTarget[i].blendDestColor;
blendDesc.RenderTarget[i].BlendOp = (D3D11_BLEND_OP)m_desc.renderTarget[i].blendOpColor;
blendDesc.RenderTarget[i].SrcBlendAlpha = (D3D11_BLEND)m_desc.renderTarget[i].srcBlendAlpha;
blendDesc.RenderTarget[i].DestBlendAlpha = (D3D11_BLEND)m_desc.renderTarget[i].destBlendAlpha;
blendDesc.RenderTarget[i].SrcBlendAlpha = (D3D11_BLEND)m_desc.renderTarget[i].blendSrcAlpha;
blendDesc.RenderTarget[i].DestBlendAlpha = (D3D11_BLEND)m_desc.renderTarget[i].blendDestAlpha;
blendDesc.RenderTarget[i].BlendOpAlpha = (D3D11_BLEND_OP)m_desc.renderTarget[i].blendOpAlpha;
}
blendDesc.RenderTarget[i].RenderTargetWriteMask = m_desc.renderTarget[i].u8RenderTargetWriteMask;
......
......@@ -195,7 +195,7 @@ BOOL CGXContext::initContext(SXWINDOW wnd, int iWidth, int iHeight, bool isWindo
if(!FAILED(DX_CALL(pDXGIAdapter->GetDesc(&adapterDesc))))
{
lstrcpyW(m_adapterDesc.szDescription, adapterDesc.Description);
m_adapterDesc.uTotalGPUMemory = adapterDesc.DedicatedVideoMemory;
m_adapterDesc.sizeTotalGPUmemory = adapterDesc.DedicatedVideoMemory;
}
else
{
......@@ -222,15 +222,15 @@ BOOL CGXContext::initContext(SXWINDOW wnd, int iWidth, int iHeight, bool isWindo
memset(&rasterizerDesc, 0, sizeof(rasterizerDesc));
rasterizerDesc.fillMode = GXFILL_SOLID;
rasterizerDesc.cullMode = GXCULL_BACK;
rasterizerDesc.bDepthClipEnable = TRUE;
rasterizerDesc.useDepthClip = TRUE;
m_pDefaultRasterizerState = createRasterizerState(&rasterizerDesc);
GXDEPTH_STENCIL_DESC depthStencilDesc;
memset(&depthStencilDesc, 0, sizeof(depthStencilDesc));
depthStencilDesc.bDepthEnable = TRUE;
depthStencilDesc.bEnableDepthWrite = TRUE;
depthStencilDesc.depthFunc = GXCMP_LESS_EQUAL;
depthStencilDesc.bStencilEnable = FALSE;
depthStencilDesc.useDepthTest = TRUE;
depthStencilDesc.useDepthWrite = TRUE;
depthStencilDesc.cmpFuncDepth = GXCMP_LESS_EQUAL;
depthStencilDesc.useStencilTest = FALSE;
m_pDefaultDepthStencilState = createDepthStencilState(&depthStencilDesc);
......@@ -276,7 +276,7 @@ void CGXContext::clear(UINT what, GXCOLOR color, float fDepth, UINT uStencil)
{
if(m_pColorTarget[i])
{
m_pDeviceContext->ClearRenderTargetView(((CGXSurface*)m_pColorTarget[i])->m_pRTV, (float*)&GXCOLOR_COLORVECTOR_ARGB(color));
m_pDeviceContext->ClearRenderTargetView(((CGXSurface*)m_pColorTarget[i])->m_pRTV, (float*)&GXCOLOR_COLOR_TO_F4(color));
}
}
}
......@@ -325,7 +325,7 @@ IGXVertexBuffer* CGXContext::createVertexBuffer(size_t size, GX_BUFFER_USAGE fla
}
pBuff->m_uSize = (UINT)size;
m_memoryStats.uVertexBufferBytes += pBuff->m_uSize;
m_memoryStats.sizeVertexBufferBytes += pBuff->m_uSize;
return(pBuff);
}
......@@ -378,7 +378,7 @@ IGXIndexBuffer* CGXContext::createIndexBuffer(size_t size, GX_BUFFER_USAGE flags
}
pBuff->m_uSize = (UINT)size;
m_memoryStats.uIndexBufferBytes += pBuff->m_uSize;
m_memoryStats.sizeIndexBufferBytes += pBuff->m_uSize;
return(pBuff);
}
......@@ -392,7 +392,7 @@ void CGXContext::destroyIndexBuffer(IGXIndexBuffer *pBuff)
m_pCurIndexBuffer = NULL;
m_sync_state.bIndexBuffer = TRUE;
}
m_memoryStats.uIndexBufferBytes -= ((CGXIndexBuffer*)pBuff)->m_uSize;
m_memoryStats.sizeIndexBufferBytes -= ((CGXIndexBuffer*)pBuff)->m_uSize;
}
mem_delete(pBuff);
}
......@@ -407,7 +407,7 @@ void CGXContext::destroyVertexBuffer(IGXVertexBuffer *pBuff)
m_sync_state.bIndexBuffer = TRUE;
}*/
m_memoryStats.uVertexBufferBytes -= ((CGXVertexBuffer*)pBuff)->m_uSize;
m_memoryStats.sizeVertexBufferBytes -= ((CGXVertexBuffer*)pBuff)->m_uSize;
}
mem_delete(pBuff);
}
......@@ -579,7 +579,7 @@ void CGXContext::syncronize(UINT flags)
{
pBS = (CGXBlendState*)m_pDefaultBlendState;
}
m_pDeviceContext->OMSetBlendState(pBS->m_pStateBlock, (float*)&GXCOLOR_COLORVECTOR_ARGB(m_blendFactor), 0xffffffff);
m_pDeviceContext->OMSetBlendState(pBS->m_pStateBlock, (float*)&GXCOLOR_COLOR_TO_F4(m_blendFactor), 0xffffffff);
m_sync_state.bBlendState = FALSE;
}
......@@ -872,7 +872,7 @@ IGXVertexShader* CGXContext::createVertexShader(const char *szFile, GXMACRO *pDe
}
mem_release(pErrorBlob);
IGXVertexShader *pShader = createVertexShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXVertexShader *pShader = createVertexShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
......@@ -896,13 +896,13 @@ IGXVertexShader* CGXContext::createVertexShaderFromString(const char *szCode, GX
}
mem_release(pErrorBlob);
IGXVertexShader *pShader = createVertexShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXVertexShader *pShader = createVertexShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
return(pShader);
}
IGXVertexShader* CGXContext::createVertexShader(void *_pData, UINT uSize)
IGXVertexShader* CGXContext::createVertexShaderFromBin(void *_pData, UINT uSize)
{
CGXVertexShader *pShader = new CGXVertexShader(this);
......@@ -946,13 +946,13 @@ IGXPixelShader* CGXContext::createPixelShader(const char *szFile, GXMACRO *pDefs
}
mem_release(pErrorBlob);
IGXPixelShader *pShader = createPixelShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXPixelShader *pShader = createPixelShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
return(pShader);
}
IGXPixelShader* CGXContext::createPixelShader(void *_pData, UINT uSize)
IGXPixelShader* CGXContext::createPixelShaderFromBin(void *_pData, UINT uSize)
{
CGXPixelShader *pShader = new CGXPixelShader(this);
......@@ -985,7 +985,7 @@ IGXPixelShader* CGXContext::createPixelShaderFromString(const char *szCode, GXMA
}
mem_release(pErrorBlob);
IGXPixelShader *pShader = createPixelShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXPixelShader *pShader = createPixelShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
......@@ -1020,13 +1020,13 @@ IGXGeometryShader* CGXContext::createGeometryShader(const char *szFile, GXMACRO
}
mem_release(pErrorBlob);
IGXGeometryShader *pShader = createGeometryShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXGeometryShader *pShader = createGeometryShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
return(pShader);
}
IGXGeometryShader* CGXContext::createGeometryShader(void *_pData, UINT uSize)
IGXGeometryShader* CGXContext::createGeometryShaderFromBin(void *_pData, UINT uSize)
{
CGXGeometryShader *pShader = new CGXGeometryShader(this);
......@@ -1059,7 +1059,7 @@ IGXGeometryShader* CGXContext::createGeometryShaderFromString(const char *szCode
}
mem_release(pErrorBlob);
IGXGeometryShader *pShader = createGeometryShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXGeometryShader *pShader = createGeometryShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
......@@ -1097,13 +1097,13 @@ IGXComputeShader* CGXContext::createComputeShader(const char *szFile, GXMACRO *p
}
mem_release(pErrorBlob);
IGXComputeShader *pShader = createComputeShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXComputeShader *pShader = createComputeShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
return(pShader);
}
IGXComputeShader* CGXContext::createComputeShader(void *_pData, UINT uSize)
IGXComputeShader* CGXContext::createComputeShaderFromBin(void *_pData, UINT uSize)
{
CGXComputeShader *pShader = new CGXComputeShader(this);
......@@ -1137,7 +1137,7 @@ IGXComputeShader* CGXContext::createComputeShaderFromString(const char *szCode,
}
mem_release(pErrorBlob);
IGXComputeShader *pShader = createComputeShader(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
IGXComputeShader *pShader = createComputeShaderFromBin(pShaderBlob->GetBufferPointer(), (UINT)pShaderBlob->GetBufferSize());
mem_release(pShaderBlob);
......@@ -1310,7 +1310,7 @@ IGXRasterizerState* CGXContext::createRasterizerState(GXRASTERIZER_DESC *pRSDesc
{
CGXRasterizerState *pRS = new CGXRasterizerState(this);
pRS->m_isScissorsEnabled = pRSDesc->bScissorEnable;
pRS->m_isScissorsEnabled = pRSDesc->useScissorTest;
pRS->m_desc = *pRSDesc;
pRS->onDevRst();
......@@ -1809,7 +1809,7 @@ IGXBaseTexture* CGXContext::getTextureCS(UINT uStage)
return(m_pTexturesCS[uStage]);
}
void CGXContext::setUnorderedAccessVeiwCS(IGXBaseTexture *pTexture, UINT uStage)
void CGXContext::setUnorderedAccessViewCS(IGXBaseTexture *pTexture, UINT uStage)
{
assert(uStage < GX_MAX_UAV_TEXTURES);
mem_release(m_pUAVsCS[uStage]);
......@@ -1820,7 +1820,7 @@ void CGXContext::setUnorderedAccessVeiwCS(IGXBaseTexture *pTexture, UINT uStage)
}
m_sync_state.bUAVsCS[uStage] = TRUE;
}
IGXBaseTexture* CGXContext::getUnorderedAccessVeiwCS(UINT uStage)
IGXBaseTexture* CGXContext::getUnorderedAccessViewCS(UINT uStage)
{
assert(uStage < GX_MAX_UAV_TEXTURES);
if(m_pUAVsCS[uStage])
......
......@@ -87,22 +87,22 @@ public:
IGXVertexShader* createVertexShader(const char *szFile, GXMACRO *pDefs = NULL) override;
IGXVertexShader* createVertexShaderFromString(const char * szCode, GXMACRO *pDefs = NULL) override;
IGXVertexShader* createVertexShader(void *pData, UINT uSize) override;
IGXVertexShader* createVertexShaderFromBin(void *pData, UINT uSize) override;
void setVertexShaderConstant(IGXConstantBuffer *pBuffer, UINT uSlot = 0) override;
IGXPixelShader* createPixelShader(const char *szFile, GXMACRO *pDefs = NULL) override;
IGXPixelShader* createPixelShaderFromString(const char * szCode, GXMACRO *pDefs = NULL) override;
IGXPixelShader* createPixelShader(void *pData, UINT uSize) override;
IGXPixelShader* createPixelShaderFromBin(void *pData, UINT uSize) override;
void setPixelShaderConstant(IGXConstantBuffer *pBuffer, UINT uSlot = 0) override;
IGXGeometryShader* createGeometryShader(const char *szFile, GXMACRO *pDefs = NULL) override;
IGXGeometryShader* createGeometryShaderFromString(const char * szCode, GXMACRO *pDefs = NULL) override;
IGXGeometryShader* createGeometryShader(void *pData, UINT uSize) override;
IGXGeometryShader* createGeometryShaderFromBin(void *pData, UINT uSize) override;
void setGeometryShaderConstant(IGXConstantBuffer *pBuffer, UINT uSlot = 0) override;
IGXComputeShader* createComputeShader(const char *szFile, GXMACRO *pDefs = NULL) override;
IGXComputeShader* createComputeShaderFromString(const char * szCode, GXMACRO *pDefs = NULL) override;
IGXComputeShader* createComputeShader(void *pData, UINT uSize) override;
IGXComputeShader* createComputeShaderFromBin(void *pData, UINT uSize) override;
void setComputeShaderConstant(IGXConstantBuffer *pBuffer, UINT uSlot = 0) override;
......@@ -145,8 +145,8 @@ public:
IGXBaseTexture* getTextureVS(UINT uStage = 0) override;
void setTextureCS(IGXBaseTexture *pTexture, UINT uStage = 0) override;
IGXBaseTexture* getTextureCS(UINT uStage = 0) override;
void setUnorderedAccessVeiwCS(IGXBaseTexture *pUAV, UINT uStage = 0) override;
IGXBaseTexture* getUnorderedAccessVeiwCS(UINT uStage = 0) override;
void setUnorderedAccessViewCS(IGXBaseTexture *pUAV, UINT uStage = 0) override;
IGXBaseTexture* getUnorderedAccessViewCS(UINT uStage = 0) override;
IGXBlendState* createBlendState(GXBLEND_DESC *pBlendDesc) override;
void destroyBlendState(IGXBlendState *pState);
......@@ -215,11 +215,11 @@ public:
{
if(isRT)
{
m_memoryStats.uRenderTargetBytes += uBytes;
m_memoryStats.sizeRenderTargetBytes += uBytes;
}
else
{
m_memoryStats.uTextureBytes += uBytes;
m_memoryStats.sizeTextureBytes += uBytes;
}
if(uBytes < 0)
......@@ -241,7 +241,7 @@ public:
{
if(bTotal)
{
m_memoryStats.uShaderConstBytes += uBytes;
m_memoryStats.sizeShaderConstBytes += uBytes;
if(uBytes < 0)
{
......
......@@ -25,20 +25,21 @@ void CGXDepthStencilState::onDevRst()
D3D11_DEPTH_STENCIL_DESC dsDesc;
memset(&dsDesc, 0, sizeof(dsDesc));
dsDesc.DepthEnable = m_desc.bDepthEnable;
dsDesc.DepthWriteMask = m_desc.bEnableDepthWrite ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
dsDesc.DepthFunc = (D3D11_COMPARISON_FUNC)m_desc.depthFunc;
dsDesc.StencilEnable = m_desc.bStencilEnable;
dsDesc.DepthEnable = m_desc.useDepthTest;
dsDesc.DepthWriteMask = m_desc.useDepthWrite ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
dsDesc.DepthFunc = (D3D11_COMPARISON_FUNC)m_desc.cmpFuncDepth;
dsDesc.StencilEnable = m_desc.useStencilTest;
dsDesc.StencilReadMask = m_desc.u8StencilReadMask;
dsDesc.StencilWriteMask = m_desc.u8StencilWriteMask;
dsDesc.FrontFace.StencilFunc = (D3D11_COMPARISON_FUNC)m_desc.stencilFunc;
dsDesc.FrontFace.StencilPassOp = (D3D11_STENCIL_OP)m_desc.stencilPassOp;
dsDesc.FrontFace.StencilFailOp = (D3D11_STENCIL_OP)m_desc.stencilFailOp;
dsDesc.FrontFace.StencilDepthFailOp = (D3D11_STENCIL_OP)m_desc.stencilDepthFailOp;
dsDesc.BackFace.StencilFunc = (D3D11_COMPARISON_FUNC)m_desc.stencilBackFunc;
dsDesc.BackFace.StencilPassOp = (D3D11_STENCIL_OP)m_desc.stencilBackPassOp;
dsDesc.BackFace.StencilFailOp = (D3D11_STENCIL_OP)m_desc.stencilBackFailOp;
dsDesc.BackFace.StencilDepthFailOp = (D3D11_STENCIL_OP)m_desc.stencilBackDepthFailOp;
dsDesc.FrontFace.StencilFunc = (D3D11_COMPARISON_FUNC)m_desc.stencilTestFront.cmpFuncStencil;
dsDesc.FrontFace.StencilPassOp = (D3D11_STENCIL_OP)m_desc.stencilTestFront.stencilOpPass;
dsDesc.FrontFace.StencilFailOp = (D3D11_STENCIL_OP)m_desc.stencilTestFront.stencilOpFail;
dsDesc.FrontFace.StencilDepthFailOp = (D3D11_STENCIL_OP)m_desc.stencilTestFront.stencilOpDepthFail;
dsDesc.BackFace.StencilFunc = (D3D11_COMPARISON_FUNC)m_desc.stencilTestBack.cmpFuncStencil;
dsDesc.BackFace.StencilPassOp = (D3D11_STENCIL_OP)m_desc.stencilTestBack.stencilOpPass;
dsDesc.BackFace.StencilFailOp = (D3D11_STENCIL_OP)m_desc.stencilTestBack.stencilOpFail;
dsDesc.BackFace.StencilDepthFailOp = (D3D11_STENCIL_OP)m_desc.stencilTestBack.stencilOpDepthFail;
DX_CALL(m_pDevice->CreateDepthStencilState(&dsDesc, &m_pStateBlock));
}
......@@ -27,10 +27,10 @@ void CGXRasterizerState::onDevRst()
rsDesc.DepthBias = m_desc.iDepthBias;
rsDesc.DepthBiasClamp = m_desc.fDepthBiasClamp;
rsDesc.SlopeScaledDepthBias = m_desc.fSlopeScaledDepthBias;
rsDesc.DepthClipEnable = m_desc.bDepthClipEnable;
rsDesc.ScissorEnable = m_desc.bScissorEnable;
rsDesc.MultisampleEnable = m_desc.bMultisampleEnable;
rsDesc.AntialiasedLineEnable = m_desc.bAntialiasedLineEnable;
rsDesc.DepthClipEnable = m_desc.useDepthClip;
rsDesc.ScissorEnable = m_desc.useScissorTest;
rsDesc.MultisampleEnable = m_desc.useMultisample;
rsDesc.AntialiasedLineEnable = m_desc.useAntialiasedLine;
switch(m_desc.fillMode)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment