blob: cf41f8e765e8e3bb1049711d6e6d76d50d9138a6 [file] [log] [blame]
jvanverthcba99b82015-06-24 06:59:57 -07001/*
2 * Copyright 2012 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
8
9#include "GrGLSLCaps.h"
10
egdanielb7e7d572015-11-04 04:23:53 -080011#include "GrContextOptions.h"
12
jvanverthcba99b82015-06-24 06:59:57 -070013////////////////////////////////////////////////////////////////////////////////////////////
14
15GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
jvanverth98a83a92015-06-24 11:07:07 -070016 fGLSLGeneration = k330_GrGLSLGeneration;
17
jvanverthcba99b82015-06-24 06:59:57 -070018 fDropsTileOnZeroDivide = false;
19 fFBFetchSupport = false;
20 fFBFetchNeedsCustomOutput = false;
21 fBindlessTextureSupport = false;
egdanielf5294392015-10-21 07:14:17 -070022 fUsesPrecisionModifiers = false;
egdaniel472d44e2015-10-22 08:20:00 -070023 fCanUseAnyFunctionInShader = true;
egdaniel8dcdedc2015-11-11 06:27:20 -080024 fCanUseMinAndAbsTogether = true;
25 fMustForceNegatedAtanParamToFloat = false;
egdaniel472d44e2015-10-22 08:20:00 -070026 fVersionDeclString = nullptr;
egdaniel574a4c12015-11-02 06:22:44 -080027 fShaderDerivativeExtensionString = nullptr;
egdaniel8dcdedc2015-11-11 06:27:20 -080028 fFragCoordConventionsExtensionString = nullptr;
29 fSecondaryOutputExtensionString = nullptr;
bsalomon7ea33f52015-11-22 14:51:00 -080030 fExternalTextureExtensionString = nullptr;
halcanary96fcdcc2015-08-27 07:41:13 -070031 fFBFetchColorName = nullptr;
32 fFBFetchExtensionString = nullptr;
jvanverth98a83a92015-06-24 11:07:07 -070033 fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
egdanielb7e7d572015-11-04 04:23:53 -080034
35 fMustSwizzleInShader = false;
36 memset(fConfigSwizzle, 0, sizeof(fConfigSwizzle));
jvanverthcba99b82015-06-24 06:59:57 -070037}
38
39SkString GrGLSLCaps::dump() const {
40 SkString r = INHERITED::dump();
41
42 static const char* kAdvBlendEqInteractionStr[] = {
43 "Not Supported",
44 "Automatic",
45 "General Enable",
46 "Specific Enables",
47 };
48 GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction);
49 GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction);
50 GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction);
51 GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction);
52 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlendEqInteraction + 1);
53
54 r.appendf("--- GLSL-Specific ---\n");
55
56 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
57 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
58 r.appendf("Bindless texture support: %s\n", (fBindlessTextureSupport ? "YES" : "NO"));
egdanielf5294392015-10-21 07:14:17 -070059 r.appendf("Uses precision modifiers: %s\n", (fUsesPrecisionModifiers ? "YES" : "NO"));
egdaniel8dcdedc2015-11-11 06:27:20 -080060 r.appendf("Can use any() function: %s\n", (fCanUseAnyFunctionInShader ? "YES" : "NO"));
egdaniel8dcdedc2015-11-11 06:27:20 -080061 r.appendf("Can use min() and abs() together: %s\n", (fCanUseMinAndAbsTogether ? "YES" : "NO"));
62 r.appendf("Must force negated atan param to float: %s\n", (fMustForceNegatedAtanParamToFloat ?
63 "YES" : "NO"));
jvanverthcba99b82015-06-24 06:59:57 -070064 r.appendf("Advanced blend equation interaction: %s\n",
65 kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]);
66 return r;
67}
68
egdanielb7e7d572015-11-04 04:23:53 -080069void GrGLSLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
70 if (options.fUseShaderSwizzling) {
71 fMustSwizzleInShader = true;
72 }
73}
74