From 9952b1f764a32eb227e1ddd8f05184bfbb864221 Mon Sep 17 00:00:00 2001 From: Andrew Woloszyn Date: Mon, 7 May 2018 16:22:29 -0400 Subject: [PATCH] Add context destruction blacklist. This will cause a context and window leak, which is bad, but only for certain hardware combinations. We can remove once we figure out exactly waht is causing this behavior. --- core/os/device/deviceinfo/cc/query.cpp | 13 ++++++++++++- core/os/device/deviceinfo/cc/windows/query.cpp | 13 ++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/core/os/device/deviceinfo/cc/query.cpp b/core/os/device/deviceinfo/cc/query.cpp index 1b6a08d36b..3aadf9ae75 100644 --- a/core/os/device/deviceinfo/cc/query.cpp +++ b/core/os/device/deviceinfo/cc/query.cpp @@ -160,7 +160,18 @@ void buildDeviceInstance(const query::Option& opt, void* platform_data, instance->set_allocated_configuration(configuration); deviceInstanceID(instance); - query::destroyContext(); + // Blacklist of OS/Hardware version that means we cannot safely + // destroy the context. + // https://github.com/google/gapid/issues/1867 + bool blacklist = false; + if (std::string(gpuName).find("Vega") != std::string::npos && + std::string(query::osName()).find("Windows 10") != std::string::npos) { + blacklist = true; + } + + if (!blacklist) { + query::destroyContext(); + } *out = instance; } diff --git a/core/os/device/deviceinfo/cc/windows/query.cpp b/core/os/device/deviceinfo/cc/windows/query.cpp index c77f08e296..3690dc73cc 100644 --- a/core/os/device/deviceinfo/cc/windows/query.cpp +++ b/core/os/device/deviceinfo/cc/windows/query.cpp @@ -26,16 +26,19 @@ namespace { static const char* wndClassName = TEXT("opengl-dummy-window"); -WNDCLASS registerWindowClass() { - WNDCLASS wc; +WNDCLASSEX registerWindowClass() { + WNDCLASSEX wc; memset(&wc, 0, sizeof(wc)); - wc.style = 0; + wc.cbSize = sizeof(wc); +// We must use CS_OWNDC here if we are to use this window with GL. +// https://www.khronos.org/opengl/wiki/Creating_an_OpenGL_Context_(WGL)#The_Window_Itself + wc.style = CS_OWNDC; wc.lpfnWndProc = DefWindowProc; wc.hInstance = GetModuleHandle(0); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.lpszMenuName = TEXT(""); wc.lpszClassName = wndClassName; - RegisterClass(&wc); + RegisterClassEx(&wc); return wc; } @@ -91,7 +94,7 @@ void createGlContext() { return; } - WNDCLASS wc = registerWindowClass(); + WNDCLASSEX wc = registerWindowClass(); gContext.mWnd = CreateWindow(wndClassName, TEXT(""), WS_POPUP, 0, 0, 8, 8, 0, 0, GetModuleHandle(0), 0); if (gContext.mWnd == nullptr) { return;