Commit: 82ab2c167844627ccda4ac0e439f322fcea07173 Author: Peter Kim Date: Fri Sep 10 13:01:14 2021 +0900 Branches: master https://developer.blender.org/rB82ab2c167844627ccda4ac0e439f322fcea07173
XR: Re-enable SteamVR OpenGL backend for AMD gpus Addresses T76082. Since the DirectX backend does not work for AMD gpus (wglDXRegisterObjectNV() fails to register the shared OpenGL-DirectX render buffer, displaying a pink screen to the user), the original solution was to use SteamVR's OpenGL backend, which, as tested recently, seems to work without any issues on AMD hardware. However, the SteamVR OpenGL backend (on Windows) was disabled in fe492d922d6d since it resulted in crashes with NVIDIA gpus (and still crashes, as tested recently), so SteamVR would always use the AMD-incompatible DirectX backend (on Windows). This patch restores use of the SteamVR OpenGL backend for non-NVIDIA (AMD, etc.) gpus while maintaining the DirectX workaround for NVIDIA gpus. In this way, issues are still resolved on the NVIDIA side but AMD users can once again use the SteamVR runtime, which may be their only viable option of using Blender in VR. Reviewed By: Julian Eisel Differential Revision: https://developer.blender.org/D12409 =================================================================== M intern/ghost/GHOST_Types.h M intern/ghost/intern/GHOST_XrContext.cpp M intern/ghost/intern/GHOST_XrContext.h M source/blender/windowmanager/xr/intern/wm_xr.c =================================================================== diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index e46f712cb64..221fa140f70 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -652,6 +652,11 @@ typedef struct { enum { GHOST_kXrContextDebug = (1 << 0), GHOST_kXrContextDebugTime = (1 << 1), +# ifdef WIN32 + /* Needed to avoid issues with the SteamVR OpenGL graphics binding (use DirectX fallback + instead). */ + GHOST_kXrContextGpuNVIDIA = (1 << 2), +# endif }; typedef struct { diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index 98c87232882..f6b3caa3ec7 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -99,7 +99,7 @@ void GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info) storeInstanceProperties(); /* Multiple bindings may be enabled. Now that we know the runtime in use, settle for one. */ - m_gpu_binding_type = determineGraphicsBindingTypeToUse(graphics_binding_types); + m_gpu_binding_type = determineGraphicsBindingTypeToUse(graphics_binding_types, create_info); printInstanceInfo(); if (isDebugMode()) { @@ -473,14 +473,16 @@ std::vector<GHOST_TXrGraphicsBinding> GHOST_XrContext::determineGraphicsBindingT } GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToUse( - const std::vector<GHOST_TXrGraphicsBinding> &enabled_types) + const std::vector<GHOST_TXrGraphicsBinding> &enabled_types, + const GHOST_XrContextCreateInfo *create_info) { /* Return the first working type. */ for (GHOST_TXrGraphicsBinding type : enabled_types) { #ifdef WIN32 - /* The SteamVR OpenGL backend fails currently. Disable it and allow falling back to the DirectX - * one. */ - if ((m_runtime_id == OPENXR_RUNTIME_STEAMVR) && (type == GHOST_kXrGraphicsOpenGL)) { + /* The SteamVR OpenGL backend currently fails for NVIDIA gpus. Disable it and allow falling + * back to the DirectX one. */ + if ((m_runtime_id == OPENXR_RUNTIME_STEAMVR) && (type == GHOST_kXrGraphicsOpenGL) && + ((create_info->context_flag & GHOST_kXrContextGpuNVIDIA) != 0)) { continue; } #endif diff --git a/intern/ghost/intern/GHOST_XrContext.h b/intern/ghost/intern/GHOST_XrContext.h index 26fc374b957..479b50e1537 100644 --- a/intern/ghost/intern/GHOST_XrContext.h +++ b/intern/ghost/intern/GHOST_XrContext.h @@ -139,5 +139,6 @@ class GHOST_XrContext : public GHOST_IXrContext { std::vector<GHOST_TXrGraphicsBinding> determineGraphicsBindingTypesToEnable( const GHOST_XrContextCreateInfo *create_info); GHOST_TXrGraphicsBinding determineGraphicsBindingTypeToUse( - const std::vector<GHOST_TXrGraphicsBinding> &enabled_types); + const std::vector<GHOST_TXrGraphicsBinding> &enabled_types, + const GHOST_XrContextCreateInfo *create_info); }; diff --git a/source/blender/windowmanager/xr/intern/wm_xr.c b/source/blender/windowmanager/xr/intern/wm_xr.c index 297205d1e79..8891840cb75 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr.c +++ b/source/blender/windowmanager/xr/intern/wm_xr.c @@ -35,6 +35,8 @@ #include "GHOST_C-api.h" +#include "GPU_platform.h" + #include "WM_api.h" #include "wm_surface.h" @@ -91,6 +93,11 @@ bool wm_xr_init(wmWindowManager *wm) if (G.debug & G_DEBUG_XR_TIME) { create_info.context_flag |= GHOST_kXrContextDebugTime; } +#ifdef WIN32 + if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_WIN, GPU_DRIVER_ANY)) { + create_info.context_flag |= GHOST_kXrContextGpuNVIDIA; + } +#endif if (!(context = GHOST_XrContextCreate(&create_info))) { return false; _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
