/src/skia/src/gpu/gl/GrGLGLSL.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
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. |
6 | | */ |
7 | | |
8 | | #include "src/gpu/gl/GrGLGLSL.h" |
9 | | #include "src/gpu/gl/GrGLUtil.h" |
10 | | |
11 | 0 | bool GrGLGetGLSLGeneration(const GrGLDriverInfo& info, GrGLSLGeneration* generation) { |
12 | 0 | SkASSERT(generation); |
13 | | // Workaround for a bug on some Adreno 308 devices with Android 9. The driver reports a GL |
14 | | // version of 3.0, and a GLSL version of 3.1. If we use version 310 shaders, the driver reports |
15 | | // that it's not supported. To keep things simple, we pin the GLSL version to the GL version. |
16 | | // Note that GLSL versions have an extra digit on their minor level, so we have to scale up |
17 | | // the GL version's minor revision to get a comparable GLSL version. This logic can easily |
18 | | // create invalid GLSL versions (older GL didn't keep the versions in sync), but the checks |
19 | | // below will further pin the GLSL generation correctly. |
20 | | // https://github.com/flutter/flutter/issues/36130 |
21 | 0 | uint32_t glMajor = GR_GL_MAJOR_VER(info.fVersion), |
22 | 0 | glMinor = GR_GL_MINOR_VER(info.fVersion); |
23 | 0 | GrGLSLVersion ver = std::min(info.fGLSLVersion, GR_GLSL_VER(glMajor, 10 * glMinor)); |
24 | 0 | if (info.fGLSLVersion == GR_GLSL_INVALID_VER) { |
25 | 0 | return false; |
26 | 0 | } |
27 | | |
28 | 0 | if (GR_IS_GR_GL(info.fStandard)) { |
29 | 0 | SkASSERT(ver >= GR_GLSL_VER(1,10)); |
30 | 0 | if (ver >= GR_GLSL_VER(4,20)) { |
31 | 0 | *generation = k420_GrGLSLGeneration; |
32 | 0 | } else if (ver >= GR_GLSL_VER(4,00)) { |
33 | 0 | *generation = k400_GrGLSLGeneration; |
34 | 0 | } else if (ver >= GR_GLSL_VER(3,30)) { |
35 | 0 | *generation = k330_GrGLSLGeneration; |
36 | 0 | } else if (ver >= GR_GLSL_VER(1,50)) { |
37 | 0 | *generation = k150_GrGLSLGeneration; |
38 | 0 | } else if (ver >= GR_GLSL_VER(1,40)) { |
39 | 0 | *generation = k140_GrGLSLGeneration; |
40 | 0 | } else if (ver >= GR_GLSL_VER(1,30)) { |
41 | 0 | *generation = k130_GrGLSLGeneration; |
42 | 0 | } else { |
43 | 0 | *generation = k110_GrGLSLGeneration; |
44 | 0 | } |
45 | 0 | return true; |
46 | 0 | } else if (GR_IS_GR_GL_ES(info.fStandard)) { |
47 | 0 | SkASSERT(ver >= GR_GL_VER(1,00)); |
48 | 0 | if (ver >= GR_GLSL_VER(3,20)) { |
49 | 0 | *generation = k320es_GrGLSLGeneration; |
50 | 0 | } else if (ver >= GR_GLSL_VER(3,10)) { |
51 | 0 | *generation = k310es_GrGLSLGeneration; |
52 | 0 | } else if (ver >= GR_GLSL_VER(3,00)) { |
53 | 0 | *generation = k330_GrGLSLGeneration; |
54 | 0 | } else { |
55 | 0 | *generation = k110_GrGLSLGeneration; |
56 | 0 | } |
57 | 0 | return true; |
58 | 0 | } else if (GR_IS_GR_WEBGL(info.fStandard)) { |
59 | 0 | SkASSERT(ver >= GR_GL_VER(1,0)); |
60 | 0 | if (ver >= GR_GLSL_VER(2,0)) { |
61 | 0 | *generation = k330_GrGLSLGeneration; // ES 3.0 |
62 | 0 | } else { |
63 | 0 | *generation = k110_GrGLSLGeneration; |
64 | 0 | } |
65 | 0 | return true; |
66 | 0 | } |
67 | 0 | SK_ABORT("Unknown GL Standard"); |
68 | 0 | } Unexecuted instantiation: GrGLGetGLSLGeneration(GrGLDriverInfo const&, GrGLSLGeneration*) Unexecuted instantiation: GrGLGetGLSLGeneration(GrGLDriverInfo const&, GrGLSLGeneration*) |