Commit b827f490 by Geoff Lang Committed by Commit Bot

GL: Work around errors generated during query caps initialization.

Nexus5X drivers generate INVLAID_ENUM errors when querying GL_QUERY_COUNTER_BITS. Add device detection from renderer string. BUG=angleproject:3027 Change-Id: I367e20c79e1c4e53c26d94603d9a893604b51165 Reviewed-on: https://chromium-review.googlesource.com/c/1374274 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent c05c1416
...@@ -163,6 +163,10 @@ struct WorkaroundsGL ...@@ -163,6 +163,10 @@ struct WorkaroundsGL
// glReadPixels on unsized sRGB texture formats. http://crbug.com/550292 and // glReadPixels on unsized sRGB texture formats. http://crbug.com/550292 and
// http://crbug.com/565179 // http://crbug.com/565179
bool unsizedsRGBReadPixelsDoesntTransform = false; bool unsizedsRGBReadPixelsDoesntTransform = false;
// Older Qualcomm drivers generate errors when querying the number of bits in timer queries, ex:
// GetQueryivEXT(GL_TIME_ELAPSED, GL_QUERY_COUNTER_BITS). http://anglebug.com/3027
bool queryCounterBitsGeneratesErrors = false;
}; };
inline WorkaroundsGL::WorkaroundsGL() = default; inline WorkaroundsGL::WorkaroundsGL() = default;
......
...@@ -59,6 +59,27 @@ VendorID GetVendorID(const FunctionsGL *functions) ...@@ -59,6 +59,27 @@ VendorID GetVendorID(const FunctionsGL *functions)
} }
} }
uint32_t GetDeviceID(const FunctionsGL *functions)
{
std::string nativeRendererString(
reinterpret_cast<const char *>(functions->getString(GL_RENDERER)));
constexpr std::pair<const char *, uint32_t> kKnownDeviceIDs[] = {
{"Adreno (TM) 418", ANDROID_DEVICE_ID_NEXUS5X},
{"Adreno (TM) 530", ANDROID_DEVICE_ID_PIXEL1XL},
{"Adreno (TM) 540", ANDROID_DEVICE_ID_PIXEL2},
};
for (const auto &knownDeviceID : kKnownDeviceIDs)
{
if (nativeRendererString.find(knownDeviceID.first) != std::string::npos)
{
return knownDeviceID.second;
}
}
return 0;
}
namespace nativegl_gl namespace nativegl_gl
{ {
...@@ -1133,10 +1154,15 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -1133,10 +1154,15 @@ void GenerateCaps(const FunctionsGL *functions,
functions->hasGLESExtension("GL_EXT_disjoint_timer_query")) functions->hasGLESExtension("GL_EXT_disjoint_timer_query"))
{ {
extensions->disjointTimerQuery = true; extensions->disjointTimerQuery = true;
extensions->queryCounterBitsTimeElapsed =
QueryQueryValue(functions, GL_TIME_ELAPSED, GL_QUERY_COUNTER_BITS); // If we can't query the counter bits, leave them at 0.
extensions->queryCounterBitsTimestamp = if (!workarounds.queryCounterBitsGeneratesErrors)
QueryQueryValue(functions, GL_TIMESTAMP, GL_QUERY_COUNTER_BITS); {
extensions->queryCounterBitsTimeElapsed =
QueryQueryValue(functions, GL_TIME_ELAPSED, GL_QUERY_COUNTER_BITS);
extensions->queryCounterBitsTimestamp =
QueryQueryValue(functions, GL_TIMESTAMP, GL_QUERY_COUNTER_BITS);
}
} }
// the EXT_multisample_compatibility is written against ES3.1 but can apply // the EXT_multisample_compatibility is written against ES3.1 but can apply
...@@ -1333,6 +1359,7 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -1333,6 +1359,7 @@ void GenerateCaps(const FunctionsGL *functions,
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds) void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds)
{ {
VendorID vendor = GetVendorID(functions); VendorID vendor = GetVendorID(functions);
uint32_t device = GetDeviceID(functions);
workarounds->dontRemoveInvariantForFragmentInput = workarounds->dontRemoveInvariantForFragmentInput =
functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor); functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor);
...@@ -1409,6 +1436,8 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround ...@@ -1409,6 +1436,8 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
workarounds->disableBlendFuncExtended = IsAMD(vendor) || IsIntel(vendor); workarounds->disableBlendFuncExtended = IsAMD(vendor) || IsIntel(vendor);
workarounds->unsizedsRGBReadPixelsDoesntTransform = IsAndroid() && IsQualcomm(vendor); workarounds->unsizedsRGBReadPixelsDoesntTransform = IsAndroid() && IsQualcomm(vendor);
workarounds->queryCounterBitsGeneratesErrors = IsNexus5X(vendor, device);
} }
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds) void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment