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