From 851fef680164e3472b0516e7237bbcc4a35bc5a3 Mon Sep 17 00:00:00 2001 From: Callum Linden Date: Tue, 28 Sep 2021 15:24:42 -0700 Subject: SL-16102 Set window title to agent name (child of SL-15999 Support for low overhead, non interactive viewer sessions) --- indra/llwindow/llwindowwin32.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 0b3d14fb16..34dcb7f268 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -58,7 +58,8 @@ public: /*virtual*/ BOOL setSizeImpl(LLCoordScreen size); /*virtual*/ BOOL setSizeImpl(LLCoordWindow size); /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL); - /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); + /*virtual*/ void setTitle(const std::string title); + /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); /*virtual*/ void showCursor(); /*virtual*/ void hideCursor(); -- cgit v1.2.3 From 2148e4c731e1c0926c32fedb3e7047c96cd9eebf Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 1 Oct 2021 15:51:12 +0000 Subject: SL-16094 Move LLWindowWin32::mainWindowProc and Windows message handling to a background thread to prevent frame stalls in LLWindowWin32::gatherInput --- indra/llwindow/llwindowwin32.h | 46 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 0b3d14fb16..66647459b2 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -33,11 +33,46 @@ #include "llwindow.h" #include "llwindowcallbacks.h" #include "lldragdropwin32.h" +#include "llthread.h" +#include "llthreadsafequeue.h" // Hack for async host by name #define LL_WM_HOST_RESOLVED (WM_APP + 1) typedef void (*LLW32MsgCallback)(const MSG &msg); +class LLWindowWin32; + +// Thread that owns the Window Handle +class LLWindowWin32Thread : public LLThread +{ +public: + class Message + { + public: + LRESULT mMsg; + }; + + static const int MAX_QUEUE_SIZE = 2048; + + LLThreadSafeQueue mMessageQueue; + LLThreadSafeQueue> mFunctionQueue; + + bool mFinished = false; + + LLWindowWin32Thread(LLWindowWin32* window); + + void run() override; + + void post(const std::function& func); + +private: + + // call PeekMessage and pull enqueue messages for later processing + void gatherInput(); + LLWindowWin32* mWindow = nullptr; + +}; + class LLWindowWin32 : public LLWindow { public: @@ -172,9 +207,9 @@ protected: WCHAR *mWindowTitle; WCHAR *mWindowClassName; - HWND mWindowHandle; // window handle - HGLRC mhRC; // OpenGL rendering context - HDC mhDC; // Windows Device context handle + HWND mWindowHandle = 0; // window handle + HGLRC mhRC = 0; // OpenGL rendering context + HDC mhDC = 0; // Windows Device context handle HINSTANCE mhInstance; // handle to application instance WNDPROC mWndProc; // user-installable window proc RECT mOldMouseClip; // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse() @@ -221,7 +256,12 @@ protected: BOOL mMouseVanish; + LLWindowWin32Thread* mWindowThread = nullptr; + LLThreadSafeQueue> mFunctionQueue; + void post(const std::function& func); + friend class LLWindowManager; + friend class LLWindowWin32Thread; }; class LLSplashScreenWin32 : public LLSplashScreen -- cgit v1.2.3 From d00272e0cc9974f35a46f0c313ee2c0e11cddbda Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 11 Oct 2021 16:03:40 +0000 Subject: SL-16099 Multi-threaded OpenGL usage on Windows, enable Core Profile and VAOs by default. --- indra/llwindow/llwindowwin32.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 66647459b2..5f253b5df3 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -93,6 +93,9 @@ public: /*virtual*/ BOOL setSizeImpl(LLCoordScreen size); /*virtual*/ BOOL setSizeImpl(LLCoordWindow size); /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL); + void* createSharedContext() override; + void makeContextCurrent(void* context) override; + void destroySharedContext(void* context) override; /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); /*virtual*/ void showCursor(); -- cgit v1.2.3 From 5553d614211998b5a10529f6b3ec68d2b25dc07a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 22 Oct 2021 17:01:33 +0000 Subject: SL-16203 Fix for wonky handling of mouse deltas. --- indra/llwindow/llwindowwin32.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 5f253b5df3..b44d458fc6 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -35,6 +35,7 @@ #include "lldragdropwin32.h" #include "llthread.h" #include "llthreadsafequeue.h" +#include "llmutex.h" // Hack for async host by name #define LL_WM_HOST_RESOLVED (WM_APP + 1) @@ -98,6 +99,7 @@ public: void destroySharedContext(void* context) override; /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); + /*virtual*/ BOOL getCursorDelta(LLCoordCommon* delta); /*virtual*/ void showCursor(); /*virtual*/ void hideCursor(); /*virtual*/ void showCursorFromMouseMove(); @@ -221,6 +223,14 @@ protected: F32 mNativeAspectRatio; HCURSOR mCursor[ UI_CURSOR_COUNT ]; // Array of all mouse cursors + LLCoordWindow mCursorPosition; // mouse cursor position, should only be mutated on main thread + LLMutex mRawMouseMutex; + RAWINPUTDEVICE mRawMouse; + LLCoordWindow mLastCursorPosition; // mouse cursor position from previous frame + LLCoordCommon mRawMouseDelta; // raw mouse delta according to window thread + LLCoordCommon mMouseFrameDelta; // how much the mouse moved between the last two calls to gatherInput + + MASK mMouseMask; static BOOL sIsClassRegistered; // has the window class been registered? @@ -231,7 +241,6 @@ protected: BOOL mCustomGammaSet; LPWSTR mIconResource; - BOOL mMousePositionModified; BOOL mInputProcessingPaused; // The following variables are for Language Text Input control. @@ -261,7 +270,9 @@ protected: LLWindowWin32Thread* mWindowThread = nullptr; LLThreadSafeQueue> mFunctionQueue; + LLThreadSafeQueue> mMouseQueue; void post(const std::function& func); + void postMouseButtonEvent(const std::function& func); friend class LLWindowManager; friend class LLWindowWin32Thread; -- cgit v1.2.3 From c7af4921db7f62005f3f668ca7fca45d01d80781 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 5 Nov 2021 17:20:11 -0400 Subject: SL-16094: Use ThreadPool for LLWindowWin32Thread. Move the whole LLWindowWin32Thread class inside LLWindowWin32, and make it a struct. Migrate the struct declaration to llwindowwin32.cpp. Derive it from ThreadPool, which provides the WorkQueue. Use runPending() instead of manually popping and running individual queue items. Make its post() operation always PostMessage(bogus) whenever we put an entry in the WorkQueue, so we won't remain blocked in GetMessage(). Instead of storing a back pointer to the LLWindowWin32 instance, store the relevant HWND and HDC in LLWindowWin32Thread itself to avoid cross-thread timing problems. Extract both instances of a large duplicated block of LLWindowWin32 code to a new recreateWindow() method, and call it in those places. Per the TODO, use a std::future to pass the new HWND and HDC back to LLWindowWin32 -- but also store them locally on the LLWindowWin32Thread instance. --- indra/llwindow/llwindowwin32.h | 47 +++++++----------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 7a9a30ccea..97d1e6d7a3 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -36,44 +36,12 @@ #include "llthread.h" #include "llthreadsafequeue.h" #include "llmutex.h" +#include "workqueue.h" // Hack for async host by name #define LL_WM_HOST_RESOLVED (WM_APP + 1) typedef void (*LLW32MsgCallback)(const MSG &msg); -class LLWindowWin32; - -// Thread that owns the Window Handle -class LLWindowWin32Thread : public LLThread -{ -public: - class Message - { - public: - LRESULT mMsg; - }; - - static const int MAX_QUEUE_SIZE = 2048; - - LLThreadSafeQueue mMessageQueue; - LLThreadSafeQueue> mFunctionQueue; - - bool mFinished = false; - - LLWindowWin32Thread(LLWindowWin32* window); - - void run() override; - - void post(const std::function& func); - -private: - - // call PeekMessage and pull enqueue messages for later processing - void gatherInput(); - LLWindowWin32* mWindow = nullptr; - -}; - class LLWindowWin32 : public LLWindow { public: @@ -269,14 +237,15 @@ protected: BOOL mMouseVanish; - LLWindowWin32Thread* mWindowThread = nullptr; - LLThreadSafeQueue> mFunctionQueue; - LLThreadSafeQueue> mMouseQueue; - void post(const std::function& func); - void postMouseButtonEvent(const std::function& func); + struct LLWindowWin32Thread; + LLWindowWin32Thread* mWindowThread = nullptr; + LLThreadSafeQueue> mFunctionQueue; + LLThreadSafeQueue> mMouseQueue; + void post(const std::function& func); + void postMouseButtonEvent(const std::function& func); + void recreateWindow(RECT window_rect, DWORD dw_ex_style, DWORD dw_style); friend class LLWindowManager; - friend class LLWindowWin32Thread; }; class LLSplashScreenWin32 : public LLSplashScreen -- cgit v1.2.3 From 08336bb469b8db41809893a2ed26599777383eed Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 8 Nov 2021 15:15:56 -0500 Subject: SL-16094: Zap thread safety land mine; thin PostMessage() calls. LLWindowWin32::mWndProc was a public WNDPROC member. If set non-NULL, mainWindowProc() would call that before falling into its own handler code. But now, mWndProc would be called on the window thread instead of on the main thread. Running arbitrary callback code on the window thread could cause all sorts of problems. It could be made safe by posting the callback call to the "mainloop" WorkQueue for execution on the main thread. But as no code actually references it, delete it instead. Per DaveP, the recent change to LLWindowsWin32Thread::post() could end up calling PostMessage() many times per frame, with nontrivial overhead. Reinstate the more selective code that calls PostMessage() with the dummy message (to bust us out of GetMessage() to check pending window-thread work requests) at most once per frame. --- indra/llwindow/llwindowwin32.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 97d1e6d7a3..c3ce1e25a9 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -185,7 +185,6 @@ protected: HGLRC mhRC = 0; // OpenGL rendering context HDC mhDC = 0; // Windows Device context handle HINSTANCE mhInstance; // handle to application instance - WNDPROC mWndProc; // user-installable window proc RECT mOldMouseClip; // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse() WPARAM mLastSizeWParam; F32 mOverrideAspectRatio; -- cgit v1.2.3 From 768b7a4d33b64dc3e9d7f7c0c384bb2aa37b458b Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 9 Nov 2021 17:17:49 +0200 Subject: SL-16330 Clean up vertical sync handling, add to UI --- indra/llwindow/llwindowwin32.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 7a9a30ccea..d082080807 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -93,11 +93,12 @@ public: /*virtual*/ BOOL setPosition(LLCoordScreen position); /*virtual*/ BOOL setSizeImpl(LLCoordScreen size); /*virtual*/ BOOL setSizeImpl(LLCoordWindow size); - /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL); + /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL enable_vsync, const LLCoordScreen * const posp = NULL); /*virtual*/ void setTitle(const std::string title); void* createSharedContext() override; void makeContextCurrent(void* context) override; void destroySharedContext(void* context) override; + /*virtual*/ void toggleVSync(bool enable_vsync); /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); /*virtual*/ BOOL getCursorDelta(LLCoordCommon* delta); @@ -164,7 +165,7 @@ public: protected: LLWindowWin32(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags, - BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, + BOOL fullscreen, BOOL clearBg, BOOL enable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples); ~LLWindowWin32(); -- cgit v1.2.3 From 029b41c0419e975bbb28454538b46dc69ce5d2ba Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Mon, 15 Nov 2021 09:25:35 -0700 Subject: Revert "SL-16220: Merge branch 'origin/DRTVWR-546' into glthread" This reverts commit 5188a26a8521251dda07ac0140bb129f28417e49, reversing changes made to 819088563e13f1d75e048311fbaf0df4a79b7e19. --- indra/llwindow/llwindowwin32.h | 48 +++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 5966061177..d082080807 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -36,12 +36,44 @@ #include "llthread.h" #include "llthreadsafequeue.h" #include "llmutex.h" -#include "workqueue.h" // Hack for async host by name #define LL_WM_HOST_RESOLVED (WM_APP + 1) typedef void (*LLW32MsgCallback)(const MSG &msg); +class LLWindowWin32; + +// Thread that owns the Window Handle +class LLWindowWin32Thread : public LLThread +{ +public: + class Message + { + public: + LRESULT mMsg; + }; + + static const int MAX_QUEUE_SIZE = 2048; + + LLThreadSafeQueue mMessageQueue; + LLThreadSafeQueue> mFunctionQueue; + + bool mFinished = false; + + LLWindowWin32Thread(LLWindowWin32* window); + + void run() override; + + void post(const std::function& func); + +private: + + // call PeekMessage and pull enqueue messages for later processing + void gatherInput(); + LLWindowWin32* mWindow = nullptr; + +}; + class LLWindowWin32 : public LLWindow { public: @@ -186,6 +218,7 @@ protected: HGLRC mhRC = 0; // OpenGL rendering context HDC mhDC = 0; // Windows Device context handle HINSTANCE mhInstance; // handle to application instance + WNDPROC mWndProc; // user-installable window proc RECT mOldMouseClip; // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse() WPARAM mLastSizeWParam; F32 mOverrideAspectRatio; @@ -237,15 +270,14 @@ protected: BOOL mMouseVanish; - struct LLWindowWin32Thread; - LLWindowWin32Thread* mWindowThread = nullptr; - LLThreadSafeQueue> mFunctionQueue; - LLThreadSafeQueue> mMouseQueue; - void post(const std::function& func); - void postMouseButtonEvent(const std::function& func); - void recreateWindow(RECT window_rect, DWORD dw_ex_style, DWORD dw_style); + LLWindowWin32Thread* mWindowThread = nullptr; + LLThreadSafeQueue> mFunctionQueue; + LLThreadSafeQueue> mMouseQueue; + void post(const std::function& func); + void postMouseButtonEvent(const std::function& func); friend class LLWindowManager; + friend class LLWindowWin32Thread; }; class LLSplashScreenWin32 : public LLSplashScreen -- cgit v1.2.3 From a633efdc0b62f28f145ec26c2efa8dfc06a3729e Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 15 Nov 2021 14:34:30 -0500 Subject: SL-16094: In LLWindowWin32::recreateWindow(), kick window thread before blocking on the pending future. Otherwise the window thread can remain blocked in a GetMessage() call and deadlock the app. --- indra/llwindow/llwindowwin32.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 5966061177..b02815e990 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -244,6 +244,7 @@ protected: void post(const std::function& func); void postMouseButtonEvent(const std::function& func); void recreateWindow(RECT window_rect, DWORD dw_ex_style, DWORD dw_style); + void kickWindowThread(HWND windowHandle=0); friend class LLWindowManager; }; -- cgit v1.2.3 From 0b066539fe68dc5750900c3452189645c40adb45 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 24 Nov 2021 10:47:54 -0500 Subject: DRTVWR-546, SL-16220, SL-16094: Undo previous glthread branch revert. Reverting a merge is sticky: it tells git you never want to see that branch again. Merging the DRTVWR-546 branch, which contained the revert, into the glthread branch undid much of the development work on that branch. To restore it we must revert the revert. This reverts commit 029b41c0419e975bbb28454538b46dc69ce5d2ba. --- indra/llwindow/llwindowwin32.h | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 8d0193abc8..b02815e990 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -36,44 +36,12 @@ #include "llthread.h" #include "llthreadsafequeue.h" #include "llmutex.h" +#include "workqueue.h" // Hack for async host by name #define LL_WM_HOST_RESOLVED (WM_APP + 1) typedef void (*LLW32MsgCallback)(const MSG &msg); -class LLWindowWin32; - -// Thread that owns the Window Handle -class LLWindowWin32Thread : public LLThread -{ -public: - class Message - { - public: - LRESULT mMsg; - }; - - static const int MAX_QUEUE_SIZE = 2048; - - LLThreadSafeQueue mMessageQueue; - LLThreadSafeQueue> mFunctionQueue; - - bool mFinished = false; - - LLWindowWin32Thread(LLWindowWin32* window); - - void run() override; - - void post(const std::function& func); - -private: - - // call PeekMessage and pull enqueue messages for later processing - void gatherInput(); - LLWindowWin32* mWindow = nullptr; - -}; - class LLWindowWin32 : public LLWindow { public: @@ -218,7 +186,6 @@ protected: HGLRC mhRC = 0; // OpenGL rendering context HDC mhDC = 0; // Windows Device context handle HINSTANCE mhInstance; // handle to application instance - WNDPROC mWndProc; // user-installable window proc RECT mOldMouseClip; // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse() WPARAM mLastSizeWParam; F32 mOverrideAspectRatio; @@ -280,7 +247,6 @@ protected: void kickWindowThread(HWND windowHandle=0); friend class LLWindowManager; - friend class LLWindowWin32Thread; }; class LLSplashScreenWin32 : public LLSplashScreen -- cgit v1.2.3 From 9689e606f4da78dd5654124b3e90913b4e934b1a Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Thu, 9 Dec 2021 14:01:41 -0600 Subject: SL-16480 Fix for window not saving its position on exit. --- indra/llwindow/llwindowwin32.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llwindow/llwindowwin32.h') diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index b02815e990..9367f49510 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -237,6 +237,11 @@ protected: BOOL mMouseVanish; + // Cached values of GetWindowRect and GetClientRect to be used by app thread + void updateWindowRect(); + RECT mRect; + RECT mClientRect; + struct LLWindowWin32Thread; LLWindowWin32Thread* mWindowThread = nullptr; LLThreadSafeQueue> mFunctionQueue; -- cgit v1.2.3