summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowwin32.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-10-13 09:30:36 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2024-10-13 09:30:36 +0300
commitf93d237196c3b8bfef43d241fe4ae45b437a314b (patch)
tree3985495f413a3cb59f637c470b7ab4ce64fdcf23 /indra/llwindow/llwindowwin32.cpp
parent1da6053cdef9828bcb4f75e21cd655edc15e3c4e (diff)
parent9e24b300d02e5627ea0d304d412cb683ec2de3a4 (diff)
Merge branch 'release/maint-c' into marchcat/c-develop
# Conflicts: # indra/llwindow/llwindowwin32.cpp # indra/newview/llappviewer.cpp # indra/newview/llfloaterinventorysettings.cpp # indra/newview/llinventoryfunctions.cpp # indra/newview/llteleporthistorystorage.cpp # indra/newview/lltexturectrl.cpp # indra/newview/lltexturectrl.h # indra/newview/llviewerparceloverlay.cpp
Diffstat (limited to 'indra/llwindow/llwindowwin32.cpp')
-rw-r--r--indra/llwindow/llwindowwin32.cpp79
1 files changed, 48 insertions, 31 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index fb3363dad1..8d884b174b 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -344,7 +344,12 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool
void run() override;
- // closes queue, wakes thread, waits until thread closes
+ // Detroys handles and window
+ // Either post to or call from window thread
+ void destroyWindow();
+
+ // Closes queue, wakes thread, waits until thread closes.
+ // Call from main thread
bool wakeAndDestroy();
void glReady()
@@ -401,8 +406,16 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool
// *HACK: Attempt to prevent startup crashes by deferring memory accounting
// until after some graphics setup. See SL-20177. -Cosmic,2023-09-18
bool mGLReady = false;
- bool mDeleteOnExit = false;
bool mGotGLBuffer = false;
+ LLAtomicBool mDeleteOnExit = false;
+ // best guess at available video memory in MB
+ std::atomic<U32> mAvailableVRAM;
+
+ U32 mMaxVRAM = 0; // maximum amount of vram to allow in the "budget", or 0 for no maximum (see updateVRAMUsage)
+
+ IDXGIAdapter3* mDXGIAdapter = nullptr;
+ LPDIRECT3D9 mD3D = nullptr;
+ LPDIRECT3DDEVICE9 mD3DDevice = nullptr;
};
@@ -846,6 +859,7 @@ LLWindowWin32::~LLWindowWin32()
}
delete mDragDrop;
+ mDragDrop = NULL;
delete [] mWindowTitle;
mWindowTitle = NULL;
@@ -857,6 +871,7 @@ LLWindowWin32::~LLWindowWin32()
mWindowClassName = NULL;
delete mWindowThread;
+ mWindowThread = NULL;
}
void LLWindowWin32::show()
@@ -4783,12 +4798,43 @@ void LLWindowWin32::LLWindowWin32Thread::run()
#endif
}
+ destroyWindow();
+
if (mDeleteOnExit)
{
delete this;
}
}
+void LLWindowWin32::LLWindowWin32Thread::destroyWindow()
+{
+ if (mWindowHandleThrd != NULL && IsWindow(mWindowHandleThrd))
+ {
+ if (mhDCThrd)
+ {
+ if (!ReleaseDC(mWindowHandleThrd, mhDCThrd))
+ {
+ LL_WARNS("Window") << "Release of ghDC failed!" << LL_ENDL;
+ }
+ mhDCThrd = NULL;
+ }
+
+ // This causes WM_DESTROY to be sent *immediately*
+ if (!destroy_window_handler(mWindowHandleThrd))
+ {
+ LL_WARNS("Window") << "Failed to destroy Window! " << std::hex << GetLastError() << LL_ENDL;
+ }
+ }
+ else
+ {
+ // Something killed the window while we were busy destroying gl or handle somehow got broken
+ LL_WARNS("Window") << "Failed to destroy Window, invalid handle!" << LL_ENDL;
+ }
+ mWindowHandleThrd = NULL;
+ mhDCThrd = NULL;
+ mGLReady = false;
+}
+
bool LLWindowWin32::LLWindowWin32Thread::wakeAndDestroy()
{
if (mQueue->isClosed())
@@ -4804,35 +4850,6 @@ bool LLWindowWin32::LLWindowWin32Thread::wakeAndDestroy()
// Schedule destruction
HWND old_handle = mWindowHandleThrd;
- post([this]()
- {
- if (IsWindow(mWindowHandleThrd))
- {
- if (mhDCThrd)
- {
- if (!ReleaseDC(mWindowHandleThrd, mhDCThrd))
- {
- LL_WARNS("Window") << "Release of ghDC failed!" << LL_ENDL;
- }
- mhDCThrd = NULL;
- }
-
- // This causes WM_DESTROY to be sent *immediately*
- if (!destroy_window_handler(mWindowHandleThrd))
- {
- LL_WARNS("Window") << "Failed to destroy Window! " << std::hex << GetLastError() << LL_ENDL;
- }
- }
- else
- {
- // Something killed the window while we were busy destroying gl or handle somehow got broken
- LL_WARNS("Window") << "Failed to destroy Window, invalid handle!" << LL_ENDL;
- }
- mWindowHandleThrd = NULL;
- mhDCThrd = NULL;
- mGLReady = false;
- });
-
mDeleteOnExit = true;
SetWindowLongPtr(old_handle, GWLP_USERDATA, NULL);