blob: 98a2386161f8c80827a070adc61a60eac48edc1b [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
jvanverthcba99b82015-06-24 06:59:57 -07008#include "GrGLGLSL.h"
egdanielf5294392015-10-21 07:14:17 -07009#include "GrGLContext.h"
egdanielf5294392015-10-21 07:14:17 -070010#include "GrGLUtil.h"
bsalomon@google.com4af0af62012-08-29 12:59:57 +000011#include "SkString.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));
rmistry63a9f842014-10-17 06:07:08 -070022 if (ver >= GR_GLSL_VER(3,30)) {
23 *generation = k330_GrGLSLGeneration;
24 } else if (ver >= GR_GLSL_VER(1,50)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000025 *generation = k150_GrGLSLGeneration;
bsalomon@google.com281c7262012-10-23 14:31:30 +000026 } else if (ver >= GR_GLSL_VER(1,40)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000027 *generation = k140_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000028 } else if (ver >= GR_GLSL_VER(1,30)) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000029 *generation = k130_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000030 } else {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000031 *generation = k110_GrGLSLGeneration;
tomhudson@google.com086e5352011-12-08 14:44:10 +000032 }
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000033 return true;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000034 case kGLES_GrGLStandard:
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000035 SkASSERT(ver >= GR_GL_VER(1,00));
rmistry63a9f842014-10-17 06:07:08 -070036 if (ver >= GR_GLSL_VER(3,1)) {
37 *generation = k310es_GrGLSLGeneration;
38 }
39 else if (ver >= GR_GLSL_VER(3,0)) {
40 *generation = k330_GrGLSLGeneration;
41 } else {
42 *generation = k110_GrGLSLGeneration;
43 }
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000044 return true;
tomhudson@google.com086e5352011-12-08 14:44:10 +000045 default:
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +000046 SkFAIL("Unknown GL Standard");
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000047 return false;
tomhudson@google.com086e5352011-12-08 14:44:10 +000048 }
49}
50