• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #ifndef GrShaderCaps_DEFINED
9 #define GrShaderCaps_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "src/sksl/SkSLUtil.h"
13 
14 struct GrContextOptions;
15 class SkJSONWriter;
16 
17 struct GrShaderCaps : SkSL::ShaderCaps {
GrShaderCapsGrShaderCaps18     GrShaderCaps() {}
19 
20     void dumpJSON(SkJSONWriter*) const;
21 
noperspectiveInterpolationExtensionStringGrShaderCaps22     const char* noperspectiveInterpolationExtensionString() const {
23         SkASSERT(this->fNoPerspectiveInterpolationSupport);
24         return fNoPerspectiveInterpolationExtensionString;
25     }
26 
sampleVariablesExtensionStringGrShaderCaps27     const char* sampleVariablesExtensionString() const {
28         SkASSERT(this->fSampleMaskSupport);
29         return fSampleVariablesExtensionString;
30     }
31 
32     void applyOptionsOverrides(const GrContextOptions& options);
33 
34     bool fDstReadInShaderSupport = false;
35     bool fDualSourceBlendingSupport = false;
36     bool fPreferFlatInterpolation = false;
37     bool fVertexIDSupport = false;
38     // Returns true if `expr` in `myArray[expr]` can be any integer expression. If false, `expr`
39     // must be a constant-index-expression as defined in the OpenGL ES2 specification, Appendix A.5.
40     bool fNonconstantArrayIndexSupport = false;
41     // frexp(), ldexp(), findMSB(), findLSB().
42     bool fBitManipulationSupport = false;
43     bool fHalfIs32Bits = false;
44     bool fHasLowFragmentPrecision = false;
45     // Use a reduced set of rendering algorithms or less optimal effects in order to reduce the
46     // number of unique shaders generated.
47     bool fReducedShaderMode = false;
48 
49     // Used for specific driver bug workarounds
50     bool fRequiresLocalOutputColorForFBFetch = false;
51     // Workaround for Mali GPU opacity bug with uniform colors.
52     bool fMustObfuscateUniformColor = false;
53     // On Nexus 6, the GL context can get lost if a shader does not write a value to gl_FragColor.
54     // https://bugs.chromium.org/p/chromium/issues/detail?id=445377
55     bool fMustWriteToFragColor = false;
56     bool fColorSpaceMathNeedsFloat = false;
57     // When we have the option of using either dFdx or dfDy in a shader, this returns whether we
58     // should avoid using dFdx. We have found some drivers have bugs or lower precision when using
59     // dFdx.
60     bool fAvoidDfDxForGradientsWhenPossible = false;
61 
62     // This contains the name of an extension that must be enabled in the shader, if such a thing is
63     // required in order to use a secondary output in the shader. This returns a nullptr if no such
64     // extension is required. However, the return value of this function does not say whether dual
65     // source blending is supported.
66     const char* fSecondaryOutputExtensionString = nullptr;
67 
68     const char* fNoPerspectiveInterpolationExtensionString = nullptr;
69     const char* fSampleVariablesExtensionString = nullptr;
70 
71     const char* fFBFetchExtensionString = nullptr;
72 
73     int fMaxFragmentSamplers = 0;
74 };
75 
76 #endif
77