Skip to content
Snippets Groups Projects

Fix compat profile intel linux

Merged Martin Schultz requested to merge fixCompatProfileIntelLinux into master
1 file
+ 31
5
Compare changes
  • Side-by-side
  • Inline
+ 31
5
@@ -516,12 +516,33 @@ bool verifySpecificContextFormat(QSurfaceFormat format, QSurfaceFormat* resultin
@@ -516,12 +516,33 @@ bool verifySpecificContextFormat(QSurfaceFormat format, QSurfaceFormat* resultin
// Human-readable name of current profile
// Human-readable name of current profile
auto curProfileString = profileToString(resultFormat.profile());
auto curProfileString = profileToString(resultFormat.profile());
// Check whether the actually applied OpenGL context profile matches the requested one
// and the current GL version is at least the requested one (but may be higher)
// Example: OpenGL Version 4.6 -> 46
 
auto reqVersionInt = format.version().first * 10 + format.version().second;
 
auto curVersionInt = curVersion.first * 10 + curVersion.second;
 
 
 
// Qt Docs say: Whenever "NoProfile" is returned, either the GL version is < 3.2 or (GL >= 3.2) it is actually a core profile
 
// Thus we set the following guidelines:
 
// 1. Whenever the actually received GL version is < than the requested one, the context is not the one requested
 
// 2. If the requested version is >= 3.2 and Compat, only Compat is allowed (as NoProfile is considered core)
 
// 3. If the requested version is >= 3.2 and Core or NoProfile is requested, Compat is not allowed
 
 
 
// For >= 3.2, treat Core and NoProfile equally
 
bool reqCoreOrNoProfile = format.profile() == QSurfaceFormat::NoProfile || format.profile() == QSurfaceFormat::CoreProfile;
 
bool curCoreOrNoProfile = resultFormat.profile() == QSurfaceFormat::NoProfile || resultFormat.profile() == QSurfaceFormat::CoreProfile;
 
 
if(curVersionInt < 32 && resultFormat.profile() == QSurfaceFormat::CoreProfile)
 
{
 
std::cerr << "Warning: Got an OpenGL core context with OpengGL version < 3.2 (" << curVersion.first << "." << curVersion.second << ")! This should not be possible." << std::endl;
 
return false;
 
}
 
 
// Check whether the conditions above are met.
// If not, print some error to the console
// If not, print some error to the console
if(curVersion.first < format.version().first ||
if(curVersionInt < reqVersionInt ||
((curVersion.first == format.version().first) && (curVersion.second < format.version().second)) ||
(reqVersionInt >= 32 && reqCoreOrNoProfile != curCoreOrNoProfile))
format.profile() != resultFormat.profile())
{
{
std::cout << "[OpenGL context] Requested: "
std::cout << "[OpenGL context] Requested: "
<< format.version().first << "." << format.version().second << " (" << reqProfileString << ")"
<< format.version().first << "." << format.version().second << " (" << reqProfileString << ")"
@@ -533,6 +554,10 @@ bool verifySpecificContextFormat(QSurfaceFormat format, QSurfaceFormat* resultin
@@ -533,6 +554,10 @@ bool verifySpecificContextFormat(QSurfaceFormat format, QSurfaceFormat* resultin
std::cout << "[OpenGL context] Successfully created OpenGL context with version " << curVersion.first << "."
std::cout << "[OpenGL context] Successfully created OpenGL context with version " << curVersion.first << "."
<< curVersion.second << " (" << curProfileString << ")." << std::endl;
<< curVersion.second << " (" << curProfileString << ")." << std::endl;
 
if(resultFormat.profile() == QSurfaceFormat::NoProfile || curVersionInt < 32)
 
{
 
std::cout << "[OpenGL context] Note that 'NoProfile' is fine for OpenGL version < 3.2 as core profile was introduced in 3.2" << std::endl;
 
}
return true;
return true;
}
}
@@ -596,6 +621,7 @@ QSurfaceFormat getContextFormat()
@@ -596,6 +621,7 @@ QSurfaceFormat getContextFormat()
{
{
std::cout << "[OpenGL context] Trying to create a 4.4 compat context..." << std::endl;
std::cout << "[OpenGL context] Trying to create a 4.4 compat context..." << std::endl;
success = verifySpecificContextFormat(createFormat(QSurfaceFormat::CompatibilityProfile, 4, 4, reqSamples, reqStereo, debugContext), &resultFormat);
success = verifySpecificContextFormat(createFormat(QSurfaceFormat::CompatibilityProfile, 4, 4, reqSamples, reqStereo, debugContext), &resultFormat);
 
if(!success)
if(!success)
{
{
std::cout << "[OpenGL context] Trying to create a 3.2 core context..." << std::endl;
std::cout << "[OpenGL context] Trying to create a 3.2 core context..." << std::endl;
Loading