Skip to content

Fix render states spillover #3412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,11 +2012,21 @@ void CCore::OnPreHUDRender()
{
IDirect3DDevice9* pDevice = CGraphics::GetSingleton().GetDevice();

CGraphics::GetSingleton().EnteringMTARenderZone();
if (CGraphics::GetSingleton().HasLine3DPostFXQueueItems() || CGraphics::GetSingleton().HasPrimitive3DPostFXQueueItems())
{
/*
Although MTA render zones are expensive, we should use them twice in the bounds of the function
because some of render states from PostFX drain to the 2D part of the frame.
*/
CGraphics::GetSingleton().EnteringMTARenderZone();

CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue();
CGraphics::GetSingleton().DrawLine3DPostFXQueue();

CGraphics::GetSingleton().LeavingMTARenderZone();
}

// Draw post-fx 3D primitives
CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue();
CGraphics::GetSingleton().DrawLine3DPostFXQueue();
CGraphics::GetSingleton().EnteringMTARenderZone();

// Maybe capture screen and other stuff
CGraphics::GetSingleton().GetRenderItemManager()->DoPulse();
Expand Down
10 changes: 10 additions & 0 deletions Client/core/Graphics/CGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,11 @@ bool CGraphics::HasLine3DPreGUIQueueItems(void)
return m_pLine3DBatcherPreGUI->HasItems() || m_pMaterialLine3DBatcherPreGUI->HasItems();
}

bool CGraphics::HasLine3DPostFXQueueItems()
{
return m_pLine3DBatcherPostFX->HasItems() || m_pMaterialLine3DBatcherPostFX->HasItems();
}

void CGraphics::DrawPrimitive3DPostFXQueue(void)
{
m_pPrimitive3DBatcherPostFX->Flush();
Expand All @@ -1662,6 +1667,11 @@ bool CGraphics::HasPrimitive3DPreGUIQueueItems(void)
return m_pMaterialPrimitive3DBatcherPreGUI->HasItems() || m_pPrimitive3DBatcherPreGUI->HasItems();
}

bool CGraphics::HasPrimitive3DPostFXQueueItems()
{
return m_pMaterialPrimitive3DBatcherPostFX->HasItems() || m_pPrimitive3DBatcherPostFX->HasItems();
}

void CGraphics::DrawQueue(std::vector<sDrawQueueItem>& Queue)
{
BeginDrawBatch();
Expand Down
2 changes: 2 additions & 0 deletions Client/core/Graphics/CGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ class CGraphics : public CGraphicsInterface, public CSingleton<CGraphics>
void DrawLine3DPreGUIQueue(void);
void DrawLine3DPostFXQueue(void);
bool HasLine3DPreGUIQueueItems(void);
bool HasLine3DPostFXQueueItems();
void DrawPrimitive3DPostFXQueue(void);
void DrawPrimitive3DPreGUIQueue(void);
bool HasPrimitive3DPreGUIQueueItems(void);
bool HasPrimitive3DPostFXQueueItems();

void DidRenderScene();
void SetProgressMessage(const SString& strMessage);
Expand Down
Loading