2015-06-24 13:59:57 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GrGLSLCaps_DEFINED
|
|
|
|
#define GrGLSLCaps_DEFINED
|
|
|
|
|
|
|
|
#include "GrCaps.h"
|
|
|
|
#include "GrGLSL.h"
|
|
|
|
|
|
|
|
class GrGLSLCaps : public GrShaderCaps {
|
|
|
|
public:
|
2015-06-26 18:45:03 +00:00
|
|
|
|
2015-06-24 13:59:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates how GLSL must interact with advanced blend equations. The KHR extension requires
|
|
|
|
* special layout qualifiers in the fragment shader.
|
|
|
|
*/
|
|
|
|
enum AdvBlendEqInteraction {
|
|
|
|
kNotSupported_AdvBlendEqInteraction, //<! No _blend_equation_advanced extension
|
|
|
|
kAutomatic_AdvBlendEqInteraction, //<! No interaction required
|
|
|
|
kGeneralEnable_AdvBlendEqInteraction, //<! layout(blend_support_all_equations) out
|
|
|
|
kSpecificEnables_AdvBlendEqInteraction, //<! Specific layout qualifiers per equation
|
|
|
|
|
|
|
|
kLast_AdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the GrGLSLCaps to a default set of features
|
|
|
|
*/
|
|
|
|
GrGLSLCaps(const GrContextOptions&);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some helper functions for encapsulating various extensions to read FB Buffer on openglES
|
|
|
|
*
|
|
|
|
* TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar to this effect
|
|
|
|
*/
|
|
|
|
bool fbFetchSupport() const { return fFBFetchSupport; }
|
|
|
|
|
|
|
|
bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; }
|
|
|
|
|
|
|
|
bool bindlessTextureSupport() const { return fBindlessTextureSupport; }
|
|
|
|
|
2015-10-22 15:20:00 +00:00
|
|
|
const char* versionDeclString() const { return fVersionDeclString; }
|
|
|
|
|
2015-06-24 13:59:57 +00:00
|
|
|
const char* fbFetchColorName() const { return fFBFetchColorName; }
|
|
|
|
|
|
|
|
const char* fbFetchExtensionString() const { return fFBFetchExtensionString; }
|
|
|
|
|
|
|
|
bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
|
|
|
|
|
|
|
|
AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
|
|
|
|
|
|
|
|
bool mustEnableAdvBlendEqs() const {
|
|
|
|
return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mustEnableSpecificAdvBlendEqs() const {
|
|
|
|
return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mustDeclareFragmentShaderOutput() const {
|
|
|
|
return fGLSLGeneration > k110_GrGLSLGeneration;
|
|
|
|
}
|
|
|
|
|
2015-10-21 14:14:17 +00:00
|
|
|
bool usesPrecisionModifiers() const { return fUsesPrecisionModifiers; }
|
|
|
|
|
2015-10-22 15:20:00 +00:00
|
|
|
// Returns whether we can use the glsl funciton any() in our shader code.
|
|
|
|
bool canUseAnyFunctionInShader() const { return fCanUseAnyFunctionInShader; }
|
|
|
|
|
|
|
|
bool forceHighPrecisionNDSTransform() const { return fForceHighPrecisionNDSTransform; }
|
|
|
|
|
2015-11-11 14:27:20 +00:00
|
|
|
bool canUseMinAndAbsTogether() const { return fCanUseMinAndAbsTogether; }
|
|
|
|
|
|
|
|
bool mustForceNegatedAtanParamToFloat() const { return fMustForceNegatedAtanParamToFloat; }
|
|
|
|
|
2015-11-02 14:22:44 +00:00
|
|
|
// Returns the string of an extension that must be enabled in the shader to support
|
|
|
|
// derivatives. If nullptr is returned then no extension needs to be enabled. Before calling
|
|
|
|
// this function, the caller should check that shaderDerivativeSupport exists.
|
|
|
|
const char* shaderDerivativeExtensionString() const {
|
|
|
|
SkASSERT(this->shaderDerivativeSupport());
|
|
|
|
return fShaderDerivativeExtensionString;
|
|
|
|
}
|
2015-11-11 14:27:20 +00:00
|
|
|
|
|
|
|
// Returns the string of an extension that will do all necessary coord transfomations needed
|
|
|
|
// when reading the fragment position. If such an extension does not exisits, this function
|
|
|
|
// returns a nullptr, and all transforms of the frag position must be done manually in the
|
|
|
|
// shader.
|
|
|
|
const char* fragCoordConventionsExtensionString() const {
|
|
|
|
return fFragCoordConventionsExtensionString;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This returns the name of an extension that must be enabled in the shader, if such a thing is
|
|
|
|
// required in order to use a secondary output in the shader. This returns a nullptr if no such
|
|
|
|
// extension is required. However, the return value of this function does not say whether dual
|
|
|
|
// source blending is supported.
|
|
|
|
const char* secondaryOutputExtensionString() const {
|
|
|
|
return fSecondaryOutputExtensionString;
|
|
|
|
}
|
2015-11-02 14:22:44 +00:00
|
|
|
|
2015-11-04 12:23:53 +00:00
|
|
|
bool mustSwizzleInShader() const { return fMustSwizzleInShader; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string which represents how to map from an internal GLFormat to a given
|
|
|
|
* GrPixelConfig. The function mustSwizzleInShader determines whether this swizzle is applied
|
|
|
|
* in the generated shader code or using sample state in the 3D API.
|
|
|
|
*/
|
|
|
|
const char* getSwizzleMap(GrPixelConfig config) const { return fConfigSwizzle[config]; }
|
|
|
|
|
2015-06-24 13:59:57 +00:00
|
|
|
GrGLSLGeneration generation() const { return fGLSLGeneration; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string containing the caps info.
|
|
|
|
*/
|
|
|
|
SkString dump() const override;
|
|
|
|
|
|
|
|
private:
|
2015-11-04 12:23:53 +00:00
|
|
|
void onApplyOptionsOverrides(const GrContextOptions& options) override;
|
|
|
|
|
2015-06-24 13:59:57 +00:00
|
|
|
GrGLSLGeneration fGLSLGeneration;
|
|
|
|
|
|
|
|
bool fDropsTileOnZeroDivide : 1;
|
|
|
|
bool fFBFetchSupport : 1;
|
|
|
|
bool fFBFetchNeedsCustomOutput : 1;
|
|
|
|
bool fBindlessTextureSupport : 1;
|
2015-10-21 14:14:17 +00:00
|
|
|
bool fUsesPrecisionModifiers : 1;
|
2015-10-22 15:20:00 +00:00
|
|
|
bool fCanUseAnyFunctionInShader : 1;
|
|
|
|
bool fForceHighPrecisionNDSTransform : 1;
|
2015-10-21 14:14:17 +00:00
|
|
|
|
2015-11-11 14:27:20 +00:00
|
|
|
// Used for specific driver bug work arounds
|
|
|
|
bool fCanUseMinAndAbsTogether : 1;
|
|
|
|
bool fMustForceNegatedAtanParamToFloat : 1;
|
|
|
|
|
2015-10-22 15:20:00 +00:00
|
|
|
const char* fVersionDeclString;
|
2015-06-24 13:59:57 +00:00
|
|
|
|
2015-11-02 14:22:44 +00:00
|
|
|
const char* fShaderDerivativeExtensionString;
|
2015-11-11 14:27:20 +00:00
|
|
|
const char* fFragCoordConventionsExtensionString;
|
|
|
|
const char* fSecondaryOutputExtensionString;
|
2015-11-02 14:22:44 +00:00
|
|
|
|
2015-06-24 13:59:57 +00:00
|
|
|
const char* fFBFetchColorName;
|
|
|
|
const char* fFBFetchExtensionString;
|
|
|
|
|
|
|
|
AdvBlendEqInteraction fAdvBlendEqInteraction;
|
|
|
|
|
2015-11-04 12:23:53 +00:00
|
|
|
bool fMustSwizzleInShader;
|
|
|
|
const char* fConfigSwizzle[kGrPixelConfigCnt];
|
|
|
|
|
2015-06-24 13:59:57 +00:00
|
|
|
friend class GrGLCaps; // For initialization.
|
|
|
|
|
|
|
|
typedef GrShaderCaps INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|