Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
GrGLGLSL.h File Reference
#include "src/sksl/SkSLGLSL.h"

Go to the source code of this file.

Functions

bool GrGLGetGLSLGeneration (const GrGLDriverInfo &, SkSL::GLSLGeneration *generation)
 

Function Documentation

◆ GrGLGetGLSLGeneration()

bool GrGLGetGLSLGeneration ( const GrGLDriverInfo info,
SkSL::GLSLGeneration generation 
)

Gets the most recent GLSL Generation compatible with the OpenGL context.

Definition at line 12 of file GrGLGLSL.cpp.

12 {
13 SkASSERT(generation);
14 // Workaround for a bug on some Adreno 308 devices with Android 9. The driver reports a GL
15 // version of 3.0, and a GLSL version of 3.1. If we use version 310 shaders, the driver reports
16 // that it's not supported. To keep things simple, we pin the GLSL version to the GL version.
17 // Note that GLSL versions have an extra digit on their minor level, so we have to scale up
18 // the GL version's minor revision to get a comparable GLSL version. This logic can easily
19 // create invalid GLSL versions (older GL didn't keep the versions in sync), but the checks
20 // below will further pin the GLSL generation correctly.
21 // https://github.com/flutter/flutter/issues/36130
22 uint32_t glMajor = GR_GL_MAJOR_VER(info.fVersion),
23 glMinor = GR_GL_MINOR_VER(info.fVersion);
24 GrGLSLVersion ver = std::min(info.fGLSLVersion, GR_GLSL_VER(glMajor, 10 * glMinor));
25 if (info.fGLSLVersion == GR_GLSL_INVALID_VER) {
26 return false;
27 }
28
29 if (GR_IS_GR_GL(info.fStandard)) {
30 SkASSERT(ver >= GR_GLSL_VER(1,10));
31 if (ver >= GR_GLSL_VER(4,20)) {
32 *generation = SkSL::GLSLGeneration::k420;
33 } else if (ver >= GR_GLSL_VER(4,00)) {
34 *generation = SkSL::GLSLGeneration::k400;
35 } else if (ver >= GR_GLSL_VER(3,30)) {
36 *generation = SkSL::GLSLGeneration::k330;
37 } else if (ver >= GR_GLSL_VER(1,50)) {
38 *generation = SkSL::GLSLGeneration::k150;
39 } else if (ver >= GR_GLSL_VER(1,40)) {
40 *generation = SkSL::GLSLGeneration::k140;
41 } else if (ver >= GR_GLSL_VER(1,30)) {
42 *generation = SkSL::GLSLGeneration::k130;
43 } else {
44 *generation = SkSL::GLSLGeneration::k110;
45 }
46 return true;
47 } else if (GR_IS_GR_GL_ES(info.fStandard)) {
48 SkASSERT(ver >= GR_GLSL_VER(1,00));
49 if (ver >= GR_GLSL_VER(3,20)) {
50 *generation = SkSL::GLSLGeneration::k320es;
51 } else if (ver >= GR_GLSL_VER(3,10)) {
52 *generation = SkSL::GLSLGeneration::k310es;
53 } else if (ver >= GR_GLSL_VER(3,00)) {
54 *generation = SkSL::GLSLGeneration::k300es;
55 } else {
56 *generation = SkSL::GLSLGeneration::k100es;
57 }
58 return true;
59 } else if (GR_IS_GR_WEBGL(info.fStandard)) {
60 SkASSERT(ver >= GR_GLSL_VER(1,0));
61 if (ver >= GR_GLSL_VER(2,0)) {
62 *generation = SkSL::GLSLGeneration::k300es;
63 } else {
64 *generation = SkSL::GLSLGeneration::k100es;
65 }
66 return true;
67 }
68 SK_ABORT("Unknown GL Standard");
69}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
#define GR_IS_GR_WEBGL(standard)
Definition GrGLTypes.h:50
#define GR_IS_GR_GL(standard)
Definition GrGLTypes.h:48
#define GR_IS_GR_GL_ES(standard)
Definition GrGLTypes.h:49
#define GR_GLSL_INVALID_VER
Definition GrGLUtil.h:38
uint32_t GrGLSLVersion
Definition GrGLUtil.h:23
#define GR_GLSL_VER(major, minor)
Definition GrGLUtil.h:28
#define GR_GL_MINOR_VER(version)
Definition GrGLUtil.h:35
#define GR_GL_MAJOR_VER(version)
Definition GrGLUtil.h:34
#define SK_ABORT(message,...)
Definition SkAssert.h:70
#define SkASSERT(cond)
Definition SkAssert.h:116