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

Side by Side 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, 5 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 unified diff | Download patch
« no previous file with comments | « ui/gl/gl_version_info.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_version_info.h" 5 #include "ui/gl/gl_version_info.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_split.h"
8 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 11
11 namespace { 12 namespace {
12 13
13 bool DesktopCoreCommonCheck( 14 bool DesktopCoreCommonCheck(
14 bool is_es, unsigned major_version, unsigned minor_version) { 15 bool is_es, unsigned major_version, unsigned minor_version) {
15 return (!is_es && 16 return (!is_es &&
16 ((major_version == 3 && minor_version >= 2) || 17 ((major_version == 3 && minor_version >= 2) ||
17 major_version > 3)); 18 major_version > 3));
18 } 19 }
19 20
20 } 21 }
21 22
22 namespace gl { 23 namespace gl {
23 24
24 GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str, 25 GLVersionInfo::GLVersionInfo(const char* version_str,
26 const char* renderer_str,
25 const char* extensions_str) 27 const char* extensions_str)
26 : GLVersionInfo(version_str, renderer_str) { 28 : GLVersionInfo() {
27 is_desktop_core_profile = 29 std::set<std::string> extensions;
28 DesktopCoreCommonCheck(is_es, major_version, minor_version) && 30 if (extensions_str) {
29 !strstr(extensions_str, "GL_ARB_compatibility"); 31 auto split = base::SplitString(extensions_str, " ", base::KEEP_WHITESPACE,
32 base::SPLIT_WANT_NONEMPTY);
33 extensions.insert(split.begin(), split.end());
34 }
35 Initialize(version_str, renderer_str, extensions);
30 } 36 }
31 37
32 GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str, 38 GLVersionInfo::GLVersionInfo(const char* version_str,
39 const char* renderer_str,
33 const std::set<std::string>& extensions) 40 const std::set<std::string>& extensions)
34 : GLVersionInfo(version_str, renderer_str) { 41 : GLVersionInfo() {
35 is_desktop_core_profile = 42 Initialize(version_str, renderer_str, extensions);
36 DesktopCoreCommonCheck(is_es, major_version, minor_version) &&
37 extensions.find("GL_ARB_compatibility") == extensions.end();
38 } 43 }
39 44
40 GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str) 45 GLVersionInfo::GLVersionInfo()
41 : is_es(false), 46 : is_es(false),
42 is_angle(false), 47 is_angle(false),
43 major_version(0), 48 major_version(0),
44 minor_version(0), 49 minor_version(0),
45 is_es2(false), 50 is_es2(false),
46 is_es3(false), 51 is_es3(false),
47 is_desktop_core_profile(false) { 52 is_desktop_core_profile(false),
53 is_es3_capable(false) {}
54
55 void GLVersionInfo::Initialize(const char* version_str,
56 const char* renderer_str,
57 const std::set<std::string>& extensions) {
48 if (version_str) { 58 if (version_str) {
49 ParseVersionString(version_str, &major_version, &minor_version, 59 ParseVersionString(version_str, &major_version, &minor_version,
50 &is_es, &is_es2, &is_es3); 60 &is_es, &is_es2, &is_es3);
51 } 61 }
52 if (renderer_str) { 62 if (renderer_str) {
53 is_angle = base::StartsWith(renderer_str, "ANGLE", 63 is_angle = base::StartsWith(renderer_str, "ANGLE",
54 base::CompareCase::SENSITIVE); 64 base::CompareCase::SENSITIVE);
55 } 65 }
66 is_desktop_core_profile =
67 DesktopCoreCommonCheck(is_es, major_version, minor_version) &&
68 extensions.find("GL_ARB_compatibility") == extensions.end();
69 is_es3_capable = IsES3Capable(extensions);
70 }
71
72 bool GLVersionInfo::IsES3Capable(
73 const std::set<std::string>& extensions) const {
74 auto has_extension = [&extensions](std::string extension) -> bool {
75 return extensions.find(extension) != extensions.end();
76 };
77
78 // Version ES3 capable without extensions needed.
79 if (IsAtLeastGLES(3, 0) || IsAtLeastGL(4, 2)) {
80 return true;
81 }
82
83 // Don't try supporting ES3 on ES2, or desktop before 3.2 because there are no
84 // extension that allow querying for GL_MAX_FRAGMENT_INPUT_COMPONENTS
85 if (is_es || !IsAtLeastGL(3, 2)) {
86 return false;
87 }
88
89 bool has_shader_packing = has_extension("GL_ARB_shading_bit_packing") ||
90 has_extension("GL_ARB_shader_bit_encoding");
91 bool has_transform_feedback =
92 IsAtLeastGL(4, 0) || has_extension("GL_ARB_transform_feedback2");
93 bool has_samplers =
94 IsAtLeastGL(3, 3) || has_extension("GL_ARB_sampler_object");
95 bool has_swizzle = IsAtLeastGL(3, 3) ||
96 has_extension("GL_ARB_texture_swizzle") ||
97 has_extension("GL_EXT_texture_swizzle");
98 bool has_attrib_location =
99 IsAtLeastGL(3, 3) || has_extension("GL_ARB_explicit_attrib_location");
100
101 // TODO(cwallez) check for texture related extensions. See crbug.com/623577
102
103 return has_shader_packing && has_transform_feedback && has_samplers &&
104 has_swizzle && has_attrib_location;
56 } 105 }
57 106
58 void GLVersionInfo::ParseVersionString(const char* version_str, 107 void GLVersionInfo::ParseVersionString(const char* version_str,
59 unsigned* major_version, 108 unsigned* major_version,
60 unsigned* minor_version, 109 unsigned* minor_version,
61 bool* is_es, 110 bool* is_es,
62 bool* is_es2, 111 bool* is_es2,
63 bool* is_es3) { 112 bool* is_es3) {
64 // Make sure the outputs are always initialized. 113 // Make sure the outputs are always initialized.
65 *major_version = 0; 114 *major_version = 0;
(...skipping 18 matching lines...) Expand all
84 } 133 }
85 } 134 }
86 if (*is_es && *major_version == 2) 135 if (*is_es && *major_version == 2)
87 *is_es2 = true; 136 *is_es2 = true;
88 if (*is_es && *major_version == 3) 137 if (*is_es && *major_version == 3)
89 *is_es3 = true; 138 *is_es3 = true;
90 DCHECK(major_version != 0); 139 DCHECK(major_version != 0);
91 } 140 }
92 141
93 } // namespace gl 142 } // namespace gl
OLDNEW
« 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