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/private/base/SkAssert.h" 12 #include "src/sksl/SkSLUtil.h" 13 14 class SkJSONWriter; 15 struct GrContextOptions; 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 fPreferFlatInterpolation = false; 36 bool fVertexIDSupport = false; 37 // Returns true if `expr` in `myArray[expr]` can be any integer expression. If false, `expr` 38 // must be a constant-index-expression as defined in the OpenGL ES2 specification, Appendix A.5. 39 bool fNonconstantArrayIndexSupport = false; 40 // frexp(), ldexp(), findMSB(), findLSB(). 41 bool fBitManipulationSupport = false; 42 bool fHalfIs32Bits = false; 43 bool fHasLowFragmentPrecision = false; 44 // Use a reduced set of rendering algorithms or less optimal effects in order to reduce the 45 // number of unique shaders generated. 46 bool fReducedShaderMode = false; 47 48 // Used for specific driver bug workarounds 49 bool fRequiresLocalOutputColorForFBFetch = false; 50 // Workaround for Mali GPU opacity bug with uniform colors. 51 bool fMustObfuscateUniformColor = false; 52 // On Nexus 6, the GL context can get lost if a shader does not write a value to gl_FragColor. 53 // https://bugs.chromium.org/p/chromium/issues/detail?id=445377 54 bool fMustWriteToFragColor = false; 55 // When we have the option of using either dFdx or dfDy in a shader, this returns whether we 56 // should avoid using dFdx. We have found some drivers have bugs or lower precision when using 57 // dFdx. 58 bool fAvoidDfDxForGradientsWhenPossible = false; 59 60 // This contains the name of an extension that must be enabled in the shader, if such a thing is 61 // required in order to use a secondary output in the shader. This returns a nullptr if no such 62 // extension is required. However, the return value of this function does not say whether dual 63 // source blending is supported. 64 const char* fSecondaryOutputExtensionString = nullptr; 65 66 const char* fNoPerspectiveInterpolationExtensionString = nullptr; 67 const char* fSampleVariablesExtensionString = nullptr; 68 69 const char* fFBFetchExtensionString = nullptr; 70 71 int fMaxFragmentSamplers = 0; 72 }; 73 74 #endif 75