blob: 4050d36be676381bcfe146e18260793cc49d6a10 [file] [log] [blame]
tomhudson@google.com086e5352011-12-08 14:44:10 +00001/*
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
Brian Salomon23c55b62018-06-19 16:28:41 -04008#include "GrGLGLSL.h"
egdanielf5294392015-10-21 07:14:17 -07009#include "GrGLUtil.h"
tomhudson@google.com086e5352011-12-08 14:44:10 +000010
jvanverthcba99b82015-06-24 06:59:57 -070011bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
bsalomon49f085d2014-09-05 13:34:00 -070012 SkASSERT(generation);
tomhudson@google.com086e5352011-12-08 14:44:10 +000013 GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000014 if (GR_GLSL_INVALID_VER == ver) {
15 return false;
16 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000017 switch (gl->fStandard) {
18 case kGL_GrGLStandard:
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000019 SkASSERT(ver >= GR_GLSL_VER(1,10));
Brian Salomond327e8c2016-11-15 13:26:08 -050020 if (ver >= GR_GLSL_VER(4,20)) {
21 *generation = k420_GrGLSLGeneration;
22 } else if (ver >= GR_GLSL_VER(4,00)) {
cdalton33ad7012016-02-22 07:55:44 -080023 *generation = k400_GrGLSLGeneration;
24 } else if (ver >= GR_GLSL_VER(3,30)) {
rmistry63a9f842014-10-17 06:07:08 -070025 *generation = k330_GrGLSLGeneration;
26 } else if (ver >= GR_GLSL_VER(1,50)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000027 *generation = k150_GrGLSLGeneration;
bsalomon@google.com281c7262012-10-23 14:31:30 +000028 } else if (ver >= GR_GLSL_VER(1,40)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000029 *generation = k140_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000030 } else if (ver >= GR_GLSL_VER(1,30)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000031 *generation = k130_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000032 } else {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000033 *generation = k110_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000034 }
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000035 return true;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000036 case kGLES_GrGLStandard:
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000037 SkASSERT(ver >= GR_GL_VER(1,00));
cdalton33ad7012016-02-22 07:55:44 -080038 if (ver >= GR_GLSL_VER(3,20)) {
39 *generation = k320es_GrGLSLGeneration;
40 } else if (ver >= GR_GLSL_VER(3,10)) {
rmistry63a9f842014-10-17 06:07:08 -070041 *generation = k310es_GrGLSLGeneration;
cdalton33ad7012016-02-22 07:55:44 -080042 } else if (ver >= GR_GLSL_VER(3,00)) {
rmistry63a9f842014-10-17 06:07:08 -070043 *generation = k330_GrGLSLGeneration;
44 } else {
45 *generation = k110_GrGLSLGeneration;
46 }
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000047 return true;
tomhudson@google.com086e5352011-12-08 14:44:10 +000048 default:
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040049 SK_ABORT("Unknown GL Standard");
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000050 return false;
tomhudson@google.com086e5352011-12-08 14:44:10 +000051 }
52}