From b926a67909b6a2c4bbd8cf8bc4a4e82d4558fe74 Mon Sep 17 00:00:00 2001 From: gerrit Date: Thu, 15 May 2014 15:14:05 +0800 Subject: [PATCH] fixed: OSB loader check index property has useVBO set if the geometry uses useVAO (fixed nvidia linux driver crash) --- Source/System/FileIO/OSB/OSGOSBCommonElement.cpp | 4 ++ Source/System/FileIO/OSB/OSGOSBCommonElement.h | 1 + Source/System/FileIO/OSB/OSGOSBElementBase.h | 2 +- Source/System/FileIO/OSB/OSGOSBGeometryElement.cpp | 50 ++++++++++++++++++++++ Source/System/FileIO/OSB/OSGOSBGeometryElement.h | 2 + Source/System/FileIO/OSB/OSGOSBRootElement.cpp | 15 +++++++ Source/System/FileIO/OSB/OSGOSBRootElement.h | 1 + 7 files changed, 74 insertions(+), 1 deletion(-) diff --git a/Source/System/FileIO/OSB/OSGOSBCommonElement.cpp b/Source/System/FileIO/OSB/OSGOSBCommonElement.cpp index e3a062db7..2acf25a2f 100644 --- a/Source/System/FileIO/OSB/OSGOSBCommonElement.cpp +++ b/Source/System/FileIO/OSB/OSGOSBCommonElement.cpp @@ -88,6 +88,10 @@ OSBCommonElement::~OSBCommonElement(void) // nothing to do. } +void OSBCommonElement::postMap(void) +{ +} + /*-------------------------------------------------------------------------*/ /* Reading */ diff --git a/Source/System/FileIO/OSB/OSGOSBCommonElement.h b/Source/System/FileIO/OSB/OSGOSBCommonElement.h index 96848d4d1..6a7b57fbf 100644 --- a/Source/System/FileIO/OSB/OSGOSBCommonElement.h +++ b/Source/System/FileIO/OSB/OSGOSBCommonElement.h @@ -97,6 +97,7 @@ class OSG_FILEIO_DLLMAPPING OSBCommonElement : public OSBElementBase virtual void read (const std::string &typeName) = 0; virtual void postRead( void ) = 0; + virtual void postMap ( void ); /*! \} */ /*---------------------------------------------------------------------*/ diff --git a/Source/System/FileIO/OSB/OSGOSBElementBase.h b/Source/System/FileIO/OSB/OSGOSBElementBase.h index ae1131ff5..d49d793d3 100644 --- a/Source/System/FileIO/OSB/OSGOSBElementBase.h +++ b/Source/System/FileIO/OSB/OSGOSBElementBase.h @@ -162,7 +162,7 @@ class OSG_FILEIO_DLLMAPPING OSBElementBase virtual void read (const std::string &typeName) = 0; virtual void postRead( void ) = 0; - + virtual void postMap ( void ) = 0; /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Writing */ diff --git a/Source/System/FileIO/OSB/OSGOSBGeometryElement.cpp b/Source/System/FileIO/OSB/OSGOSBGeometryElement.cpp index 8e88b1fbc..c306520c0 100644 --- a/Source/System/FileIO/OSB/OSGOSBGeometryElement.cpp +++ b/Source/System/FileIO/OSB/OSGOSBGeometryElement.cpp @@ -45,6 +45,7 @@ #include "OSGTypedGeoIntegralProperty.h" #include "OSGTypedGeoVectorProperty.h" #include "OSGGeometry.h" +#include "OSGGeoPumpGroup.h" OSG_USING_NAMESPACE @@ -152,6 +153,8 @@ OSBGeometryElement::postRead(void) "Unknown version, trying to process as latest.\n")); } + postMapV200(); + // postRead v2.0 Geometry - nothing to do. } else if(_version >= OSGOSBHeaderVersion100) @@ -160,6 +163,26 @@ OSBGeometryElement::postRead(void) } } +void OSBGeometryElement::postMap(void) +{ + OSG_OSB_LOG(("OSBGeometryElement::postMap:\n")); + + if(_version >= OSGOSBHeaderVersion200) + { + if(_version > OSGOSBHeaderVersion200) + { + FINFO(("OSBGeometryElement::postMap: " + "Unknown version, trying to process as latest.\n")); + } + + postMapV200(); + } + else if(_version >= OSGOSBHeaderVersion100) + { + // postMap v1.0 Geometry - nothing to do. + } +} + /*-------------------------------------------------------------------------*/ /* Writing */ @@ -690,3 +713,30 @@ OSBGeometryElement::postReadV100(void) } } } + +void OSBGeometryElement::postMapV200(void) +{ + Geometry *geo = + dynamic_cast(getContainer()); + + if(geo == NULL) + return; + + if(geo->getUseVAO() == false) + return; + + GeoPumpGroup::PropertyCharacteristics prop = + GeoPumpGroup::characterizeGeometry(geo); + + if(((prop & (GeoPumpGroup::SingleIndexed)) == 0x0000)) + { + return; + } + + GeoProperty *pIndexProp = geo->getIndex(Geometry::PositionsIndex); + + if(pIndexProp == NULL) + return; + + pIndexProp->setUseVBO(true); +} diff --git a/Source/System/FileIO/OSB/OSGOSBGeometryElement.h b/Source/System/FileIO/OSB/OSGOSBGeometryElement.h index ba3324ce0..a413212d8 100644 --- a/Source/System/FileIO/OSB/OSGOSBGeometryElement.h +++ b/Source/System/FileIO/OSB/OSGOSBGeometryElement.h @@ -108,6 +108,7 @@ class OSG_FILEIO_DLLMAPPING OSBGeometryElement : public OSBCommonElement virtual void read (const std::string &typeName); virtual void postRead( void ); + virtual void postMap ( void ); /*! \} */ /*---------------------------------------------------------------------*/ @@ -131,6 +132,7 @@ class OSG_FILEIO_DLLMAPPING OSBGeometryElement : public OSBCommonElement void readV100 (void); void postReadV100(void); + void postMapV200 (void); /*! \} */ /*---------------------------------------------------------------------*/ diff --git a/Source/System/FileIO/OSB/OSGOSBRootElement.cpp b/Source/System/FileIO/OSB/OSGOSBRootElement.cpp index 4cb8eb5a2..3210d3b34 100644 --- a/Source/System/FileIO/OSB/OSGOSBRootElement.cpp +++ b/Source/System/FileIO/OSB/OSGOSBRootElement.cpp @@ -248,6 +248,21 @@ OSBRootElement::postRead(void) { mapPtrField(*ptrFieldIt); } + + this->postMap(); +} + +void OSBRootElement::postMap(void) +{ + OSG_OSB_LOG(("OSBRootElement::postMap\n")); + + ElementListConstIt elemIt = getElementList().begin(); + ElementListConstIt elemEnd = getElementList().end (); + + for(; elemIt != elemEnd; ++elemIt) + { + (*elemIt)->postMap(); + } } /*-------------------------------------------------------------------------*/ diff --git a/Source/System/FileIO/OSB/OSGOSBRootElement.h b/Source/System/FileIO/OSB/OSGOSBRootElement.h index cefdb7166..f10ec5e64 100644 --- a/Source/System/FileIO/OSB/OSGOSBRootElement.h +++ b/Source/System/FileIO/OSB/OSGOSBRootElement.h @@ -119,6 +119,7 @@ class OSG_FILEIO_DLLMAPPING OSBRootElement : public OSBCommonElement virtual void read (const std::string &typeName); virtual void postRead ( void ); + virtual void postMap ( void ); /*! \} */ /*---------------------------------------------------------------------*/ -- 2.11.4.GIT