Commit b4d878f1 authored by D-AIRY's avatar D-AIRY

Some refactor

parent 302560a0
......@@ -15,6 +15,6 @@ half4x4 g_mWVP1: register(b0);
VSO_GUISimple main(VSI_GUISimple IN)
{
VSO_GUISimple OUT = (VSO_GUISimple)0;
OUT.vPosition = mul(half4(IN.vPosition.xyz,1), g_mWVP1);
OUT.vPosition = mul(half4(IN.vPosition,1), g_mWVP1);
return(OUT);
}
......@@ -14,7 +14,7 @@ VSO_SkyBox main(VSI_SkyBox IN)
{
VSO_SkyBox OUT = (VSO_SkyBox)0;
OUT.vPosition = mul(half4(IN.vPosition.xyz + g_vPosCam.xyz, 1.f), g_mVP);
OUT.vPosition = mul(half4(IN.vPosition + g_vPosCam.xyz, 1.f), g_mVP);
OUT.vTexUV = IN.vTexUV;
return OUT;
......
......@@ -158,7 +158,7 @@ struct PSO_RSMbuffer
struct VSI_SkyBox
{
float4 vPosition :POSITION0;
float3 vPosition :POSITION0;
float3 vTexUV :TEXCOORD0;
};
......@@ -274,7 +274,7 @@ struct VSO_GUITextured
struct VSI_GUISimple
{
float4 vPosition :POSITION0;
float3 vPosition :POSITION0;
};
struct VSO_GUISimple
......
Subproject commit 760d08ff9d3ac024bb691a8612e09ff4103ae419
Subproject commit 677e87a4c99e4c354d3b345d9e1456b0e222bd60
......@@ -188,7 +188,7 @@ void CSkyBox::render()
//static ID s_idShader = SGCore_ShaderCreateKit(m_idVS, m_idPS);
//SGCore_ShaderBind(s_idShader);
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->setIndexBuffer(m_pIndeces);
pCtx->setRenderBuffer(m_pRenderBuffer);
......
......@@ -749,7 +749,7 @@ void XMETHODCALLTYPE CAnimatedModel::render(UINT uLod, bool isTransparent)
m_isWorldDirty = false;
}
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->setVSConstant(m_pWorldBuffer, 1 /* SCR_OBJECT */);
pCtx->setVSConstant(m_pBoneConstantBuffer, 10);
......
......@@ -1080,7 +1080,7 @@ void CAnimatedModelShared::render(UINT uSkin, UINT uLod, const float4_t &vColor)
return;
}
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->setIndexBuffer(m_ppIndexBuffer[uLod]);
pCtx->setRenderBuffer(m_ppRenderBuffer[uLod]);
......
......@@ -198,7 +198,7 @@ void XMETHODCALLTYPE CDynamicModel::render(UINT uLod, bool isTransparent)
m_isWorldDirty = false;
}
m_pDevice->getDirectContext()->setVSConstant(m_pWorldBuffer, 1 /* SCR_OBJECT */);
m_pDevice->getThreadContext()->setVSConstant(m_pWorldBuffer, 1 /* SCR_OBJECT */);
m_pShared->render(m_uSkin, uLod, m_vColor, isTransparent);
}
......
......@@ -2,6 +2,17 @@
#include <xcommon/IPluginManager.h>
#include <chrono>
/*
#if 1
# include <core/sxcore.h>
# ifdef _DEBUG
# pragma comment(lib, "sxcore_d.lib")
# else
# pragma comment(lib, "sxcore.lib")
# endif
#endif
*/
CMaterialChangedEventListener::CMaterialChangedEventListener(CDynamicModelProvider *pProvider):
m_pProvider(pProvider)
{
......@@ -13,6 +24,68 @@ void CMaterialChangedEventListener::onEvent(const XEventMaterialChanged *pData)
m_pProvider->onMaterialTransparencyChanged(pData->pMaterial);
}
}
/*
//##########################################################################
class CRenderTask: public IParallelForBody
{
public:
CRenderTask(CRenderableVisibility *pVisibility, Array<CDynamicModel*> *pModels, IGXDevice *pDevice, IGXContextState *pState):
m_pVisibility(pVisibility),
m_pModels(pModels),
m_pDevice(pDevice),
m_pState(pState)
{
}
void forLoop(int iStart, int iEnd) const
{
//printf("%d %d\n", iStart, iEnd);
//printf("%d\n", Core_MGetThreadID());
m_pDevice->getThreadContext()->setFullState(m_pState);
m_pDevice->getThreadContext()->beginIndirect();
for(UINT i = iStart, l = iEnd; i < l; ++i)
{
//if(iStart != 279 && iStart != 558 && iStart != 837)
//{
// break;
//}
//if(iStart == 558)
//{
// //break;
//}
//if(iStart == 837)
//{
// //break;
//}
if(m_pVisibility)
{
auto pItem = m_pVisibility->getItemDynamic(i, false);
if(pItem && pItem->isVisible)
{
(*m_pModels)[i]->render(pItem->uLod, false);
//break;
}
}
else
{
(*m_pModels)[i]->render(0, false);
}
}
//Sleep(2);
m_pDevice->getThreadContext()->endIndirect();
};
protected:
CRenderableVisibility *m_pVisibility;
Array<CDynamicModel*> *m_pModels;
IGXDevice *m_pDevice;
IGXContextState *m_pState;
};
*/
//##########################################################################
......@@ -122,25 +195,65 @@ IXMaterialSystem *CDynamicModelProvider::getMaterialSystem()
void CDynamicModelProvider::render(bool isTransparent, CRenderableVisibility *pVisibility)
{
for(UINT i = 0, l = m_apModels.size(); i < l; ++i)
{
if(pVisibility)
//if(isTransparent/* || m_apModels.size() < 1000*/)
//{
for(UINT i = 0, l = m_apModels.size(); i < l; ++i)
{
auto pItem = pVisibility->getItemDynamic(i);
if(pItem->isVisible)
if(pVisibility)
{
if(isTransparent && !pItem->isTransparent)
auto pItem = pVisibility->getItemDynamic(i);
if(pItem->isVisible)
{
continue;
if(isTransparent && !pItem->isTransparent)
{
continue;
}
m_apModels[i]->render(pItem->uLod, isTransparent);
}
m_apModels[i]->render(pItem->uLod, isTransparent);
}
else
{
m_apModels[i]->render(0, isTransparent);
}
}
else
//}
/*else
{
IGXContextState *pState = m_pRenderContext->getThreadContext()->getCurrentState();
CRenderTask task(pVisibility, &m_apModels, m_pRenderContext, pState);
int iThreads = Core_MGetThreadCount();
int iChunkSize = ((int)m_apModels.size() + (iThreads - 1)) / iThreads;
ID idTask = Core_MForLoop(iChunkSize, m_apModels.size(), &task);
for(UINT i = 0, l = iChunkSize; i < l; ++i)
{
m_apModels[i]->render(0, isTransparent);
if(pVisibility)
{
auto pItem = pVisibility->getItemDynamic(i);
if(pItem->isVisible)
{
if(isTransparent && !pItem->isTransparent)
{
continue;
}
m_apModels[i]->render(pItem->uLod, isTransparent);
}
}
else
{
m_apModels[i]->render(0, isTransparent);
}
}
}
Core_MWaitFor(idTask);
mem_release(pState);
m_pRenderContext->executeThreadContexts();
//printf("\n");
}*/
}
void CDynamicModelProvider::computeVisibility(const IFrustum *pFrustum, CRenderableVisibility *pVisibility, CRenderableVisibility *pReference)
......
......@@ -343,7 +343,7 @@ void CDynamicModelShared::render(UINT uSkin, UINT uLod, const float4_t &vColor,
return;
}
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->setIndexBuffer(m_ppIndexBuffer[uLod]);
pCtx->setRenderBuffer(m_ppRenderBuffer[uLod]);
......
......@@ -67,9 +67,13 @@ void CRenderableVisibility::setItemCountDynamic(UINT uCount)
}
}
CRenderableVisibility::item_s* CRenderableVisibility::getItemDynamic(UINT uIndex)
CRenderableVisibility::item_s* CRenderableVisibility::getItemDynamic(UINT uIndex, bool forceCreate)
{
return(&m_aItemsDynamic[uIndex]);
if(forceCreate || uIndex < m_aItemsDynamic.size())
{
return(&m_aItemsDynamic[uIndex]);
}
return(NULL);
}
CRenderableVisibility::TransparentModel* CRenderableVisibility::getItemTransparentDynamic(UINT uIndex)
......
......@@ -39,7 +39,7 @@ public:
item_s* getItem(UINT uIndex);
void setItemCountDynamic(UINT uCount);
item_s* getItemDynamic(UINT uIndex);
item_s* getItemDynamic(UINT uIndex, bool forceCreate=true);
void resetItemTransparentDynamic();
void addItemTransparentDynamic(const TransparentModel &mdl);
......
Subproject commit c7a4f320b908e62e123169293eaae63ef5e23f81
Subproject commit 332b5eb41a39b488d18d1038b2ce35bd72f05159
......@@ -411,7 +411,7 @@ ID CTaskManager::forLoop(int iStart, int iEnd, const IParallelForBody *pBody, in
return(0);
}
int iTotal = iEnd - iStart;
int iChunkSize = (int)(ceilf((float)iTotal / (float)m_iNumThreads) + 0.5f);
int iChunkSize = (int)(ceilf((float)iTotal / (float)(m_iNumThreads - 1)) + 0.5f);
if(iMaxChunkSize > 0 && iChunkSize > iMaxChunkSize)
{
iChunkSize = iMaxChunkSize;
......
......@@ -87,7 +87,7 @@ void CAxesHelper::render()
static float3 vCamPos;
Core_RFloat3Get(G_RI_FLOAT3_OBSERVER_POSITION, &vCamPos);
SGCore_GetDXDevice()->getDirectContext()->setPSTexture(NULL);
SGCore_GetDXDevice()->getThreadContext()->setPSTexture(NULL);
// SGCore_GetDXDevice()->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);
SGCore_ShaderUnBind();
......
......@@ -146,7 +146,7 @@ void CEditorObject::renderSelection(bool is3D)
}
IGXDevice *pDevice = SGCore_GetDXDevice();
IGXContext *pCtx = pDevice->getDirectContext();
IGXContext *pCtx = pDevice->getThreadContext();
IGXBlendState *pOldBlendState = pCtx->getBlendState();
IGXRasterizerState *pOldRS = pCtx->getRasterizerState();
......
......@@ -1230,7 +1230,7 @@ void GameData::render()
}
if(pDev)
{
const GXFrameStats *pFrameStats = pDev->getDirectContext()->getFrameStats();
const GXFrameStats *pFrameStats = pDev->getThreadContext()->getFrameStats();
const GXAdapterMemoryStats *pMemoryStats = pDev->getMemoryStats();
static GXFrameStats s_oldFrameStats = {0};
......@@ -1281,7 +1281,7 @@ void GameData::render()
}
if(g_pTextRenderBuffer)
{
IGXContext *pContext = pDev->getDirectContext();
IGXContext *pContext = pDev->getThreadContext();
pContext->setBlendState(g_pTextBlendState);
pContext->setRasterizerState(NULL);
......
......@@ -379,7 +379,7 @@ void CCrosshair::render()
m_pIndexBuffer->unlock();
}
}
IGXContext *pCtx = m_pDev->getDirectContext();
IGXContext *pCtx = m_pDev->getThreadContext();
SGCore_ShaderBind(m_idShaderKit);
pCtx->setBlendState(m_pBlendState);
......
......@@ -360,7 +360,7 @@ SX_LIB_API BOOL SGame_AddWMsg(UINT message, WPARAM wParam, LPARAM lParam)
}
static const bool *s_pGrabCursor = GET_PCVAR_BOOL("cl_grab_cursor");
if(message == WM_ACTIVATE && *s_pGrabCursor && LOWORD(wParam) == WA_INACTIVE)
if(message == WM_ACTIVATE && s_pGrabCursor && *s_pGrabCursor && LOWORD(wParam) == WA_INACTIVE)
{
Core_0ConsoleExecCmd("game_menu");
}
......
......@@ -844,12 +844,12 @@ void CShaderManager::bind(ID idShaderKit)
return;
}
g_pDevice->getDirectContext()->setShader(m_aShaderKit[idShaderKit]->m_pShaderKit);
g_pDevice->getThreadContext()->setShader(m_aShaderKit[idShaderKit]->m_pShaderKit);
}
void CShaderManager::unbind()
{
g_pDevice->getDirectContext()->setShader(0);
g_pDevice->getThreadContext()->setShader(0);
}
......
......@@ -144,7 +144,7 @@ SX_LIB_API void SGCore_OnResetDevice()
SX_LIB_API void SGCore_ScreenQuadDraw()
{
SG_PRECOND(_VOID);
IGXContext *pCtx = g_pDevice->getDirectContext();
IGXContext *pCtx = g_pDevice->getThreadContext();
pCtx->setRenderBuffer(g_pScreenTextureRB);
pCtx->setPrimitiveTopology(GXPT_TRIANGLELIST);
pCtx->drawPrimitive(0, 2);
......@@ -289,7 +289,7 @@ public:
}
void draw()
{
IGXContext *pCtx = g_pDevice->getDirectContext();
IGXContext *pCtx = g_pDevice->getThreadContext();
pCtx->setRenderBuffer(m_pRB);
pCtx->setIndexBuffer(m_pIB);
pCtx->drawIndexed(m_uVertexCount, m_uIndexCount / 3, 0, 0);
......
......@@ -103,7 +103,7 @@ namespace gui
void CDesktop::render(float fTimeDelta, bool bPresent)
{
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
m_pDoc->update(fTimeDelta);
if(m_pDoc->isDirty())
......
......@@ -119,7 +119,7 @@ namespace gui
texWhite = CTextureManager::getTexture(TEX_WHITE);
}
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
// GetGUI()->getDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
......@@ -164,7 +164,7 @@ namespace gui
void IRenderBorder::renderInnerFill()
{
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
pCtx->setRenderBuffer(m_pRenderBuffer);
pCtx->setIndexBuffer(m_pIndexBuffer);
......
......@@ -1267,7 +1267,7 @@ namespace gui
static CPITexture texWhite = CTextureManager::getTexture(TEX_WHITE);
// static CSHADER shText = CTextureManager::loadShader(L"text");
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
IGXSamplerState *pOldSampler = pCtx->getSamplerState(0);
......@@ -1386,6 +1386,7 @@ namespace gui
// GetGUI()->getDevice()->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0xFFFFFFFF);
// GetGUI()->getDevice()->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
}
mem_release(pOldSampler);
}
void IRenderFrame::updateStyles()
......@@ -1705,7 +1706,7 @@ namespace gui
void IRenderBlock::render(UINT lvl)
{
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
pCtx->setStencilRef(lvl);
if(m_iScrollTop != 0 || m_iScrollTopMax != 0)
......@@ -1888,7 +1889,7 @@ namespace gui
void IRenderAnonymousBlock::render(UINT lvl)
{
GetGUI()->getDevice()->getDirectContext()->setStencilRef(lvl);
GetGUI()->getDevice()->getThreadContext()->setStencilRef(lvl);
CTranslationManager::pushMatrix(SMMatrixTranslation(m_iXpos, m_iYpos, 0.0f));
BaseClass::render(lvl);
CTranslationManager::popMatrix();
......@@ -2156,7 +2157,7 @@ namespace gui
void IRenderInline::render(UINT lvl)
{
GetGUI()->getDevice()->getDirectContext()->setStencilRef(lvl);
GetGUI()->getDevice()->getThreadContext()->setStencilRef(lvl);
CTranslationManager::pushMatrix(SMMatrixTranslation(m_iXpos, m_iYpos, 0.0f));
m_border.render();
renderBackground(lvl);
......@@ -2396,7 +2397,7 @@ namespace gui
}
void IRenderTextNew::render(UINT lvl)
{
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
pCtx->setStencilRef(lvl);
static CPITexture texWhite = NULL;
......@@ -2821,7 +2822,7 @@ namespace gui
}
if(m_pNode->parentNode()->getStyle()->_gui_text_cursor->getInt() == css::ICSSproperty::_GUI_TEXT_CURSOR_SHOW)
{
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
int iTextSize = m_pNode->parentNode()->getStyle()->font_size->getPX(m_pParent->getInnerHeight());
m_iTextSize = iTextSize;
......@@ -3002,7 +3003,7 @@ namespace gui
}
if(m_pNode->parentNode()->getStyle()->_gui_text_cursor->getInt() == css::ICSSproperty::_GUI_TEXT_CURSOR_SHOW)
{
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
UINT iTextSize = m_pNode->parentNode()->getStyle()->font_size->getPX(m_pParent->getInnerHeight());
m_iTextSize = iTextSize;
......
......@@ -373,7 +373,7 @@ namespace gui
CVideoUpdateManager::update();
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->clear(GX_CLEAR_STENCIL);
......
......@@ -150,7 +150,7 @@ namespace gui
void updateTransformShader()
{
m_pVSTransformConstant->update(&SMMatrixTranspose(m_mTransformWorld * m_mTransformViewProj));
m_pDevice->getDirectContext()->setVSConstant(m_pVSTransformConstant, 0);
m_pDevice->getThreadContext()->setVSConstant(m_pVSTransformConstant, 0);
}
IGXRenderBuffer *getQuadRenderBufferXYZ(float3_t *pVertices);
......
......@@ -45,7 +45,7 @@ namespace gui
s_pColorConstant->update(&float4_t(1, 1, 1, 0.5));
}
IGXContext *pCtx = GetGUI()->getDevice()->getDirectContext();
IGXContext *pCtx = GetGUI()->getDevice()->getThreadContext();
pCtx->setPSConstant(s_pColorConstant);
//SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, shader.m_idPS, "g_vColor", (float*)&float4_t(1, 1, 1, 0.5), 1);
......
......@@ -72,14 +72,14 @@ namespace gui
if(!tex)
{
//FIXME: Set fallback texture
GetGUI()->getDevice()->getDirectContext()->setPSTexture(NULL);
GetGUI()->getDevice()->getThreadContext()->setPSTexture(NULL);
m_pCurrentTex = NULL;
return;
}
if(m_pCurrentTex != tex)
{
m_pCurrentTex = tex;
GetGUI()->getDevice()->getDirectContext()->setPSTexture(m_pCurrentTex->m_pTexture);
GetGUI()->getDevice()->getThreadContext()->setPSTexture(m_pCurrentTex->m_pTexture);
}
......
......@@ -165,7 +165,7 @@ void XMETHODCALLTYPE CMaterialSystem::setWorld(const SMMATRIX &mWorld)
m_pObjectConstantBuffer->update(&m_objectData);
SGCore_GetDXDevice()->getDirectContext()->setVSConstant(m_pObjectConstantBuffer, SCR_OBJECT);
SGCore_GetDXDevice()->getThreadContext()->setVSConstant(m_pObjectConstantBuffer, SCR_OBJECT);
//SGCore_GetDXDevice()->setPixelShaderConstant(m_pObjectConstantBuffer, SCR_OBJECT);
}
void XMETHODCALLTYPE CMaterialSystem::bindMaterial(IXMaterial *pMaterial, IXShaderVariant *pShaderVariant)
......@@ -180,12 +180,12 @@ void XMETHODCALLTYPE CMaterialSystem::bindTexture(IXTexture *pTexture, UINT slot
{
IGXBaseTexture *pTex;
pTexture->getAPITexture(&pTex);
SGCore_GetDXDevice()->getDirectContext()->setPSTexture(pTex, slot);
SGCore_GetDXDevice()->getThreadContext()->setPSTexture(pTex, slot);
mem_release(pTex);
}
else
{
SGCore_GetDXDevice()->getDirectContext()->setPSTexture(NULL, slot);
SGCore_GetDXDevice()->getThreadContext()->setPSTexture(NULL, slot);
}
}
......
......@@ -1254,11 +1254,11 @@ void CMaterials::setMainTexture(ID slot, ID id)
{
IGXBaseTexture *pTex = NULL;
m_aUnitMtrls[id]->m_pMtrl->m_oMainGraphics.m_pMainTexture->getAPITexture(&pTex);
mtrl_data::pDXDevice->getDirectContext()->setPSTexture(pTex, slot);
mtrl_data::pDXDevice->getThreadContext()->setPSTexture(pTex, slot);
mem_release(pTex);
}
else
mtrl_data::pDXDevice->getDirectContext()->setPSTexture(0, slot);
mtrl_data::pDXDevice->getThreadContext()->setPSTexture(0, slot);
}
ID CMaterials::getID(const char* name)
......@@ -1933,7 +1933,7 @@ void CMaterials::render(ID id, const float4x4 *pWorld, const float4 *pColor)
{
MTL_PRE_COND_ID(id, _VOID);
IGXContext *pCtx = mtrl_data::pDXDevice->getDirectContext();
IGXContext *pCtx = mtrl_data::pDXDevice->getThreadContext();
static const int *r_win_width = GET_PCVAR_INT("r_win_width");
static const int *r_win_height = GET_PCVAR_INT("r_win_height");
......
......@@ -249,7 +249,7 @@ void CReflection::preRenderRefPlane(const SMPLANE* plane)
Core_RMatrixSet(G_RI_MATRIX_PROJECTION, &mtrl_data::mRefProjPlane);
Core_RMatrixSet(G_RI_MATRIX_VIEWPROJ, &(viewmat * mtrl_data::mRefProjPlane));
IGXContext *pCtx = mtrl_data::pDXDevice->getDirectContext();
IGXContext *pCtx = mtrl_data::pDXDevice->getThreadContext();
m_pBackBuffer = pCtx->getColorTarget();
......@@ -274,7 +274,7 @@ void CReflection::postRenderRefPlane()
mtrl_data::pDXDevice->GetRenderState(D3DRS_ZENABLE, &zenable);
mtrl_data::pDXDevice->GetRenderState(D3DRS_ZWRITEENABLE, &zwriteenable);
*/
IGXContext *pCtx = mtrl_data::pDXDevice->getDirectContext();
IGXContext *pCtx = mtrl_data::pDXDevice->getThreadContext();
pCtx->setDepthStencilState(m_pDSState);
pCtx->setBlendState(NULL);
......@@ -346,7 +346,7 @@ void CReflection::beginRenderRefCube(const float3_t* pCenter)
Core_RMatrixGet(G_RI_MATRIX_PROJECTION, &m_mOldMatProj);
Core_RMatrixGet(G_RI_MATRIX_VIEWPROJ, &m_mOldMatViewProj);
m_pBackBuffer = mtrl_data::pDXDevice->getDirectContext()->getColorTarget();
m_pBackBuffer = mtrl_data::pDXDevice->getThreadContext()->getColorTarget();
}
void CReflection::preRenderRefCube(ID idFace, const float4x4 *pWorld)
......@@ -374,7 +374,7 @@ void CReflection::preRenderRefCube(ID idFace, const float4x4 *pWorld)
mem_release(m_pSurface);
m_pSurface = m_pTexWork->getMipmap();
IGXContext *pCtx = mtrl_data::pDXDevice->getDirectContext();
IGXContext *pCtx = mtrl_data::pDXDevice->getThreadContext();
pCtx->setColorTarget(m_pSurface);
......@@ -387,7 +387,7 @@ void CReflection::postRenderRefCube(ID idFace)
DWORD alphablend, alphatest, zenable, zwriteenable;
IGXContext *pCtx = mtrl_data::pDXDevice->getDirectContext();
IGXContext *pCtx = mtrl_data::pDXDevice->getThreadContext();
/* mtrl_data::pDXDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &alphablend);
mtrl_data::pDXDevice->GetRenderState(D3DRS_ALPHATESTENABLE, &alphatest);
......@@ -433,7 +433,7 @@ void CReflection::endRenderRefCube(const float3_t *pViewPos)
Core_RMatrixSet(G_RI_MATRIX_PROJECTION, &m_mOldMatProj);
Core_RMatrixSet(G_RI_MATRIX_VIEWPROJ, &m_mOldMatViewProj);
mtrl_data::pDXDevice->getDirectContext()->setColorTarget(m_pBackBuffer);
mtrl_data::pDXDevice->getThreadContext()->setColorTarget(m_pBackBuffer);
mem_release_del(m_pBackBuffer);
updateCountUpdate(pViewPos);
......
......@@ -986,7 +986,7 @@ void CPhyWorld::CDebugDrawer::begin()
SGCore_ShaderBind(m_idShader);
IGXContext *pCtx = SGCore_GetDXDevice()->getDirectContext();
IGXContext *pCtx = SGCore_GetDXDevice()->getThreadContext();
pCtx->setRenderBuffer(m_pRenderBuffer);
pCtx->setPrimitiveTopology(GXPT_LINELIST);
......@@ -1002,7 +1002,7 @@ void CPhyWorld::CDebugDrawer::commit()
{
render();
SGCore_ShaderUnBind();
SGCore_GetDXDevice()->getDirectContext()->setPrimitiveTopology(GXPT_TRIANGLELIST);
SGCore_GetDXDevice()->getThreadContext()->setPrimitiveTopology(GXPT_TRIANGLELIST);
}
void CPhyWorld::CDebugDrawer::render()
......@@ -1018,7 +1018,7 @@ void CPhyWorld::CDebugDrawer::render()
memcpy(pData, m_pDrawData, sizeof(render_point) * m_uDataPointer);
m_pVertexBuffer->unlock();
SGCore_GetDXDevice()->getDirectContext()->drawPrimitive(0, m_uDataPointer / 2);
SGCore_GetDXDevice()->getThreadContext()->drawPrimitive(0, m_uDataPointer / 2);
}
m_uDataPointer = 0;
......
......@@ -235,7 +235,7 @@ void CRenderPipeline::renderFrame()
UINT timeDelta = 16;
static const int *r_final_image = GET_PCVAR_INT("r_final_image");
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
m_sceneShaderData.vNearFarInvWinSize = float4(gdata::vNearFar, 1.0f / (float)m_uOutWidth, 1.0f / (float)m_uOutHeight);
m_pSceneShaderDataPS->update(&m_sceneShaderData);
......@@ -380,7 +380,7 @@ void CRenderPipeline::newVisData(IXRenderableVisibility **ppVisibility)
void CRenderPipeline::showGICubes()
{
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->setPrimitiveTopology(GXPT_POINTLIST);
pCtx->setRenderBuffer(m_pGICubesRB);
......@@ -407,7 +407,7 @@ void CRenderPipeline::renderPrepare()
}
void CRenderPipeline::renderGBuffer()
{
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->setRasterizerState(NULL);
pCtx->setDepthStencilState(NULL);
......@@ -468,7 +468,7 @@ void CRenderPipeline::renderGI()
return;
}
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
IGXDepthStencilSurface *pOldDSSurface = pCtx->getDepthStencilSurface();
......@@ -852,7 +852,7 @@ void CRenderPipeline::renderTransparent()
assert(m_pMainCameraVisibility && m_pMainCameraVisibility->getPluginId() == -1);
CRenderableVisibility *pVis = (CRenderableVisibility*)m_pMainCameraVisibility;
IGXContext *pCtx = m_pDevice->getDirectContext();
IGXContext *pCtx = m_pDevice->getThreadContext();
pCtx->setDepthStencilState(m_pDepthStencilStateNoZWrite);
pCtx->setBlendState(m_pBlendStateAlpha);
......@@ -897,92 +897,95 @@ void CRenderPipeline::renderTransparent()
}
}
UINT uTotalPlanes = 0;
// Определение секущих плоскостей
for(UINT i = 0, l = aPSPs.size(); i < l; ++i)
if(aNodes.size())
{
XTransparentPSP *pPSP = &aPSPs[i];
XTransparentNode *pPSPNode = &aNodes[pPSP->uNode];
for(UINT j = 0, jl = aNodes.size(); j < jl; ++j)
UINT uTotalPlanes = 0;
// Определение секущих плоскостей
for(UINT i = 0, l = aPSPs.size(); i < l; ++i)
{
if(j == pPSP->uNode)
{
continue;
}
XTransparentNode *pNode = &aNodes[j];
XTransparentPSP *pPSP = &aPSPs[i];