Skip to content

Commit 06d1f1d

Browse files
authored
Fix render states spillover (PR #3412)
Fixes issue reported in comment: #3402 (comment)
1 parent f88d313 commit 06d1f1d

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

Client/core/CCore.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,11 +2012,21 @@ void CCore::OnPreHUDRender()
20122012
{
20132013
IDirect3DDevice9* pDevice = CGraphics::GetSingleton().GetDevice();
20142014

2015-
CGraphics::GetSingleton().EnteringMTARenderZone();
2015+
if (CGraphics::GetSingleton().HasLine3DPostFXQueueItems() || CGraphics::GetSingleton().HasPrimitive3DPostFXQueueItems())
2016+
{
2017+
/*
2018+
Although MTA render zones are expensive, we should use them twice in the bounds of the function
2019+
because some of render states from PostFX drain to the 2D part of the frame.
2020+
*/
2021+
CGraphics::GetSingleton().EnteringMTARenderZone();
2022+
2023+
CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue();
2024+
CGraphics::GetSingleton().DrawLine3DPostFXQueue();
2025+
2026+
CGraphics::GetSingleton().LeavingMTARenderZone();
2027+
}
20162028

2017-
// Draw post-fx 3D primitives
2018-
CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue();
2019-
CGraphics::GetSingleton().DrawLine3DPostFXQueue();
2029+
CGraphics::GetSingleton().EnteringMTARenderZone();
20202030

20212031
// Maybe capture screen and other stuff
20222032
CGraphics::GetSingleton().GetRenderItemManager()->DoPulse();

Client/core/Graphics/CGraphics.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,11 @@ bool CGraphics::HasLine3DPreGUIQueueItems(void)
16511651
return m_pLine3DBatcherPreGUI->HasItems() || m_pMaterialLine3DBatcherPreGUI->HasItems();
16521652
}
16531653

1654+
bool CGraphics::HasLine3DPostFXQueueItems()
1655+
{
1656+
return m_pLine3DBatcherPostFX->HasItems() || m_pMaterialLine3DBatcherPostFX->HasItems();
1657+
}
1658+
16541659
void CGraphics::DrawPrimitive3DPostFXQueue(void)
16551660
{
16561661
m_pPrimitive3DBatcherPostFX->Flush();
@@ -1662,6 +1667,11 @@ bool CGraphics::HasPrimitive3DPreGUIQueueItems(void)
16621667
return m_pMaterialPrimitive3DBatcherPreGUI->HasItems() || m_pPrimitive3DBatcherPreGUI->HasItems();
16631668
}
16641669

1670+
bool CGraphics::HasPrimitive3DPostFXQueueItems()
1671+
{
1672+
return m_pMaterialPrimitive3DBatcherPostFX->HasItems() || m_pPrimitive3DBatcherPostFX->HasItems();
1673+
}
1674+
16651675
void CGraphics::DrawQueue(std::vector<sDrawQueueItem>& Queue)
16661676
{
16671677
BeginDrawBatch();

Client/core/Graphics/CGraphics.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,11 @@ class CGraphics : public CGraphicsInterface, public CSingleton<CGraphics>
190190
void DrawLine3DPreGUIQueue(void);
191191
void DrawLine3DPostFXQueue(void);
192192
bool HasLine3DPreGUIQueueItems(void);
193+
bool HasLine3DPostFXQueueItems();
193194
void DrawPrimitive3DPostFXQueue(void);
194195
void DrawPrimitive3DPreGUIQueue(void);
195196
bool HasPrimitive3DPreGUIQueueItems(void);
197+
bool HasPrimitive3DPostFXQueueItems();
196198

197199
void DidRenderScene();
198200
void SetProgressMessage(const SString& strMessage);

0 commit comments

Comments
 (0)