Skip to content

Commit

Permalink
Attempt to resolve version parsing issue for Mesa driver
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Dec 12, 2023
1 parent 6274e9b commit e3ece4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
11 changes: 1 addition & 10 deletions src/osgEarth/Capabilities
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ namespace osgEarth
const std::string& getRenderer() const { return _renderer;}

//! the GL_VERSION string, which include the GL version, driver vendor, and driver version
const std::string& getVersion() const { return _version;}

//! GPU driver version extracted from GL_VERSION
const Version& getDriverVersion() const { return _driverVersion; }

//! GPU driver vendor extracted from GL_VERSION
const std::string& getDriverVendor() const { return _driverVendor; }
const std::string& getVersion() const { return _version; }

/** whether the GPU supports DEPTH_PACKED_STENCIL buffer */
bool supportsDepthPackedStencilBuffer() const { return _supportsDepthPackedStencilBuffer; }
Expand Down Expand Up @@ -139,9 +133,6 @@ namespace osgEarth
std::string _renderer;
std::string _version;

std::string _driverVendor;
Version _driverVersion;

bool _supportsS3TC;
bool _supportsPVRTC;
bool _supportsARBTC;
Expand Down
4 changes: 2 additions & 2 deletions src/osgEarth/Capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,16 @@ Capabilities::Capabilities() :
OE_INFO << LC << "GL_VERSION: " << _version << std::endl;
//OE_INFO << LC << "GLSL: " << getGLSLVersionInt() << std::endl;

#if 0
// assemble the driver version if possible.
std::vector<std::string> version_tokens;
Strings::StringTokenizer parse_glversion(_version, version_tokens, " ", "", false, true);
if (version_tokens.size() >= 2)
{
_driverVendor = version_tokens[1];
_driverVersion = parseVersion(version_tokens[2].c_str());
//OE_INFO << LC << "GL_VERSION vendor: " << _driverVendor << std::endl;
//OE_INFO << LC << "GL_VERSION driver: " << _driverVersion.major << "." << _driverVersion.minor << "." << _driverVersion.patch << std::endl;
}
#endif

// Detect core profile by investigating GL_CONTEXT_PROFILE_MASK
if ( GL2->glVersion < 3.2f )
Expand Down
16 changes: 10 additions & 6 deletions src/osgEarthDrivers/engine_rex/RexTerrainEngineNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,17 @@ RexTerrainEngineNode::onSetMap()
// There is an (apparent) bug in the mesa 23.1.4 driver that causes display artifacts
// when doing morphing; this code will attempt to detect that condition and disable
// the offending code until we can find a workaround.
auto vendor = Registry::capabilities().getDriverVendor();
auto version = Registry::capabilities().getDriverVersion();
if (vendor == "Mesa" && version.greaterThanOrEqualTo(23, 1, 4))
auto gl_version_str = Registry::capabilities().getVersion();
auto mesa_pos = gl_version_str.find("Mesa");
if (mesa_pos != std::string::npos)
{
OE_WARN << LC << "Detected Mesa >= 23.1.4 driver; disabling terrain & imagery morphing" << std::endl;
_morphingSupported = false;
getOrCreateStateSet()->setDefine("OE_MESA_23_WORKAROUND");
auto ver = gl_version_str.substr(mesa_pos + 5);
Version driver_version = parseVersion(ver.c_str());
if (driver_version.greaterThanOrEqualTo(23, 1, 4))
{
_morphingSupported = false;
getOrCreateStateSet()->setDefine("OE_MESA_23_WORKAROUND");
}
}

// morphing imagery LODs requires we bind parent textures to their own unit.
Expand Down

0 comments on commit e3ece4e

Please sign in to comment.