tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 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 | |
egdaniel | f529439 | 2015-10-21 07:14:17 -0700 | [diff] [blame] | 8 | #include "GrGLContext.h" |
egdaniel | f529439 | 2015-10-21 07:14:17 -0700 | [diff] [blame] | 9 | #include "GrGLUtil.h" |
bsalomon@google.com | 4af0af6 | 2012-08-29 12:59:57 +0000 | [diff] [blame] | 10 | #include "SkString.h" |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 11 | #include "../private/GrGLSL.h" |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 12 | |
jvanverth | cba99b8 | 2015-06-24 06:59:57 -0700 | [diff] [blame] | 13 | bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 14 | SkASSERT(generation); |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 15 | GrGLSLVersion ver = GrGLGetGLSLVersion(gl); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 16 | if (GR_GLSL_INVALID_VER == ver) { |
| 17 | return false; |
| 18 | } |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 19 | switch (gl->fStandard) { |
| 20 | case kGL_GrGLStandard: |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 21 | SkASSERT(ver >= GR_GLSL_VER(1,10)); |
Brian Salomon | d327e8c | 2016-11-15 13:26:08 -0500 | [diff] [blame] | 22 | if (ver >= GR_GLSL_VER(4,20)) { |
| 23 | *generation = k420_GrGLSLGeneration; |
| 24 | } else if (ver >= GR_GLSL_VER(4,00)) { |
cdalton | 33ad701 | 2016-02-22 07:55:44 -0800 | [diff] [blame] | 25 | *generation = k400_GrGLSLGeneration; |
| 26 | } else if (ver >= GR_GLSL_VER(3,30)) { |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 27 | *generation = k330_GrGLSLGeneration; |
| 28 | } else if (ver >= GR_GLSL_VER(1,50)) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 29 | *generation = k150_GrGLSLGeneration; |
bsalomon@google.com | 281c726 | 2012-10-23 14:31:30 +0000 | [diff] [blame] | 30 | } else if (ver >= GR_GLSL_VER(1,40)) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 31 | *generation = k140_GrGLSLGeneration; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 32 | } else if (ver >= GR_GLSL_VER(1,30)) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 33 | *generation = k130_GrGLSLGeneration; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 34 | } else { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 35 | *generation = k110_GrGLSLGeneration; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 36 | } |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 37 | return true; |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 38 | case kGLES_GrGLStandard: |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 39 | SkASSERT(ver >= GR_GL_VER(1,00)); |
cdalton | 33ad701 | 2016-02-22 07:55:44 -0800 | [diff] [blame] | 40 | if (ver >= GR_GLSL_VER(3,20)) { |
| 41 | *generation = k320es_GrGLSLGeneration; |
| 42 | } else if (ver >= GR_GLSL_VER(3,10)) { |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 43 | *generation = k310es_GrGLSLGeneration; |
cdalton | 33ad701 | 2016-02-22 07:55:44 -0800 | [diff] [blame] | 44 | } else if (ver >= GR_GLSL_VER(3,00)) { |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 45 | *generation = k330_GrGLSLGeneration; |
| 46 | } else { |
| 47 | *generation = k110_GrGLSLGeneration; |
| 48 | } |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 49 | return true; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 50 | default: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 51 | SK_ABORT("Unknown GL Standard"); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 52 | return false; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 53 | } |
| 54 | } |