diff --git a/src/Layers/xrRender/R_Backend_Runtime.cpp b/src/Layers/xrRender/R_Backend_Runtime.cpp index 6986d21ea6f..1ef0aef97be 100644 --- a/src/Layers/xrRender/R_Backend_Runtime.cpp +++ b/src/Layers/xrRender/R_Backend_Runtime.cpp @@ -126,7 +126,6 @@ void CBackend::Invalidate() // Redundant call. Just no note that we need to unmap const // if we create dedicated class. StateManager.UnmapConstants(); - SSManager.ResetDeviceState(); SRVSManager.ResetDeviceState(); for (u32 gs_it = 0; gs_it < mtMaxGeometryShaderTextures;) diff --git a/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.cpp b/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.cpp index 23ac488f56c..1988b616cd8 100644 --- a/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.cpp +++ b/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.cpp @@ -10,7 +10,6 @@ dx10SamplerStateCache::dx10SamplerStateCache() : m_uiMaxAnisotropy(1) { static const int iMaxRSStates = 10; m_StateArray.reserve(iMaxRSStates); - ResetDeviceState(); } dx10SamplerStateCache::~dx10SamplerStateCache() { ClearStateArray(); } @@ -85,12 +84,8 @@ void dx10SamplerStateCache::ClearStateArray() } void dx10SamplerStateCache::PrepareSamplerStates(HArray& samplers, - ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT], - SHandle pCurrentState[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT], u32& uiMin, u32& uiMax) const + ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]) const { - // It seems that sizeof pSS is 4 wor win32! - ZeroMemory(pSS, sizeof(pSS[0]) * D3D_COMMONSHADER_SAMPLER_SLOT_COUNT); - for (u32 i = 0; i < samplers.size(); ++i) { if (samplers[i] != hInvalidHandle) @@ -99,64 +94,49 @@ void dx10SamplerStateCache::PrepareSamplerStates(HArray& samplers, pSS[i] = m_StateArray[samplers[i]].m_pState; } } - - uiMin = 0; - uiMax = D3D_COMMONSHADER_SAMPLER_SLOT_COUNT - 1; } void dx10SamplerStateCache::VSApplySamplers(HArray& samplers) { - ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - u32 uiMin; - u32 uiMax; - PrepareSamplerStates(samplers, pSS, m_aVSSamplers, uiMin, uiMax); - HW.pContext->VSSetSamplers(uiMin, uiMax - uiMin + 1, &pSS[uiMin]); + ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr }; + PrepareSamplerStates(samplers, pSS); + HW.pContext->VSSetSamplers(0, D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS); } void dx10SamplerStateCache::PSApplySamplers(HArray& samplers) { - ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - u32 uiMin; - u32 uiMax; - PrepareSamplerStates(samplers, pSS, m_aPSSamplers, uiMin, uiMax); - HW.pContext->PSSetSamplers(uiMin, uiMax - uiMin + 1, &pSS[uiMin]); + ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr }; + PrepareSamplerStates(samplers, pSS); + HW.pContext->PSSetSamplers(0, D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS); } void dx10SamplerStateCache::GSApplySamplers(HArray& samplers) { - ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - u32 uiMin; - u32 uiMax; - PrepareSamplerStates(samplers, pSS, m_aGSSamplers, uiMin, uiMax); - HW.pContext->GSSetSamplers(uiMin, uiMax - uiMin + 1, &pSS[uiMin]); + ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr }; + PrepareSamplerStates(samplers, pSS); + HW.pContext->GSSetSamplers(0, D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS); } #ifdef USE_DX11 void dx10SamplerStateCache::HSApplySamplers(HArray& samplers) { - ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - u32 uiMin; - u32 uiMax; - PrepareSamplerStates(samplers, pSS, m_aHSSamplers, uiMin, uiMax); - HW.pContext->HSSetSamplers(uiMin, uiMax - uiMin + 1, &pSS[uiMin]); + ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr }; + PrepareSamplerStates(samplers, pSS); + HW.pContext->HSSetSamplers(0, D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS); } void dx10SamplerStateCache::DSApplySamplers(HArray& samplers) { - ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - u32 uiMin; - u32 uiMax; - PrepareSamplerStates(samplers, pSS, m_aDSSamplers, uiMin, uiMax); - HW.pContext->DSSetSamplers(uiMin, uiMax - uiMin + 1, &pSS[uiMin]); + ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr }; + PrepareSamplerStates(samplers, pSS); + HW.pContext->DSSetSamplers(0, D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS); } void dx10SamplerStateCache::CSApplySamplers(HArray& samplers) { - ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - u32 uiMin; - u32 uiMax; - PrepareSamplerStates(samplers, pSS, m_aCSSamplers, uiMin, uiMax); - HW.pContext->CSSetSamplers(uiMin, uiMax - uiMin + 1, &pSS[uiMin]); + ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr }; + PrepareSamplerStates(samplers, pSS); + HW.pContext->CSSetSamplers(0, D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS); } #endif @@ -188,18 +168,3 @@ void dx10SamplerStateCache::SetMaxAnisotropy(UINT uiMaxAniso) CreateState(desc, &rec.m_pState); } } - -void dx10SamplerStateCache::ResetDeviceState() -{ - for (int i = 0; i < sizeof(m_aPSSamplers) / sizeof(m_aPSSamplers[0]); ++i) - { - m_aPSSamplers[i] = (SHandle)hInvalidHandle; - m_aVSSamplers[i] = (SHandle)hInvalidHandle; - m_aGSSamplers[i] = (SHandle)hInvalidHandle; -#ifdef USE_DX11 - m_aHSSamplers[i] = (SHandle)hInvalidHandle; - m_aDSSamplers[i] = (SHandle)hInvalidHandle; - m_aCSSamplers[i] = (SHandle)hInvalidHandle; -#endif - } -} diff --git a/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.h b/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.h index 07c33e3da11..2fd19aef98e 100644 --- a/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.h +++ b/src/Layers/xrRenderDX10/StateManager/dx10SamplerStateCache.h @@ -33,10 +33,6 @@ class dx10SamplerStateCache void SetMaxAnisotropy(UINT uiMaxAniso); - // Marks all device sample as unused - void ResetDeviceState(); - - // Private declarations private: typedef ID3DSamplerState IDeviceState; typedef D3D_SAMPLER_DESC StateDecs; @@ -51,23 +47,13 @@ class dx10SamplerStateCache void CreateState(StateDecs desc, IDeviceState** ppIState); SHandle FindState(const StateDecs& desc, u32 StateCRC); - void PrepareSamplerStates(HArray& samplers, ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT], - SHandle pCurrentState[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT], u32& uiMin, u32& uiMax) const; + void PrepareSamplerStates(HArray& samplers, ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]) const; // Private data private: // This must be cleared on device destroy xr_vector m_StateArray; - SHandle m_aPSSamplers[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - SHandle m_aVSSamplers[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - SHandle m_aGSSamplers[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; -#ifdef USE_DX11 - SHandle m_aHSSamplers[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - SHandle m_aDSSamplers[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; - SHandle m_aCSSamplers[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]; -#endif - u32 m_uiMaxAnisotropy; };