From 7269f71c477bf06efe0810c29bd3933cc23fff27 Mon Sep 17 00:00:00 2001 From: Paul MARTZ Date: Wed, 21 Oct 2009 21:45:55 +0000 Subject: [PATCH] Add CMake-controllable option to avoid doing a glBlitFramebuffer into depth to resolve multisampling. This works arouns a hang on OS X with NVIDIA GeForce 8800 and v1.5.49 drivers. --- src/osgUtil/CMakeLists.txt | 10 ++++++++++ src/osgUtil/RenderStage.cpp | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/osgUtil/CMakeLists.txt b/src/osgUtil/CMakeLists.txt index c79cbe5d2..603099991 100644 --- a/src/osgUtil/CMakeLists.txt +++ b/src/osgUtil/CMakeLists.txt @@ -6,6 +6,16 @@ ELSE (DYNAMIC_OPENSCENEGRAPH) ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC) ENDIF(DYNAMIC_OPENSCENEGRAPH) + +# +# MSFBO resolve blit to depth buffer control. +# +OPTION(OSG_MULTISAMPLE_FBO_RESOLVE_IGNORES_DEPTH "Set to ON to ignore depth when resolving multisampled FBO rendering. This is a workaround for a crash on OS X with NVIDIA driver 1.5.49." OFF) +IF(OSG_MULTISAMPLE_FBO_RESOLVE_IGNORES_DEPTH) + ADD_DEFINITIONS(-DOSG_MULTISAMPLE_FBO_RESOLVE_IGNORES_DEPTH) +ENDIF(OSG_MULTISAMPLE_FBO_RESOLVE_IGNORES_DEPTH) + + SET(LIB_NAME osgUtil) SET(HEADER_PATH ${OpenSceneGraph_SOURCE_DIR}/include/${LIB_NAME}) SET(LIB_PUBLIC_HEADERS diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index 54ea8aabd..737106fad 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -879,7 +879,14 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b switch (it->first) { case Camera::DEPTH_BUFFER: +#ifndef OSG_MULTISAMPLE_FBO_RESOLVE_IGNORES_DEPTH + // This #define is a workaround for an OS X NVIDIA driver bug + // confirmed on GeForce 8800 with driver v1.5.49. + // If the glBlitFramebuffer mask includes depth, the OS X desktop + // will hang. The #define is controlled from CMake and should be + // set to ON to enable the workaround and avoid blitting depth. blitMask |= GL_DEPTH_BUFFER_BIT; +#endif break; case Camera::STENCIL_BUFFER: blitMask |= GL_STENCIL_BUFFER_BIT;