bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 9 | #include "GrGLUtil.h" |
commit-bot@chromium.org | 215a682 | 2013-09-05 18:28:42 +0000 | [diff] [blame] | 10 | #include "SkMatrix.h" |
bungeman@google.com | fab44db | 2013-10-11 18:50:45 +0000 | [diff] [blame] | 11 | #include <stdio.h> |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 12 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 13 | void GrGLClearErr(const GrGLInterface* gl) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 14 | while (GR_GL_NO_ERROR != gl->fFunctions.fGetError()) {} |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 15 | } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 16 | |
bsalomon@google.com | 845eafd | 2012-06-18 12:27:29 +0000 | [diff] [blame] | 17 | namespace { |
| 18 | const char *get_error_string(uint32_t err) { |
| 19 | switch (err) { |
| 20 | case GR_GL_NO_ERROR: |
| 21 | return ""; |
| 22 | case GR_GL_INVALID_ENUM: |
| 23 | return "Invalid Enum"; |
| 24 | case GR_GL_INVALID_VALUE: |
| 25 | return "Invalid Value"; |
| 26 | case GR_GL_INVALID_OPERATION: |
| 27 | return "Invalid Operation"; |
| 28 | case GR_GL_OUT_OF_MEMORY: |
| 29 | return "Out of Memory"; |
| 30 | case GR_GL_CONTEXT_LOST: |
| 31 | return "Context Lost"; |
| 32 | } |
| 33 | return "Unknown"; |
| 34 | } |
| 35 | } |
| 36 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 37 | void GrGLCheckErr(const GrGLInterface* gl, |
| 38 | const char* location, |
| 39 | const char* call) { |
| 40 | uint32_t err = GR_GL_GET_ERROR(gl); |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 41 | if (GR_GL_NO_ERROR != err) { |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 42 | SkDebugf("---- glGetError 0x%x(%s)", err, get_error_string(err)); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 43 | if (location) { |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 44 | SkDebugf(" at\n\t%s", location); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 45 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 46 | if (call) { |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 47 | SkDebugf("\n\t\t%s", call); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 48 | } |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 49 | SkDebugf("\n"); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
| 53 | /////////////////////////////////////////////////////////////////////////////// |
| 54 | |
bsalomon@google.com | d5d1049 | 2011-04-28 21:16:31 +0000 | [diff] [blame] | 55 | #if GR_GL_LOG_CALLS |
| 56 | bool gLogCallsGL = !!(GR_GL_LOG_CALLS_START); |
| 57 | #endif |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 58 | |
bsalomon@google.com | d5d1049 | 2011-04-28 21:16:31 +0000 | [diff] [blame] | 59 | #if GR_GL_CHECK_ERROR |
| 60 | bool gCheckErrorGL = !!(GR_GL_CHECK_ERROR_START); |
| 61 | #endif |
| 62 | |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 63 | /////////////////////////////////////////////////////////////////////////////// |
| 64 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 65 | GrGLStandard GrGLGetStandardInUseFromString(const char* versionString) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 66 | if (nullptr == versionString) { |
| 67 | SkDebugf("nullptr GL version string."); |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 68 | return kNone_GrGLStandard; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | int major, minor; |
| 72 | |
| 73 | // check for desktop |
| 74 | int n = sscanf(versionString, "%d.%d", &major, &minor); |
| 75 | if (2 == n) { |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 76 | return kGL_GrGLStandard; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | // check for ES 1 |
| 80 | char profile[2]; |
bsalomon@google.com | 960d114 | 2013-05-29 13:11:54 +0000 | [diff] [blame] | 81 | n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, &major, &minor); |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 82 | if (4 == n) { |
| 83 | // we no longer support ES1. |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 84 | return kNone_GrGLStandard; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | // check for ES2 |
| 88 | n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor); |
| 89 | if (2 == n) { |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 90 | return kGLES_GrGLStandard; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 91 | } |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 92 | return kNone_GrGLStandard; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 93 | } |
| 94 | |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 95 | void GrGLGetDriverInfo(GrGLStandard standard, |
| 96 | GrGLVendor vendor, |
| 97 | const char* rendererString, |
| 98 | const char* versionString, |
| 99 | GrGLDriver* outDriver, |
| 100 | GrGLDriverVersion* outVersion) { |
| 101 | int major, minor, rev, driverMajor, driverMinor; |
derekf | a6ca5a0 | 2014-11-03 13:36:40 -0800 | [diff] [blame] | 102 | |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 103 | *outDriver = kUnknown_GrGLDriver; |
| 104 | *outVersion = GR_GL_DRIVER_UNKNOWN_VER; |
bsalomon | 6383ac0 | 2016-03-23 14:55:21 -0700 | [diff] [blame] | 105 | // These null checks are for test GL contexts that return nullptr in their |
| 106 | // glGetString implementation. |
| 107 | if (!rendererString) { |
| 108 | rendererString = ""; |
| 109 | } |
| 110 | if (!versionString) { |
| 111 | versionString = ""; |
| 112 | } |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 113 | |
| 114 | if (0 == strcmp(rendererString, "Chromium")) { |
| 115 | *outDriver = kChromium_GrGLDriver; |
| 116 | return; |
| 117 | } |
derekf | a6ca5a0 | 2014-11-03 13:36:40 -0800 | [diff] [blame] | 118 | |
| 119 | if (standard == kGL_GrGLStandard) { |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 120 | if (kNVIDIA_GrGLVendor == vendor) { |
| 121 | *outDriver = kNVIDIA_GrGLDriver; |
| 122 | int n = sscanf(versionString, "%d.%d.%d NVIDIA %d.%d", |
| 123 | &major, &minor, &rev, &driverMajor, &driverMinor); |
| 124 | // Some older NVIDIA drivers don't report the driver version. |
| 125 | if (5 == n) { |
| 126 | *outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor); |
| 127 | } |
| 128 | return; |
| 129 | } |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 130 | int n = sscanf(versionString, "%d.%d Mesa %d.%d", |
| 131 | &major, &minor, &driverMajor, &driverMinor); |
| 132 | if (4 == n) { |
| 133 | *outDriver = kMesa_GrGLDriver; |
| 134 | *outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor); |
| 135 | return; |
| 136 | } |
derekf | a6ca5a0 | 2014-11-03 13:36:40 -0800 | [diff] [blame] | 137 | } |
| 138 | else { |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 139 | if (kNVIDIA_GrGLVendor == vendor) { |
| 140 | *outDriver = kNVIDIA_GrGLDriver; |
| 141 | int n = sscanf(versionString, "OpenGL ES %d.%d NVIDIA %d.%d", |
| 142 | &major, &minor, &driverMajor, &driverMinor); |
| 143 | // Some older NVIDIA drivers don't report the driver version. |
| 144 | if (4 == n) { |
| 145 | *outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor); |
| 146 | } |
| 147 | return; |
| 148 | } |
commit-bot@chromium.org | 459104c | 2013-06-14 14:42:56 +0000 | [diff] [blame] | 149 | |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 150 | int n = sscanf(versionString, "OpenGL ES %d.%d Mesa %d.%d", |
| 151 | &major, &minor, &driverMajor, &driverMinor); |
| 152 | if (4 == n) { |
| 153 | *outDriver = kMesa_GrGLDriver; |
| 154 | *outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor); |
| 155 | return; |
| 156 | } |
bsalomon | 88c7b98 | 2015-07-31 11:20:16 -0700 | [diff] [blame] | 157 | if (0 == strncmp("ANGLE", rendererString, 5)) { |
| 158 | *outDriver = kANGLE_GrGLDriver; |
| 159 | n = sscanf(versionString, "OpenGL ES %d.%d (ANGLE %d.%d", &major, &minor, &driverMajor, |
| 160 | &driverMinor); |
| 161 | if (4 == n) { |
| 162 | *outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor); |
| 163 | } |
| 164 | return; |
| 165 | } |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 166 | } |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 167 | |
| 168 | if (kIntel_GrGLVendor == vendor) { |
| 169 | // We presume we're on the Intel driver since it hasn't identified itself as Mesa. |
| 170 | *outDriver = kIntel_GrGLDriver; |
| 171 | } |
commit-bot@chromium.org | c9424b8 | 2013-10-30 20:03:16 +0000 | [diff] [blame] | 172 | } |
| 173 | |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 174 | GrGLVersion GrGLGetVersionFromString(const char* versionString) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 175 | if (nullptr == versionString) { |
| 176 | SkDebugf("nullptr GL version string."); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 177 | return GR_GL_INVALID_VER; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | int major, minor; |
| 181 | |
bsalomon@google.com | 960d114 | 2013-05-29 13:11:54 +0000 | [diff] [blame] | 182 | // check for mesa |
| 183 | int mesaMajor, mesaMinor; |
| 184 | int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor, &mesaMajor, &mesaMinor); |
| 185 | if (4 == n) { |
joshualitt | 4682170 | 2014-07-30 11:49:12 -0700 | [diff] [blame] | 186 | return GR_GL_VER(major, minor); |
bsalomon@google.com | 960d114 | 2013-05-29 13:11:54 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | n = sscanf(versionString, "%d.%d", &major, &minor); |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 190 | if (2 == n) { |
| 191 | return GR_GL_VER(major, minor); |
| 192 | } |
| 193 | |
| 194 | char profile[2]; |
| 195 | n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, |
| 196 | &major, &minor); |
| 197 | if (4 == n) { |
| 198 | return GR_GL_VER(major, minor); |
| 199 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 200 | |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 201 | n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor); |
| 202 | if (2 == n) { |
| 203 | return GR_GL_VER(major, minor); |
| 204 | } |
| 205 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 206 | return GR_GL_INVALID_VER; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 210 | if (nullptr == versionString) { |
| 211 | SkDebugf("nullptr GLSL version string."); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 212 | return GR_GLSL_INVALID_VER; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | int major, minor; |
| 216 | |
| 217 | int n = sscanf(versionString, "%d.%d", &major, &minor); |
| 218 | if (2 == n) { |
| 219 | return GR_GLSL_VER(major, minor); |
| 220 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 221 | |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 222 | n = sscanf(versionString, "OpenGL ES GLSL ES %d.%d", &major, &minor); |
| 223 | if (2 == n) { |
| 224 | return GR_GLSL_VER(major, minor); |
| 225 | } |
| 226 | |
| 227 | #ifdef SK_BUILD_FOR_ANDROID |
| 228 | // android hack until the gpu vender updates their drivers |
| 229 | n = sscanf(versionString, "OpenGL ES GLSL %d.%d", &major, &minor); |
| 230 | if (2 == n) { |
| 231 | return GR_GLSL_VER(major, minor); |
| 232 | } |
| 233 | #endif |
| 234 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 235 | return GR_GLSL_INVALID_VER; |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 236 | } |
| 237 | |
bsalomon@google.com | 0b1e481 | 2012-10-23 13:52:43 +0000 | [diff] [blame] | 238 | GrGLVendor GrGLGetVendorFromString(const char* vendorString) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 239 | if (vendorString) { |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 240 | if (0 == strcmp(vendorString, "ARM")) { |
| 241 | return kARM_GrGLVendor; |
| 242 | } |
bsalomon@google.com | 3012ded | 2013-02-22 16:44:04 +0000 | [diff] [blame] | 243 | if (0 == strcmp(vendorString, "Imagination Technologies")) { |
| 244 | return kImagination_GrGLVendor; |
| 245 | } |
commit-bot@chromium.org | 54318d3 | 2014-02-14 17:27:04 +0000 | [diff] [blame] | 246 | if (0 == strncmp(vendorString, "Intel ", 6) || 0 == strcmp(vendorString, "Intel")) { |
bsalomon@google.com | 3012ded | 2013-02-22 16:44:04 +0000 | [diff] [blame] | 247 | return kIntel_GrGLVendor; |
| 248 | } |
commit-bot@chromium.org | 7a434a2 | 2013-08-21 14:01:56 +0000 | [diff] [blame] | 249 | if (0 == strcmp(vendorString, "Qualcomm")) { |
| 250 | return kQualcomm_GrGLVendor; |
| 251 | } |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 252 | if (0 == strcmp(vendorString, "NVIDIA Corporation")) { |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 253 | return kNVIDIA_GrGLVendor; |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 254 | } |
brianosman | 131ff13 | 2016-06-07 14:22:44 -0700 | [diff] [blame] | 255 | if (0 == strcmp(vendorString, "ATI Technologies Inc.")) { |
| 256 | return kATI_GrGLVendor; |
| 257 | } |
bsalomon@google.com | 0b1e481 | 2012-10-23 13:52:43 +0000 | [diff] [blame] | 258 | } |
bsalomon@google.com | 0b1e481 | 2012-10-23 13:52:43 +0000 | [diff] [blame] | 259 | return kOther_GrGLVendor; |
| 260 | } |
| 261 | |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 262 | GrGLRenderer GrGLGetRendererFromString(const char* rendererString) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 263 | if (rendererString) { |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 264 | if (0 == strcmp(rendererString, "NVIDIA Tegra 3")) { |
| 265 | return kTegra3_GrGLRenderer; |
commit-bot@chromium.org | 6dee875 | 2014-02-07 22:39:01 +0000 | [diff] [blame] | 266 | } else if (0 == strcmp(rendererString, "NVIDIA Tegra")) { |
| 267 | return kTegra2_GrGLRenderer; |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 268 | } |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 269 | int lastDigit; |
| 270 | int n = sscanf(rendererString, "PowerVR SGX 54%d", &lastDigit); |
| 271 | if (1 == n && lastDigit >= 0 && lastDigit <= 9) { |
| 272 | return kPowerVR54x_GrGLRenderer; |
| 273 | } |
jvanverth | f10ecb7 | 2015-12-10 09:06:24 -0800 | [diff] [blame] | 274 | // certain iOS devices also use PowerVR54x GPUs |
| 275 | static const char kAppleA4Str[] = "Apple A4"; |
| 276 | static const char kAppleA5Str[] = "Apple A5"; |
| 277 | static const char kAppleA6Str[] = "Apple A6"; |
| 278 | if (0 == strncmp(rendererString, kAppleA4Str, |
| 279 | SK_ARRAY_COUNT(kAppleA4Str)-1) || |
| 280 | 0 == strncmp(rendererString, kAppleA5Str, |
| 281 | SK_ARRAY_COUNT(kAppleA5Str)-1) || |
| 282 | 0 == strncmp(rendererString, kAppleA6Str, |
| 283 | SK_ARRAY_COUNT(kAppleA6Str)-1)) { |
| 284 | return kPowerVR54x_GrGLRenderer; |
| 285 | } |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 286 | static const char kPowerVRRogueStr[] = "PowerVR Rogue"; |
jvanverth | f10ecb7 | 2015-12-10 09:06:24 -0800 | [diff] [blame] | 287 | static const char kAppleA7Str[] = "Apple A7"; |
| 288 | static const char kAppleA8Str[] = "Apple A8"; |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 289 | if (0 == strncmp(rendererString, kPowerVRRogueStr, |
jvanverth | f10ecb7 | 2015-12-10 09:06:24 -0800 | [diff] [blame] | 290 | SK_ARRAY_COUNT(kPowerVRRogueStr)-1) || |
| 291 | 0 == strncmp(rendererString, kAppleA7Str, |
| 292 | SK_ARRAY_COUNT(kAppleA7Str)-1) || |
| 293 | 0 == strncmp(rendererString, kAppleA8Str, |
| 294 | SK_ARRAY_COUNT(kAppleA8Str)-1)) { |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 295 | return kPowerVRRogue_GrGLRenderer; |
| 296 | } |
bsalomon | a8fcea0 | 2015-02-13 09:00:39 -0800 | [diff] [blame] | 297 | int adrenoNumber; |
| 298 | n = sscanf(rendererString, "Adreno (TM) %d", &adrenoNumber); |
| 299 | if (1 == n) { |
| 300 | if (adrenoNumber >= 300) { |
| 301 | if (adrenoNumber < 400) { |
| 302 | return kAdreno3xx_GrGLRenderer; |
| 303 | } |
| 304 | if (adrenoNumber < 500) { |
| 305 | return kAdreno4xx_GrGLRenderer; |
| 306 | } |
egdaniel | 7517e45 | 2016-09-20 13:00:26 -0700 | [diff] [blame] | 307 | if (adrenoNumber < 600) { |
| 308 | return kAdreno5xx_GrGLRenderer; |
| 309 | } |
bsalomon | a8fcea0 | 2015-02-13 09:00:39 -0800 | [diff] [blame] | 310 | } |
| 311 | } |
Brian Salomon | 0ee6f95 | 2017-01-19 15:52:24 -0500 | [diff] [blame] | 312 | if (0 == strcmp("Mesa Offscreen", rendererString)) { |
bsalomon | 4017007 | 2016-05-05 14:40:03 -0700 | [diff] [blame] | 313 | return kOSMesa_GrGLRenderer; |
| 314 | } |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 315 | } |
| 316 | return kOther_GrGLRenderer; |
| 317 | } |
| 318 | |
bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 319 | GrGLVersion GrGLGetVersion(const GrGLInterface* gl) { |
| 320 | const GrGLubyte* v; |
| 321 | GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION)); |
| 322 | return GrGLGetVersionFromString((const char*) v); |
| 323 | } |
| 324 | |
| 325 | GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface* gl) { |
| 326 | const GrGLubyte* v; |
| 327 | GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); |
| 328 | return GrGLGetGLSLVersionFromString((const char*) v); |
| 329 | } |
bsalomon@google.com | 0b1e481 | 2012-10-23 13:52:43 +0000 | [diff] [blame] | 330 | |
| 331 | GrGLVendor GrGLGetVendor(const GrGLInterface* gl) { |
| 332 | const GrGLubyte* v; |
| 333 | GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR)); |
| 334 | return GrGLGetVendorFromString((const char*) v); |
| 335 | } |
commit-bot@chromium.org | 215a682 | 2013-09-05 18:28:42 +0000 | [diff] [blame] | 336 | |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 337 | GrGLRenderer GrGLGetRenderer(const GrGLInterface* gl) { |
| 338 | const GrGLubyte* v; |
| 339 | GR_GL_CALL_RET(gl, v, GetString(GR_GL_RENDERER)); |
| 340 | return GrGLGetRendererFromString((const char*) v); |
| 341 | } |
| 342 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 343 | GrGLenum GrToGLStencilFunc(GrStencilTest test) { |
| 344 | static const GrGLenum gTable[kGrStencilTestCount] = { |
| 345 | GR_GL_ALWAYS, // kAlways |
| 346 | GR_GL_NEVER, // kNever |
| 347 | GR_GL_GREATER, // kGreater |
| 348 | GR_GL_GEQUAL, // kGEqual |
| 349 | GR_GL_LESS, // kLess |
| 350 | GR_GL_LEQUAL, // kLEqual |
| 351 | GR_GL_EQUAL, // kEqual |
| 352 | GR_GL_NOTEQUAL, // kNotEqual |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 353 | }; |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 354 | GR_STATIC_ASSERT(0 == (int)GrStencilTest::kAlways); |
| 355 | GR_STATIC_ASSERT(1 == (int)GrStencilTest::kNever); |
| 356 | GR_STATIC_ASSERT(2 == (int)GrStencilTest::kGreater); |
| 357 | GR_STATIC_ASSERT(3 == (int)GrStencilTest::kGEqual); |
| 358 | GR_STATIC_ASSERT(4 == (int)GrStencilTest::kLess); |
| 359 | GR_STATIC_ASSERT(5 == (int)GrStencilTest::kLEqual); |
| 360 | GR_STATIC_ASSERT(6 == (int)GrStencilTest::kEqual); |
| 361 | GR_STATIC_ASSERT(7 == (int)GrStencilTest::kNotEqual); |
| 362 | SkASSERT(test < (GrStencilTest)kGrStencilTestCount); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 363 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 364 | return gTable[(int)test]; |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 365 | } |