From 3313f382bd872ccb68509afbbdbc51c3a96b816f Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 27 Apr 2020 15:30:54 -0700 Subject: SL-12971: Add logging of Display Devices -- useful on dual GPU machines --- indra/llwindow/llwindowwin32.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'indra/llwindow/llwindowwin32.cpp') diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 0b3936f8a5..de83efb8a3 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -676,6 +676,37 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, // TrackMouseEvent( &track_mouse_event ); // } + // SL-12971 dual GPU display + DISPLAY_DEVICEA display_device; + int display_index = -1; + DWORD display_flags = 0; // EDD_GET_DEVICE_INTERFACE_NAME ? + const size_t display_bytes = sizeof(display_device); + + do + { + if (display_index >= 0) + { + // CHAR DeviceName [ 32] Adapter name + // CHAR DeviceString[128] + CHAR text[256]; + + size_t name_len = strlen(display_device.DeviceName ); + size_t desc_len = strlen(display_device.DeviceString); + + CHAR *name = name_len ? display_device.DeviceName : "???"; + CHAR *desc = desc_len ? display_device.DeviceString : "???"; + + sprintf(text, "Display Device %d: %s, %s", display_index, name, desc); + LL_INFOS("Window") << text << LL_ENDL; + } + + ::ZeroMemory(&display_device,display_bytes); + display_device.cb = display_bytes; + + display_index++; + } while( EnumDisplayDevicesA(NULL, display_index, &display_device, display_flags )); + + LL_INFOS("Window") << "Total Display Devices: " << display_index << LL_ENDL; //----------------------------------------------------------------------- // Create GL drawing context -- cgit v1.2.3 From 1a8800b051166d3406065df312c66b7e4f00fe05 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 19 Nov 2020 16:56:10 +0000 Subject: SL-14347 Crash at ChoosePixelFormat --- indra/llwindow/llwindowwin32.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'indra/llwindow/llwindowwin32.cpp') diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 8ec85976c3..6831071cd1 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -428,7 +428,8 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, memset(mCurrentGammaRamp, 0, sizeof(mCurrentGammaRamp)); memset(mPrevGammaRamp, 0, sizeof(mPrevGammaRamp)); mCustomGammaSet = FALSE; - + mWindowHandle = NULL; + if (!SystemParametersInfo(SPI_GETMOUSEVANISH, 0, &mMouseVanish, 0)) { mMouseVanish = TRUE; @@ -1169,7 +1170,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO << " Height: " << (window_rect.bottom - window_rect.top) << " Fullscreen: " << mFullscreen << LL_ENDL; - if (!destroy_window_handler(mWindowHandle)) + if (mWindowHandle && !destroy_window_handler(mWindowHandle)) { LL_WARNS("Window") << "Failed to properly close window before recreating it!" << LL_ENDL; } @@ -1228,13 +1229,26 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO LL_INFOS("Window") << "Device context retrieved." << LL_ENDL ; - if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) - { - close(); - OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), - mCallbacks->translateString("MBError"), OSMB_OK); - return FALSE; - } + try + { + // Looks like ChoosePixelFormat can crash in case of faulty driver + if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) + { + LL_WARNS("Window") << "ChoosePixelFormat failed, code: " << GetLastError() << LL_ENDL; + OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + close(); + return FALSE; + } + } + catch (...) + { + LL_WARNS("Window") << "ChoosePixelFormat failed." << LL_ENDL; + OSMessageBox(mCallbacks->translateString("MBPixelFmtErr"), + mCallbacks->translateString("MBError"), OSMB_OK); + close(); + return FALSE; + } LL_INFOS("Window") << "Pixel format chosen." << LL_ENDL ; @@ -1494,7 +1508,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO } // Destroy The Window - if (!destroy_window_handler(mWindowHandle)) + if (mWindowHandle && !destroy_window_handler(mWindowHandle)) { LL_WARNS("Window") << "Failed to properly close window!" << LL_ENDL; } -- cgit v1.2.3 From ef4c7c124753ca93659e34c6bbf0f6ef0ca208e7 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 21 Jan 2021 17:29:54 -0800 Subject: SL-14705: Merge Sovereign Engineer's fix for name tags showing in front with AMD GPUs: Fix GL_INVALID_OPERATION when copying stencil to default window framebuffer on AMD graphics on windows --- indra/llwindow/llwindowwin32.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'indra/llwindow/llwindowwin32.cpp') diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 6831071cd1..0db9886d03 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1474,24 +1474,29 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO LL_INFOS("Window") << "pixel formats done." << LL_ENDL ; - S32 swap_method = 0; - S32 cur_format = num_formats-1; - GLint swap_query = WGL_SWAP_METHOD_ARB; - - BOOL found_format = FALSE; - - while (!found_format && wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method)) + S32 swap_method = 0; + S32 cur_format = 0; + GLint swap_query = WGL_SWAP_METHOD_ARB; + + // SL-14705 Fix name tags showing in front of objects with AMD GPUs. + // On AMD hardware we need to iterate from the first pixel format to the end. + // Spec: + // https://www.khronos.org/registry/OpenGL/extensions/ARB/WGL_ARB_pixel_format.txt + while (wglGetPixelFormatAttribivARB(mhDC, pixel_formats[cur_format], 0, 1, &swap_query, &swap_method)) { - if (swap_method == WGL_SWAP_UNDEFINED_ARB || cur_format <= 0) + if (swap_method == WGL_SWAP_UNDEFINED_ARB) { - found_format = TRUE; + break; } - else + else if (cur_format >= (S32)(num_formats - 1)) { - --cur_format; + cur_format = 0; + break; } + + ++cur_format; } - + pixel_format = pixel_formats[cur_format]; if (mhDC != 0) // Does The Window Have A Device Context? -- cgit v1.2.3 From 7b2dd98962c92a4ae84ce8042109f0d9ec9b4b56 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 22 Jan 2021 16:48:31 -0800 Subject: SL-14705: Cleanup U32 S32 cast --- indra/llwindow/llwindowwin32.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llwindow/llwindowwin32.cpp') diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 0db9886d03..afe0c2cc6a 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1476,6 +1476,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO S32 swap_method = 0; S32 cur_format = 0; +const S32 max_format = (S32)num_formats - 1; GLint swap_query = WGL_SWAP_METHOD_ARB; // SL-14705 Fix name tags showing in front of objects with AMD GPUs. @@ -1488,7 +1489,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO { break; } - else if (cur_format >= (S32)(num_formats - 1)) + else if (cur_format >= max_format) { cur_format = 0; break; -- cgit v1.2.3