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 | |
jvanverth | cba99b8 | 2015-06-24 06:59:57 -0700 | [diff] [blame] | 8 | #include "GrGLGLSL.h" |
egdaniel | f529439 | 2015-10-21 07:14:17 -0700 | [diff] [blame] | 9 | #include "GrGLContext.h" |
egdaniel | f529439 | 2015-10-21 07:14:17 -0700 | [diff] [blame] | 10 | #include "GrGLUtil.h" |
bsalomon@google.com | 4af0af6 | 2012-08-29 12:59:57 +0000 | [diff] [blame] | 11 | #include "SkString.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)); |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 22 | if (ver >= GR_GLSL_VER(3,30)) { |
| 23 | *generation = k330_GrGLSLGeneration; |
| 24 | } else if (ver >= GR_GLSL_VER(1,50)) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 25 | *generation = k150_GrGLSLGeneration; |
bsalomon@google.com | 281c726 | 2012-10-23 14:31:30 +0000 | [diff] [blame] | 26 | } else if (ver >= GR_GLSL_VER(1,40)) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 27 | *generation = k140_GrGLSLGeneration; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 28 | } else if (ver >= GR_GLSL_VER(1,30)) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 29 | *generation = k130_GrGLSLGeneration; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 30 | } else { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 31 | *generation = k110_GrGLSLGeneration; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 32 | } |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 33 | return true; |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 34 | case kGLES_GrGLStandard: |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 35 | SkASSERT(ver >= GR_GL_VER(1,00)); |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 36 | 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.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 44 | return true; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 45 | default: |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 46 | SkFAIL("Unknown GL Standard"); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 47 | return false; |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 48 | } |
| 49 | } |
| 50 | |