| 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | package mainscip-go gomod go.skia.org/skia . `go.skia.org/skia/tools/ganesh/gl/interface`/ |
| 6 | |
| 7 | const ASSEMBLE_INTERFACE_GL_ESscip-go gomod go.skia.org/skia . `go.skia.org/skia/tools/ganesh/gl/interface`/ASSEMBLE_INTERFACE_GL_ES. = `/* |
| 8 | * Copyright 2019 Google LLC |
| 9 | * |
| 10 | * Use of this source code is governed by a BSD-style license that can be |
| 11 | * found in the LICENSE file. |
| 12 | * |
| 13 | * THIS FILE IS AUTOGENERATED |
| 14 | * Make edits to tools/ganesh/gl/interface/templates.go or they will |
| 15 | * be overwritten. |
| 16 | */ |
| 17 | |
| 18 | #include "include/core/SkRefCnt.h" |
| 19 | #include "include/gpu/ganesh/gl/GrGLAssembleHelpers.h" |
| 20 | #include "include/gpu/ganesh/gl/GrGLAssembleInterface.h" |
| 21 | #include "include/gpu/ganesh/gl/GrGLExtensions.h" |
| 22 | #include "include/gpu/ganesh/gl/GrGLFunctions.h" |
| 23 | #include "include/gpu/ganesh/gl/GrGLInterface.h" |
| 24 | #include "include/gpu/ganesh/gl/GrGLTypes.h" |
| 25 | #include "src/gpu/ganesh/gl/GrGLDefines.h" |
| 26 | #include "src/gpu/ganesh/gl/GrGLUtil.h" |
| 27 | |
| 28 | #define GET_PROC(F) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F) |
| 29 | #define GET_PROC_SUFFIX(F, S) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F #S) |
| 30 | #define GET_PROC_LOCAL(F) GrGL##F##Fn* F = (GrGL##F##Fn*)get(ctx, "gl" #F) |
| 31 | |
| 32 | #if SK_DISABLE_GL_ES_INTERFACE |
| 33 | sk_sp<const GrGLInterface> GrGLMakeAssembledGLESInterface(void *ctx, GrGLGetProc get) { |
| 34 | return nullptr; |
| 35 | } |
| 36 | #else |
| 37 | sk_sp<const GrGLInterface> GrGLMakeAssembledGLESInterface(void *ctx, GrGLGetProc get) { |
| 38 | GET_PROC_LOCAL(GetString); |
| 39 | if (nullptr == GetString) { |
| 40 | return nullptr; |
| 41 | } |
| 42 | |
| 43 | const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); |
| 44 | GrGLVersion glVer = GrGLGetVersionFromString(verStr); |
| 45 | |
| 46 | if (glVer < GR_GL_VER(2,0)) { |
| 47 | return nullptr; |
| 48 | } |
| 49 | |
| 50 | GET_PROC_LOCAL(GetIntegerv); |
| 51 | GET_PROC_LOCAL(GetStringi); |
| 52 | GrEGLQueryStringFn* queryString; |
| 53 | GrEGLDisplay display; |
| 54 | GrGetEGLQueryAndDisplay(&queryString, &display, ctx, get); |
| 55 | GrGLExtensions extensions; |
| 56 | if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, |
| 57 | display)) { |
| 58 | return nullptr; |
| 59 | } |
| 60 | |
| 61 | sk_sp<GrGLInterface> interface(new GrGLInterface); |
| 62 | GrGLInterface::Functions* functions = &interface->fFunctions; |
| 63 | |
| 64 | // Autogenerated content follows |
| 65 | [[content]] |
| 66 | // End autogenerated content |
| 67 | // TODO(kjlubick): Do we want a feature that removes the extension if it doesn't have |
| 68 | // the function? This is common on some low-end GPUs. |
| 69 | |
| 70 | if (extensions.has("GL_KHR_debug")) { |
| 71 | // In general we have a policy against removing extension strings when the driver does |
| 72 | // not provide function pointers for an advertised extension. However, because there is a |
| 73 | // known device that advertises GL_KHR_debug but fails to provide the functions and this is |
| 74 | // a debugging- only extension we've made an exception. This also can happen when using |
| 75 | // APITRACE. |
| 76 | if (!interface->fFunctions.fDebugMessageControl) { |
| 77 | extensions.remove("GL_KHR_debug"); |
| 78 | } |
| 79 | } |
| 80 | interface->fStandard = kGLES_GrGLStandard; |
| 81 | interface->fExtensions.swap(&extensions); |
| 82 | |
| 83 | return interface; |
| 84 | } |
| 85 | #endif |
| 86 | ` |
| 87 | |
| 88 | const ASSEMBLE_INTERFACE_GLscip-go gomod go.skia.org/skia . `go.skia.org/skia/tools/ganesh/gl/interface`/ASSEMBLE_INTERFACE_GL. = `/* |
| 89 | * Copyright 2019 Google LLC |
| 90 | * |
| 91 | * Use of this source code is governed by a BSD-style license that can be |
| 92 | * found in the LICENSE file. |
| 93 | * |
| 94 | * THIS FILE IS AUTOGENERATED |
| 95 | * Make edits to tools/ganesh/gl/interface/templates.go or they will |
| 96 | * be overwritten. |
| 97 | */ |
| 98 | |
| 99 | #include "include/core/SkRefCnt.h" |
| 100 | #include "include/gpu/ganesh/gl/GrGLAssembleHelpers.h" |
| 101 | #include "include/gpu/ganesh/gl/GrGLAssembleInterface.h" |
| 102 | #include "include/gpu/ganesh/gl/GrGLExtensions.h" |
| 103 | #include "include/gpu/ganesh/gl/GrGLFunctions.h" |
| 104 | #include "include/gpu/ganesh/gl/GrGLInterface.h" |
| 105 | #include "include/gpu/ganesh/gl/GrGLTypes.h" |
| 106 | #include "src/gpu/ganesh/gl/GrGLDefines.h" |
| 107 | #include "src/gpu/ganesh/gl/GrGLUtil.h" |
| 108 | |
| 109 | #define GET_PROC(F) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F) |
| 110 | #define GET_PROC_SUFFIX(F, S) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F #S) |
| 111 | #define GET_PROC_LOCAL(F) GrGL##F##Fn* F = (GrGL##F##Fn*)get(ctx, "gl" #F) |
| 112 | |
| 113 | #if SK_DISABLE_GL_INTERFACE |
| 114 | sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get) { |
| 115 | return nullptr; |
| 116 | } |
| 117 | #else |
| 118 | sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get) { |
| 119 | GET_PROC_LOCAL(GetString); |
| 120 | GET_PROC_LOCAL(GetStringi); |
| 121 | GET_PROC_LOCAL(GetIntegerv); |
| 122 | |
| 123 | // GetStringi may be nullptr depending on the GL version. |
| 124 | if (nullptr == GetString || nullptr == GetIntegerv) { |
| 125 | return nullptr; |
| 126 | } |
| 127 | |
| 128 | const char* versionString = (const char*) GetString(GR_GL_VERSION); |
| 129 | GrGLVersion glVer = GrGLGetVersionFromString(versionString); |
| 130 | |
| 131 | if (glVer < GR_GL_VER(2,0) || GR_GL_INVALID_VER == glVer) { |
| 132 | // This is our minimum for non-ES GL. |
| 133 | return nullptr; |
| 134 | } |
| 135 | |
| 136 | GrEGLQueryStringFn* queryString; |
| 137 | GrEGLDisplay display; |
| 138 | GrGetEGLQueryAndDisplay(&queryString, &display, ctx, get); |
| 139 | GrGLExtensions extensions; |
| 140 | if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, |
| 141 | display)) { |
| 142 | return nullptr; |
| 143 | } |
| 144 | |
| 145 | sk_sp<GrGLInterface> interface(new GrGLInterface()); |
| 146 | GrGLInterface::Functions* functions = &interface->fFunctions; |
| 147 | |
| 148 | // Autogenerated content follows |
| 149 | [[content]] |
| 150 | // End autogenerated content |
| 151 | interface->fStandard = kGL_GrGLStandard; |
| 152 | interface->fExtensions.swap(&extensions); |
| 153 | |
| 154 | return interface; |
| 155 | } |
| 156 | #endif |
| 157 | ` |
| 158 | |
| 159 | const ASSEMBLE_INTERFACE_WEBGLscip-go gomod go.skia.org/skia . `go.skia.org/skia/tools/ganesh/gl/interface`/ASSEMBLE_INTERFACE_WEBGL. = `/* |
| 160 | * Copyright 2019 Google LLC |
| 161 | * |
| 162 | * Use of this source code is governed by a BSD-style license that can be |
| 163 | * found in the LICENSE file. |
| 164 | * |
| 165 | * THIS FILE IS AUTOGENERATED |
| 166 | * Make edits to tools/ganesh/gl/interface/templates.go or they will |
| 167 | * be overwritten. |
| 168 | */ |
| 169 | #include "include/core/SkRefCnt.h" |
| 170 | #include "include/gpu/ganesh/gl/GrGLAssembleInterface.h" |
| 171 | |
| 172 | #if SK_DISABLE_WEBGL_INTERFACE || !defined(__EMSCRIPTEN__) |
| 173 | struct GrGLInterface; |
| 174 | sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get) { |
| 175 | return nullptr; |
| 176 | } |
| 177 | #else |
| 178 | |
| 179 | #include "include/gpu/ganesh/gl/GrGLAssembleHelpers.h" |
| 180 | #include "src/gpu/ganesh/gl/GrGLUtil.h" |
| 181 | |
| 182 | // Located https://github.com/emscripten-core/emscripten/tree/7ba7700902c46734987585409502f3c63beb650f/system/include/webgl |
| 183 | #include <webgl/webgl1.h> |
| 184 | #include <webgl/webgl1_ext.h> |
| 185 | #include <webgl/webgl2.h> |
| 186 | #include <webgl/webgl2_ext.h> |
| 187 | |
| 188 | #define GET_PROC(F) functions->f##F = emscripten_gl##F |
| 189 | #define GET_PROC_SUFFIX(F, S) functions->f##F = emscripten_gl##F##S |
| 190 | |
| 191 | sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get) { |
| 192 | const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION)); |
| 193 | GrGLVersion glVer = GrGLGetVersionFromString(verStr); |
| 194 | if (glVer < GR_GL_VER(1,0)) { |
| 195 | return nullptr; |
| 196 | } |
| 197 | |
| 198 | GrGLExtensions extensions; |
| 199 | if (!extensions.init(kWebGL_GrGLStandard, glGetString, glGetStringi, glGetIntegerv)) { |
| 200 | return nullptr; |
| 201 | } |
| 202 | |
| 203 | sk_sp<GrGLInterface> interface(new GrGLInterface); |
| 204 | GrGLInterface::Functions* functions = &interface->fFunctions; |
| 205 | |
| 206 | // Autogenerated content follows |
| 207 | [[content]] |
| 208 | // End autogenerated content |
| 209 | |
| 210 | interface->fStandard = kWebGL_GrGLStandard; |
| 211 | interface->fExtensions.swap(&extensions); |
| 212 | |
| 213 | return interface; |
| 214 | } |
| 215 | #endif |
| 216 | ` |
| 217 | |
| 218 | const VALIDATE_INTERFACEscip-go gomod go.skia.org/skia . `go.skia.org/skia/tools/ganesh/gl/interface`/VALIDATE_INTERFACE. = `/* |
| 219 | * Copyright 2011 Google Inc. |
| 220 | * |
| 221 | * Use of this source code is governed by a BSD-style license that can be |
| 222 | * found in the LICENSE file. |
| 223 | * |
| 224 | * THIS FILE IS AUTOGENERATED |
| 225 | * Make edits to tools/ganesh/gl/interface/templates.go or they will |
| 226 | * be overwritten. |
| 227 | */ |
| 228 | |
| 229 | #include "include/gpu/ganesh/gl/GrGLConfig.h" |
| 230 | #include "include/gpu/ganesh/gl/GrGLExtensions.h" |
| 231 | #include "include/gpu/ganesh/gl/GrGLFunctions.h" |
| 232 | #include "include/gpu/ganesh/gl/GrGLInterface.h" |
| 233 | #include "include/gpu/ganesh/gl/GrGLTypes.h" |
| 234 | #include "include/private/base/SkDebug.h" |
| 235 | #include "src/gpu/ganesh/gl/GrGLDefines.h" |
| 236 | #include "src/gpu/ganesh/gl/GrGLUtil.h" |
| 237 | |
| 238 | GrGLInterface::GrGLInterface() { |
| 239 | fStandard = kNone_GrGLStandard; |
| 240 | } |
| 241 | |
| 242 | #if GR_GL_CHECK_ERROR |
| 243 | static const char* get_error_string(GrGLenum err) { |
| 244 | switch (err) { |
| 245 | case GR_GL_NO_ERROR: |
| 246 | return ""; |
| 247 | case GR_GL_INVALID_ENUM: |
| 248 | return "Invalid Enum"; |
| 249 | case GR_GL_INVALID_VALUE: |
| 250 | return "Invalid Value"; |
| 251 | case GR_GL_INVALID_OPERATION: |
| 252 | return "Invalid Operation"; |
| 253 | case GR_GL_OUT_OF_MEMORY: |
| 254 | return "Out of Memory"; |
| 255 | case GR_GL_CONTEXT_LOST: |
| 256 | return "Context Lost"; |
| 257 | } |
| 258 | return "Unknown"; |
| 259 | } |
| 260 | |
| 261 | GrGLenum GrGLInterface::checkError(const char* location, const char* call) const { |
| 262 | GrGLenum error = fFunctions.fGetError(); |
| 263 | if (error != GR_GL_NO_ERROR && !fSuppressErrorLogging) { |
| 264 | SkDebugf("---- glGetError 0x%x(%s)", error, get_error_string(error)); |
| 265 | if (location) { |
| 266 | SkDebugf(" at\n\t%s", location); |
| 267 | } |
| 268 | if (call) { |
| 269 | SkDebugf("\n\t\t%s", call); |
| 270 | } |
| 271 | SkDebugf("\n"); |
| 272 | if (error == GR_GL_OUT_OF_MEMORY) { |
| 273 | fOOMed = true; |
| 274 | } |
| 275 | } |
| 276 | return error; |
| 277 | } |
| 278 | |
| 279 | bool GrGLInterface::checkAndResetOOMed() const { |
| 280 | if (fOOMed) { |
| 281 | fOOMed = false; |
| 282 | return true; |
| 283 | } |
| 284 | return false; |
| 285 | } |
| 286 | |
| 287 | void GrGLInterface::suppressErrorLogging() { fSuppressErrorLogging = true; } |
| 288 | #endif |
| 289 | |
| 290 | #define RETURN_FALSE_INTERFACE \ |
| 291 | SkDEBUGF("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); \ |
| 292 | return false |
| 293 | |
| 294 | bool GrGLInterface::validate() const { |
| 295 | |
| 296 | if (kNone_GrGLStandard == fStandard) { |
| 297 | RETURN_FALSE_INTERFACE; |
| 298 | } |
| 299 | |
| 300 | if (!fExtensions.isInitialized()) { |
| 301 | RETURN_FALSE_INTERFACE; |
| 302 | } |
| 303 | |
| 304 | GrGLVersion glVer = GrGLGetVersion(this); |
| 305 | if (GR_GL_INVALID_VER == glVer) { |
| 306 | RETURN_FALSE_INTERFACE; |
| 307 | } |
| 308 | // Autogenerated content follows |
| 309 | [[content]] |
| 310 | // End autogenerated content |
| 311 | return true; |
| 312 | } |
| 313 | |
| 314 | #if defined(GPU_TEST_UTILS) |
| 315 | |
| 316 | void GrGLInterface::abandon() const { |
| 317 | const_cast<GrGLInterface*>(this)->fFunctions = GrGLInterface::Functions(); |
| 318 | } |
| 319 | |
| 320 | #endif // defined(GPU_TEST_UTILS) |
| 321 | ` |