From 2a63e062b0e71c291d57aa155d9462f68fed8535 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Apr 2018 10:32:56 +0200 Subject: Tests: add --no-window-focus to open window without focus. This is useful to run OpenGL tests while continuing to do other tasks without windows constantly popping up in the foreground. --- intern/ghost/GHOST_C-api.h | 5 +++++ intern/ghost/GHOST_ISystem.h | 5 +++++ intern/ghost/intern/GHOST_C-api.cpp | 6 ++++++ intern/ghost/intern/GHOST_System.cpp | 6 ++++++ intern/ghost/intern/GHOST_System.h | 6 ++++++ intern/ghost/intern/GHOST_SystemCocoa.mm | 12 +++++++----- intern/ghost/intern/GHOST_WindowWin32.cpp | 9 +++++++-- intern/ghost/intern/GHOST_WindowX11.cpp | 10 +++++++--- 8 files changed, 49 insertions(+), 10 deletions(-) (limited to 'intern') diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 86e64b7eeb0..bc5c67f4bed 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -907,6 +907,11 @@ extern int GHOST_SupportsNativeDialogs(void); */ extern int GHOST_UseNativePixels(void); +/** + * Focus window after opening, or put them in the background. + */ +extern void GHOST_UseWindowFocus(int use_focus); + /** * If window was opened using native pixel size, it returns scaling factor. */ diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index be2a94bd508..9b017c2da38 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -306,6 +306,11 @@ public: */ virtual bool useNativePixel(void) = 0; + /** + * Focus window after opening, or put them in the background. + */ + virtual void useWindowFocus(const bool use_focus) = 0; + /*************************************************************************************** * Event management functionality ***************************************************************************************/ diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 797fb16dd6f..e60a8a9d3f3 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -911,6 +911,12 @@ int GHOST_UseNativePixels(void) return system->useNativePixel(); } +void GHOST_UseWindowFocus(int use_focus) +{ + GHOST_ISystem *system = GHOST_ISystem::getSystem(); + return system->useWindowFocus(use_focus); +} + float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle) { GHOST_IWindow *window = (GHOST_IWindow *) windowhandle; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 0629eacc3ff..39f915bb0c2 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -48,6 +48,7 @@ GHOST_System::GHOST_System() : m_nativePixel(false), + m_windowFocus(true), m_displayManager(NULL), m_timerManager(NULL), m_windowManager(NULL), @@ -390,3 +391,8 @@ bool GHOST_System::useNativePixel(void) m_nativePixel = true; return 1; } + +void GHOST_System::useWindowFocus(const bool use_focus) +{ + m_windowFocus = use_focus; +} diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 464d9269f28..ee3c30c35b4 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -177,6 +177,12 @@ public: bool useNativePixel(void); bool m_nativePixel; + /** + * Focus window after opening, or put them in the background. + */ + void useWindowFocus(const bool use_focus); + bool m_windowFocus; + /*************************************************************************************** * Event management functionality ***************************************************************************************/ diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 916da546669..697c0fae809 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -304,11 +304,13 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // raise application to front, convenient when starting from the terminal - // and important for launching the animation player. we call this after the - // application finishes launching, as doing it earlier can make us end up - // with a frontmost window but an inactive application - [NSApp activateIgnoringOtherApps:YES]; + if (systemCocoa->m_windowFocus) { + // Raise application to front, convenient when starting from the terminal + // and important for launching the animation player. we call this after the + // application finishes launching, as doing it earlier can make us end up + // with a frontmost window but an inactive application. + [NSApp activateIgnoringOtherApps:YES]; + } } - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 92de41a859b..00096c05ee3 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -201,6 +201,11 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, // Store a pointer to this class in the window structure ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, (LONG_PTR) this); + if (!m_system->m_windowFocus) { + // Lower to bottom and don't activate if we don't want focus + ::SetWindowPos(m_hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + } + // Store the device context m_hDC = ::GetDC(m_hWnd); @@ -214,11 +219,11 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, nCmdShow = SW_SHOWMAXIMIZED; break; case GHOST_kWindowStateMinimized: - nCmdShow = SW_SHOWMINIMIZED; + nCmdShow = (m_system->m_windowFocus) ? SW_SHOWMINIMIZED : SW_SHOWMINNOACTIVE; break; case GHOST_kWindowStateNormal: default: - nCmdShow = SW_SHOWNORMAL; + nCmdShow = (m_system->m_windowFocus) ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE; break; } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 623d57705b2..a4ccdef3788 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -517,7 +517,7 @@ GHOST_WindowX11(GHOST_SystemX11 *system, natom++; } - if (m_system->m_atom.WM_TAKE_FOCUS) { + if (m_system->m_atom.WM_TAKE_FOCUS && m_system->m_windowFocus) { atoms[natom] = m_system->m_atom.WM_TAKE_FOCUS; natom++; } @@ -532,7 +532,7 @@ GHOST_WindowX11(GHOST_SystemX11 *system, { XWMHints *xwmhints = XAllocWMHints(); xwmhints->initial_state = NormalState; - xwmhints->input = True; + xwmhints->input = (m_system->m_windowFocus) ? True : False; xwmhints->flags = InputHint | StateHint; XSetWMHints(display, m_window, xwmhints); XFree(xwmhints); @@ -586,11 +586,15 @@ GHOST_WindowX11(GHOST_SystemX11 *system, setTitle(title); - if (exclusive) { + if (exclusive && system->m_windowFocus) { XMapRaised(m_display, m_window); } else { XMapWindow(m_display, m_window); + + if (!system->m_windowFocus) { + XLowerWindow(m_display, m_window); + } } GHOST_PRINT("Mapped window\n"); -- cgit v1.2.3 From bee16ec4d8a19cfaecb95df804e350846148b30c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 27 Sep 2018 13:42:16 +0200 Subject: Cycles: Sync BVH8 unaligned node packing code with BVH4 Similar to dfae3de6bdf. --- intern/cycles/bvh/bvh8.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'intern') diff --git a/intern/cycles/bvh/bvh8.cpp b/intern/cycles/bvh/bvh8.cpp index 70d003d938a..8db06c31863 100644 --- a/intern/cycles/bvh/bvh8.cpp +++ b/intern/cycles/bvh/bvh8.cpp @@ -222,21 +222,21 @@ void BVH8::pack_unaligned_node(int idx, * so kernel might safely assume there are always 4 child nodes. */ - data[1][i] = 1.0f; - data[2][i] = 0.0f; - data[3][i] = 0.0f; + data[1][i] = NAN; + data[2][i] = NAN; + data[3][i] = NAN; - data[4][i] = 0.0f; - data[5][i] = 0.0f; - data[6][i] = 0.0f; + data[4][i] = NAN; + data[5][i] = NAN; + data[6][i] = NAN; - data[7][i] = 0.0f; - data[8][i] = 0.0f; - data[9][i] = 0.0f; + data[7][i] = NAN; + data[8][i] = NAN; + data[9][i] = NAN; - data[10][i] = -FLT_MAX; - data[11][i] = -FLT_MAX; - data[12][i] = -FLT_MAX; + data[10][i] = NAN; + data[11][i] = NAN; + data[12][i] = NAN; data[13][i] = __int_as_float(0); } -- cgit v1.2.3 From 8f9a6b1bab89b9af821b3996514af7de7c8cce7c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 27 Sep 2018 14:47:52 +0200 Subject: Cycles: Cleanup --- intern/cycles/bvh/bvh8.cpp | 7 +++++-- intern/cycles/kernel/bvh/obvh_traversal.h | 2 +- intern/cycles/kernel/bvh/qbvh_traversal.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'intern') diff --git a/intern/cycles/bvh/bvh8.cpp b/intern/cycles/bvh/bvh8.cpp index 8db06c31863..b95fe572e27 100644 --- a/intern/cycles/bvh/bvh8.cpp +++ b/intern/cycles/bvh/bvh8.cpp @@ -124,6 +124,7 @@ void BVH8::pack_aligned_node(int idx, data[0].a = __uint_as_float(visibility & ~PATH_RAY_NODE_UNALIGNED); data[0].b = time_from; data[0].c = time_to; + for(int i = 0; i < num; i++) { float3 bb_min = bounds[i].min; float3 bb_max = bounds[i].max; @@ -140,8 +141,8 @@ void BVH8::pack_aligned_node(int idx, for(int i = num; i < 8; i++) { /* We store BB which would never be recorded as intersection - * so kernel might safely assume there are always 4 child nodes. - */ + * so kernel might safely assume there are always 4 child nodes. + */ data[1][i] = FLT_MAX; data[2][i] = -FLT_MAX; @@ -153,6 +154,7 @@ void BVH8::pack_aligned_node(int idx, data[7][i] = __int_as_float(0); } + memcpy(&pack.nodes[idx], data, sizeof(float4)*BVH_ONODE_SIZE); } @@ -189,6 +191,7 @@ void BVH8::pack_unaligned_node(int idx, { float8 data[BVH_UNALIGNED_ONODE_SIZE]; memset(data, 0, sizeof(data)); + data[0].a = __uint_as_float(visibility | PATH_RAY_NODE_UNALIGNED); data[0].b = time_from; data[0].c = time_to; diff --git a/intern/cycles/kernel/bvh/obvh_traversal.h b/intern/cycles/kernel/bvh/obvh_traversal.h index 2021d8e1143..98cd8f000ba 100644 --- a/intern/cycles/kernel/bvh/obvh_traversal.h +++ b/intern/cycles/kernel/bvh/obvh_traversal.h @@ -179,7 +179,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, avxf cnodes; /* TODO(sergey): Investigate whether moving cnodes upwards * gives a speedup (will be different cache pattern but will - * avoid extra check here), + * avoid extra check here). */ #if BVH_FEATURE(BVH_HAIR) if(__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) { diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h index 335a4afd47a..b36689b2a2e 100644 --- a/intern/cycles/kernel/bvh/qbvh_traversal.h +++ b/intern/cycles/kernel/bvh/qbvh_traversal.h @@ -188,7 +188,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, float4 cnodes; /* TODO(sergey): Investigate whether moving cnodes upwards * gives a speedup (will be different cache pattern but will - * avoid extra check here), + * avoid extra check here). */ #if BVH_FEATURE(BVH_HAIR) if(__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) { -- cgit v1.2.3