Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/engine/renderer/DetectGLVendors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ std::string GetGLHardwareVendorName( glHardwareVendor_t hardwareVendor )
"Intel",
"Nvidia",
"Moore Threads",
"Imagination",
"OutOfRange",
};

Expand All @@ -73,6 +74,8 @@ std::string GetGLDriverVendorName( glDriverVendor_t driverVendor )
"Mesa",
"Nvidia",
"Moore Threads",
"Imagination",
"GL4ES",
"OutOfRange",
};

Expand All @@ -89,6 +92,19 @@ std::string GetGLDriverVendorName( glDriverVendor_t driverVendor )
return driverVendorNames[ index ];
}

static std::string StripPrefix( const std::string &prefix, const std::string &string )
{
if ( Str::IsPrefix( prefix, string ) )
{
size_t prefixLen = prefix.length();
size_t stringLen = string.length();
size_t subLen = stringLen - prefixLen;
return string.substr( prefixLen, subLen );
}

return string;
}

void DetectGLVendors(
const std::string& vendorString,
const std::string& versionString,
Expand Down Expand Up @@ -125,6 +141,8 @@ void DetectGLVendors(
{ "NVIDIA Corporation", { glDriverVendor_t::NVIDIA, glHardwareVendor_t::NVIDIA } },
// Moore Threads drivers on Linux and Windows.
{ "Moore Threads", { glDriverVendor_t::MTHREADS, glHardwareVendor_t::MTHREADS } },
// Proprietary Imagination driver for PowerVR.
{ "Imagination Technologies", { glDriverVendor_t::IMAGINATION, glHardwareVendor_t::IMAGINATION } },
};

auto it = vendorDriverHardware.find( vendorString );
Expand Down Expand Up @@ -309,4 +327,39 @@ void DetectGLVendors(
hardwareVendor = glHardwareVendor_t::INTEL;
return;
}

// Newer GL4ES strings disclosing the underlying technology.
if ( Str::IsPrefix( "GL4ES wrapping ", vendorString ) )
{
std::string subVendorString = StripPrefix( "GL4ES wrapping ", vendorString );
std::string subRendererString = StripPrefix( "GL4ES using ", rendererString );
DetectGLVendors( subVendorString, versionString, subRendererString, hardwareVendor, driverVendor );
driverVendor = glDriverVendor_t::GL4ES;
}

/* Older GL4ES string not disclosing the underlying technology,
also had “ptitSeb” as vendorString. */
if ( rendererString == "GL4ES wrapper" )
{
driverVendor = glDriverVendor_t::GL4ES;
// Older GL4ES doesn't disclose the underlying hardware.
if ( hardwareVendor == glHardwareVendor_t::UNKNOWN )
{
hardwareVendor = glHardwareVendor_t::TRANSLATION;
}
return;
}

/* GL4ES always use such kind of version string:
> 2.1 gl4es wrapper 1.1.7
And this is unlikely to change. */
if ( versionString.find( "gl4es wrapper" ) != std::string::npos )
{
driverVendor = glDriverVendor_t::GL4ES;
if ( hardwareVendor == glHardwareVendor_t::UNKNOWN )
{
hardwareVendor = glHardwareVendor_t::TRANSLATION;
}
return;
}
}
3 changes: 3 additions & 0 deletions src/engine/renderer/DetectGLVendors.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum class glHardwareVendor_t
INTEL,
NVIDIA,
MTHREADS,
IMAGINATION,
NUM_HARDWARE_VENDORS,
};

Expand All @@ -69,6 +70,8 @@ enum class glDriverVendor_t
MESA,
NVIDIA,
MTHREADS,
IMAGINATION,
GL4ES,
NUM_DRIVER_VENDORS,
};

Expand Down
4 changes: 4 additions & 0 deletions src/engine/renderer/GLUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ struct GLConfig
bool gpuShader4Available;
bool gpuShader5Available;
bool textureGatherAvailable;
bool texture3DAvailable;
bool mat3x2Available;
bool assumeSmoothstep;
bool incrementalShaderCompilation;
int maxDrawBuffers;

float maxTextureAnisotropy;
Expand Down
Loading
Loading