blob: ab92358c139fa60e45f69d36f6f81a07e21bfd76 [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
egdanielf5294392015-10-21 07:14:17 -07008#include "GrGLContext.h"
egdanielf5294392015-10-21 07:14:17 -07009#include "GrGLUtil.h"
bsalomon@google.com4af0af62012-08-29 12:59:57 +000010#include "SkString.h"
Brian Salomon94efbf52016-11-29 13:43:05 -050011#include "../private/GrGLSL.h"
tomhudson@google.com086e5352011-12-08 14:44:10 +000012
jvanverthcba99b82015-06-24 06:59:57 -070013bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
bsalomon49f085d2014-09-05 13:34:00 -070014 SkASSERT(generation);
tomhudson@google.com086e5352011-12-08 14:44:10 +000015 GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000016 if (GR_GLSL_INVALID_VER == ver) {
17 return false;
18 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000019 switch (gl->fStandard) {
20 case kGL_GrGLStandard:
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000021 SkASSERT(ver >= GR_GLSL_VER(1,10));
Brian Salomond327e8c2016-11-15 13:26:08 -050022 if (ver >= GR_GLSL_VER(4,20)) {
23 *generation = k420_GrGLSLGeneration;
24 } else if (ver >= GR_GLSL_VER(4,00)) {
cdalton33ad7012016-02-22 07:55:44 -080025 *generation = k400_GrGLSLGeneration;
26 } else if (ver >= GR_GLSL_VER(3,30)) {
rmistry63a9f842014-10-17 06:07:08 -070027 *generation = k330_GrGLSLGeneration;
28 } else if (ver >= GR_GLSL_VER(1,50)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000029 *generation = k150_GrGLSLGeneration;
bsalomon@google.com281c7262012-10-23 14:31:30 +000030 } else if (ver >= GR_GLSL_VER(1,40)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000031 *generation = k140_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000032 } else if (ver >= GR_GLSL_VER(1,30)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000033 *generation = k130_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000034 } else {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000035 *generation = k110_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000036 }
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000037 return true;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000038 case kGLES_GrGLStandard:
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000039 SkASSERT(ver >= GR_GL_VER(1,00));
cdalton33ad7012016-02-22 07:55:44 -080040 if (ver >= GR_GLSL_VER(3,20)) {
41 *generation = k320es_GrGLSLGeneration;
42 } else if (ver >= GR_GLSL_VER(3,10)) {
rmistry63a9f842014-10-17 06:07:08 -070043 *generation = k310es_GrGLSLGeneration;
cdalton33ad7012016-02-22 07:55:44 -080044 } else if (ver >= GR_GLSL_VER(3,00)) {
rmistry63a9f842014-10-17 06:07:08 -070045 *generation = k330_GrGLSLGeneration;
46 } else {
47 *generation = k110_GrGLSLGeneration;
48 }
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000049 return true;
tomhudson@google.com086e5352011-12-08 14:44:10 +000050 default:
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040051 SK_ABORT("Unknown GL Standard");
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000052 return false;
tomhudson@google.com086e5352011-12-08 14:44:10 +000053 }
54}