Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Unified Diff: ui/gl/gl_version_info.cc

Issue 2098913002: GLVersionInfo: alse detect es3 support with extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix references to IsES3Capable Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_version_info.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_version_info.cc
diff --git a/ui/gl/gl_version_info.cc b/ui/gl/gl_version_info.cc
index 07bc6bb76809fb35890efa17cbd53f7d2bd32a3e..f91321aa160212ccec4a01f02ddd211611d9ae0d 100644
--- a/ui/gl/gl_version_info.cc
+++ b/ui/gl/gl_version_info.cc
@@ -5,6 +5,7 @@
#include "ui/gl/gl_version_info.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
@@ -21,30 +22,39 @@ bool DesktopCoreCommonCheck(
namespace gl {
-GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str,
+GLVersionInfo::GLVersionInfo(const char* version_str,
+ const char* renderer_str,
const char* extensions_str)
- : GLVersionInfo(version_str, renderer_str) {
- is_desktop_core_profile =
- DesktopCoreCommonCheck(is_es, major_version, minor_version) &&
- !strstr(extensions_str, "GL_ARB_compatibility");
+ : GLVersionInfo() {
+ std::set<std::string> extensions;
+ if (extensions_str) {
+ auto split = base::SplitString(extensions_str, " ", base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_NONEMPTY);
+ extensions.insert(split.begin(), split.end());
+ }
+ Initialize(version_str, renderer_str, extensions);
}
-GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str,
+GLVersionInfo::GLVersionInfo(const char* version_str,
+ const char* renderer_str,
const std::set<std::string>& extensions)
- : GLVersionInfo(version_str, renderer_str) {
- is_desktop_core_profile =
- DesktopCoreCommonCheck(is_es, major_version, minor_version) &&
- extensions.find("GL_ARB_compatibility") == extensions.end();
+ : GLVersionInfo() {
+ Initialize(version_str, renderer_str, extensions);
}
-GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str)
+GLVersionInfo::GLVersionInfo()
: is_es(false),
is_angle(false),
major_version(0),
minor_version(0),
is_es2(false),
is_es3(false),
- is_desktop_core_profile(false) {
+ is_desktop_core_profile(false),
+ is_es3_capable(false) {}
+
+void GLVersionInfo::Initialize(const char* version_str,
+ const char* renderer_str,
+ const std::set<std::string>& extensions) {
if (version_str) {
ParseVersionString(version_str, &major_version, &minor_version,
&is_es, &is_es2, &is_es3);
@@ -53,6 +63,45 @@ GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str)
is_angle = base::StartsWith(renderer_str, "ANGLE",
base::CompareCase::SENSITIVE);
}
+ is_desktop_core_profile =
+ DesktopCoreCommonCheck(is_es, major_version, minor_version) &&
+ extensions.find("GL_ARB_compatibility") == extensions.end();
+ is_es3_capable = IsES3Capable(extensions);
+}
+
+bool GLVersionInfo::IsES3Capable(
+ const std::set<std::string>& extensions) const {
+ auto has_extension = [&extensions](std::string extension) -> bool {
+ return extensions.find(extension) != extensions.end();
+ };
+
+ // Version ES3 capable without extensions needed.
+ if (IsAtLeastGLES(3, 0) || IsAtLeastGL(4, 2)) {
+ return true;
+ }
+
+ // Don't try supporting ES3 on ES2, or desktop before 3.2 because there are no
+ // extension that allow querying for GL_MAX_FRAGMENT_INPUT_COMPONENTS
+ if (is_es || !IsAtLeastGL(3, 2)) {
+ return false;
+ }
+
+ bool has_shader_packing = has_extension("GL_ARB_shading_bit_packing") ||
+ has_extension("GL_ARB_shader_bit_encoding");
+ bool has_transform_feedback =
+ IsAtLeastGL(4, 0) || has_extension("GL_ARB_transform_feedback2");
+ bool has_samplers =
+ IsAtLeastGL(3, 3) || has_extension("GL_ARB_sampler_object");
+ bool has_swizzle = IsAtLeastGL(3, 3) ||
+ has_extension("GL_ARB_texture_swizzle") ||
+ has_extension("GL_EXT_texture_swizzle");
+ bool has_attrib_location =
+ IsAtLeastGL(3, 3) || has_extension("GL_ARB_explicit_attrib_location");
+
+ // TODO(cwallez) check for texture related extensions. See crbug.com/623577
+
+ return has_shader_packing && has_transform_feedback && has_samplers &&
+ has_swizzle && has_attrib_location;
}
void GLVersionInfo::ParseVersionString(const char* version_str,
« no previous file with comments | « ui/gl/gl_version_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698