#if SK_SUPPORT_GPU
#include "GLBench.h"
+#include "GrShaderCaps.h"
#include "GrShaderVar.h"
#include "gl/GrGLContext.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLUtil.h"
-#include "glsl/GrGLSL.h"
-#include "glsl/GrGLSLCaps.h"
+#include "../private/GrGLSL.h"
/*
* This is a native GL benchmark for instanced arrays vs vertex buffer objects. To benchmark this
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
- const GrGLSLCaps* glslCaps = ctx->caps()->glslCaps();
+ const GrShaderCaps* glslCaps = ctx->caps()->glslCaps();
const char* version = glslCaps->versionDeclString();
// setup vertex shader
#if SK_SUPPORT_GPU
#include "GLBench.h"
+#include "GrShaderCaps.h"
#include "GrShaderVar.h"
#include "gl/GrGLContext.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLUtil.h"
-#include "glsl/GrGLSL.h"
-#include "glsl/GrGLSLCaps.h"
+#include "../private/GrGLSL.h"
#include <stdio.h>
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
- const GrGLSLCaps* glslCaps = ctx->caps()->glslCaps();
+ const GrShaderCaps* glslCaps = ctx->caps()->glslCaps();
const char* version = glslCaps->versionDeclString();
// this shader draws fNumStages overlapping circles of increasing opacity (coverage) and
#if SK_SUPPORT_GPU
#include "GLBench.h"
+#include "GrShaderCaps.h"
#include "GrShaderVar.h"
#include "gl/GrGLContext.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLUtil.h"
-#include "glsl/GrGLSL.h"
-#include "glsl/GrGLSLCaps.h"
+#include "../private/GrGLSL.h"
#include <stdio.h>
/*
GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t attribs,
uint32_t maxAttribs) {
- const GrGLSLCaps* glslCaps = ctx->caps()->glslCaps();
+ const GrShaderCaps* glslCaps = ctx->caps()->glslCaps();
const char* version = glslCaps->versionDeclString();
// setup vertex shader
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder* b);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
return new GrGLPerlinNoise2;
}
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GrGLPerlinNoise2::GenKey(*this, caps, b);
}
args.fOutputColor, args.fOutputColor);
}
-void GrGLPerlinNoise2::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GrGLPerlinNoise2::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrPerlinNoise2Effect& turbulence = processor.cast<GrPerlinNoise2Effect>();
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
return new GrGLImprovedPerlinNoise;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GrGLImprovedPerlinNoise::GenKey(*this, caps, b);
}
args.fOutputColor, args.fOutputColor);
}
-void GrGLImprovedPerlinNoise::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GrGLImprovedPerlinNoise::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
}
"$_include/gpu/GrRenderTarget.h",
"$_include/gpu/GrRenderTargetContext.h",
"$_include/gpu/GrResourceKey.h",
+ "$_include/gpu/GrShaderCaps.h",
"$_include/gpu/GrShaderVar.h",
"$_include/gpu/GrSurface.h",
"$_include/gpu/GrSurfaceContext.h",
# Private includes
"$_include/private/GrAuditTrail.h",
+ "$_include/private/GrGLSL.h",
+ "$_include/private/GrGLSL_impl.h",
"$_include/private/GrInstancedPipelineInfo.h",
"$_include/private/GrSingleOwner.h",
"$_include/private/GrRenderTargetProxy.h",
"$_include/private/GrSurfaceProxy.h",
+ "$_include/private/GrSwizzle.h",
"$_include/private/GrTextureProxy.h",
"$_include/private/GrTextureRenderTargetProxy.h",
"$_include/private/GrTextureStripAtlas.h",
"$_src/gpu/GrResourceProvider.cpp",
"$_src/gpu/GrResourceProvider.h",
"$_src/gpu/GrScissorState.h",
+ "$_src/gpu/GrShaderCaps.cpp",
"$_src/gpu/GrShape.cpp",
"$_src/gpu/GrShape.h",
"$_src/gpu/GrStencilAttachment.cpp",
"$_src/gpu/GrSurface.cpp",
"$_src/gpu/GrSurfaceContext.cpp",
"$_src/gpu/GrSurfaceProxy.cpp",
- "$_src/gpu/GrSwizzle.h",
"$_src/gpu/GrTexture.cpp",
"$_src/gpu/GrTextureAdjuster.cpp",
"$_src/gpu/GrTextureAdjuster.h",
# GLSL
"$_src/gpu/glsl/GrGLSL.cpp",
- "$_src/gpu/glsl/GrGLSL.h",
- "$_src/gpu/glsl/GrGLSL_impl.h",
"$_src/gpu/glsl/GrGLSLBlend.cpp",
"$_src/gpu/glsl/GrGLSLBlend.h",
- "$_src/gpu/glsl/GrGLSLCaps.cpp",
- "$_src/gpu/glsl/GrGLSLCaps.h",
"$_src/gpu/glsl/GrGLSLColorSpaceXformHelper.h",
"$_src/gpu/glsl/GrGLSLFragmentProcessor.cpp",
"$_src/gpu/glsl/GrGLSLFragmentProcessor.h",
#include "GrTypesPriv.h"
#include "GrBlend.h"
#include "GrShaderVar.h"
+#include "GrShaderCaps.h"
#include "SkRefCnt.h"
#include "SkString.h"
struct GrContextOptions;
-class GrShaderCaps : public SkRefCnt {
-public:
- /** Info about shader variable precision within a given shader stage. That is, this info
- is relevant to a float (or vecNf) variable declared with a GrSLPrecision
- in a given GrShaderType. The info here is hoisted from the OpenGL spec. */
- struct PrecisionInfo {
- PrecisionInfo() {
- fLogRangeLow = 0;
- fLogRangeHigh = 0;
- fBits = 0;
- }
-
- /** Is this precision level allowed in the shader stage? */
- bool supported() const { return 0 != fBits; }
-
- bool operator==(const PrecisionInfo& that) const {
- return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fLogRangeHigh &&
- fBits == that.fBits;
- }
- bool operator!=(const PrecisionInfo& that) const { return !(*this == that); }
-
- /** floor(log2(|min_value|)) */
- int fLogRangeLow;
- /** floor(log2(|max_value|)) */
- int fLogRangeHigh;
- /** Number of bits of precision. As defined in OpenGL (with names modified to reflect this
- struct) :
- """
- If the smallest representable value greater than 1 is 1 + e, then fBits will
- contain floor(log2(e)), and every value in the range [2^fLogRangeLow,
- 2^fLogRangeHigh] can be represented to at least one part in 2^fBits.
- """
- */
- int fBits;
- };
-
- GrShaderCaps();
-
- virtual SkString dump() const;
-
- bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
- bool geometryShaderSupport() const { return fGeometryShaderSupport; }
- bool pathRenderingSupport() const { return fPathRenderingSupport; }
- bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
- bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
- bool integerSupport() const { return fIntegerSupport; }
- bool texelBufferSupport() const { return fTexelBufferSupport; }
- int imageLoadStoreSupport() const { return fImageLoadStoreSupport; }
-
- /**
- * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a
- * given shader type. If the shader type is not supported or the precision level is not
- * supported in that shader type then the returned struct will report false when supported() is
- * called.
- */
- const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType,
- GrSLPrecision precision) const {
- return fFloatPrecisions[shaderType][precision];
- }
-
- /**
- * Is there any difference between the float shader variable precision types? If this is true
- * then unless the shader type is not supported, any call to getFloatShaderPrecisionInfo() would
- * report the same info for all precisions in all shader types.
- */
- bool floatPrecisionVaries() const { return fShaderPrecisionVaries; }
-
- /**
- * PLS storage size in bytes (0 when not supported). The PLS spec defines a minimum size of 16
- * bytes whenever PLS is supported.
- */
- int pixelLocalStorageSize() const { return fPixelLocalStorageSize; }
-
- /**
- * True if this context supports the necessary extensions and features to enable the PLS path
- * renderer.
- */
- bool plsPathRenderingSupport() const {
-#if GR_ENABLE_PLS_PATH_RENDERING
- return fPLSPathRenderingSupport;
-#else
- return false;
-#endif
- }
-
-protected:
- /** Subclasses must call this after initialization in order to apply caps overrides requested by
- the client. Note that overrides will only reduce the caps never expand them. */
- void applyOptionsOverrides(const GrContextOptions& options);
-
- bool fShaderDerivativeSupport : 1;
- bool fGeometryShaderSupport : 1;
- bool fPathRenderingSupport : 1;
- bool fDstReadInShaderSupport : 1;
- bool fDualSourceBlendingSupport : 1;
- bool fIntegerSupport : 1;
- bool fTexelBufferSupport : 1;
- bool fImageLoadStoreSupport : 1;
- bool fPLSPathRenderingSupport : 1;
- bool fShaderPrecisionVaries : 1;
- PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
- int fPixelLocalStorageSize;
-
-private:
- virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
- typedef SkRefCnt INHERITED;
-};
/**
* Represents the capabilities of a GrContext.
virtual SkString dump() const;
- GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); }
+ const GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); }
bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
/** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
#include "GrProcessor.h"
class GrCoordTransform;
-class GrGLSLCaps;
class GrGLSLFragmentProcessor;
class GrInvariantOutput;
class GrPipeline;
class GrProcessorKeyBuilder;
+class GrShaderCaps;
/** Provides custom fragment shader code. Fragment processors receive an input color (vec4f) and
produce an output color. They may reference textures and uniforms. They may use
GrGLSLFragmentProcessor* createGLSLInstance() const;
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
this->onGetGLSLProcessorKey(caps, b);
for (int i = 0; i < fChildProcessors.count(); ++i) {
fChildProcessors[i]->getGLSLProcessorKey(caps, b);
virtual GrGLSLFragmentProcessor* onCreateGLSLInstance() const = 0;
/** Implemented using GLFragmentProcessor::GenKey as described in this class's comment. */
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
- GrProcessorKeyBuilder* b) const = 0;
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const = 0;
/**
* Subclass implements this to support isEqual(). It will only be called if it is known that
--- /dev/null
+/*
+ * 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 GrShaderCaps_DEFINED
+#define GrShaderCaps_DEFINED
+
+#include "../private/GrSwizzle.h"
+#include "../private/GrGLSL.h"
+
+namespace SkSL {
+ class GLSLCapsFactory;
+}
+struct GrContextOptions;
+
+class GrShaderCaps : public SkRefCnt {
+public:
+ /** Info about shader variable precision within a given shader stage. That is, this info
+ is relevant to a float (or vecNf) variable declared with a GrSLPrecision
+ in a given GrShaderType. The info here is hoisted from the OpenGL spec. */
+ struct PrecisionInfo {
+ PrecisionInfo() {
+ fLogRangeLow = 0;
+ fLogRangeHigh = 0;
+ fBits = 0;
+ }
+
+ /** Is this precision level allowed in the shader stage? */
+ bool supported() const { return 0 != fBits; }
+
+ bool operator==(const PrecisionInfo& that) const {
+ return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fLogRangeHigh &&
+ fBits == that.fBits;
+ }
+ bool operator!=(const PrecisionInfo& that) const { return !(*this == that); }
+
+ /** floor(log2(|min_value|)) */
+ int fLogRangeLow;
+ /** floor(log2(|max_value|)) */
+ int fLogRangeHigh;
+ /** Number of bits of precision. As defined in OpenGL (with names modified to reflect this
+ struct) :
+ """
+ If the smallest representable value greater than 1 is 1 + e, then fBits will
+ contain floor(log2(e)), and every value in the range [2^fLogRangeLow,
+ 2^fLogRangeHigh] can be represented to at least one part in 2^fBits.
+ """
+ */
+ int fBits;
+ };
+
+ /**
+ * 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
+ };
+
+ GrShaderCaps(const GrContextOptions&);
+
+ SkString dump() const;
+
+ bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
+ bool geometryShaderSupport() const { return fGeometryShaderSupport; }
+ bool pathRenderingSupport() const { return fPathRenderingSupport; }
+ bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
+ bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
+ bool integerSupport() const { return fIntegerSupport; }
+ bool texelBufferSupport() const { return fTexelBufferSupport; }
+ int imageLoadStoreSupport() const { return fImageLoadStoreSupport; }
+
+ /**
+ * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a
+ * given shader type. If the shader type is not supported or the precision level is not
+ * supported in that shader type then the returned struct will report false when supported() is
+ * called.
+ */
+ const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType,
+ GrSLPrecision precision) const {
+ return fFloatPrecisions[shaderType][precision];
+ }
+
+ /**
+ * Is there any difference between the float shader variable precision types? If this is true
+ * then unless the shader type is not supported, any call to getFloatShaderPrecisionInfo() would
+ * report the same info for all precisions in all shader types.
+ */
+ bool floatPrecisionVaries() const { return fShaderPrecisionVaries; }
+
+ /**
+ * PLS storage size in bytes (0 when not supported). The PLS spec defines a minimum size of 16
+ * bytes whenever PLS is supported.
+ */
+ int pixelLocalStorageSize() const { return fPixelLocalStorageSize; }
+
+ /**
+ * True if this context supports the necessary extensions and features to enable the PLS path
+ * renderer.
+ */
+ bool plsPathRenderingSupport() const {
+#if GR_ENABLE_PLS_PATH_RENDERING
+ return fPLSPathRenderingSupport;
+#else
+ return false;
+#endif
+ }
+
+ /**
+ * 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; }
+
+ const char* versionDeclString() const { return fVersionDeclString; }
+
+ const char* fbFetchColorName() const { return fFBFetchColorName; }
+
+ const char* fbFetchExtensionString() const { return fFBFetchExtensionString; }
+
+ bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
+
+ bool flatInterpolationSupport() const { return fFlatInterpolationSupport; }
+
+ bool noperspectiveInterpolationSupport() const { return fNoPerspectiveInterpolationSupport; }
+
+ bool multisampleInterpolationSupport() const { return fMultisampleInterpolationSupport; }
+
+ bool sampleVariablesSupport() const { return fSampleVariablesSupport; }
+
+ bool sampleMaskOverrideCoverageSupport() const { return fSampleMaskOverrideCoverageSupport; }
+
+ bool externalTextureSupport() const { return fExternalTextureSupport; }
+
+ bool texelFetchSupport() const { return fTexelFetchSupport; }
+
+ 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;
+ }
+
+ bool usesPrecisionModifiers() const { return fUsesPrecisionModifiers; }
+
+ // Returns whether we can use the glsl funciton any() in our shader code.
+ bool canUseAnyFunctionInShader() const { return fCanUseAnyFunctionInShader; }
+
+ bool canUseMinAndAbsTogether() const { return fCanUseMinAndAbsTogether; }
+
+ bool mustForceNegatedAtanParamToFloat() const { return fMustForceNegatedAtanParamToFloat; }
+
+ bool requiresLocalOutputColorForFBFetch() const { return fRequiresLocalOutputColorForFBFetch; }
+
+ // 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;
+ }
+
+ // 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;
+ }
+
+ const char* externalTextureExtensionString() const {
+ SkASSERT(this->externalTextureSupport());
+ return fExternalTextureExtensionString;
+ }
+
+ const char* texelBufferExtensionString() const {
+ SkASSERT(this->texelBufferSupport());
+ return fTexelBufferExtensionString;
+ }
+
+ const char* noperspectiveInterpolationExtensionString() const {
+ SkASSERT(this->noperspectiveInterpolationSupport());
+ return fNoPerspectiveInterpolationExtensionString;
+ }
+
+ const char* multisampleInterpolationExtensionString() const {
+ SkASSERT(this->multisampleInterpolationSupport());
+ return fMultisampleInterpolationExtensionString;
+ }
+
+ const char* sampleVariablesExtensionString() const {
+ SkASSERT(this->sampleVariablesSupport());
+ return fSampleVariablesExtensionString;
+ }
+
+ const char* imageLoadStoreExtensionString() const {
+ SkASSERT(this->imageLoadStoreSupport());
+ return fImageLoadStoreExtensionString;
+ }
+
+ int maxVertexSamplers() const { return fMaxVertexSamplers; }
+
+ int maxGeometrySamplers() const { return fMaxGeometrySamplers; }
+
+ int maxFragmentSamplers() const { return fMaxFragmentSamplers; }
+
+ int maxCombinedSamplers() const { return fMaxCombinedSamplers; }
+
+ int maxVertexImageStorages() const { return fMaxVertexImageStorages; }
+
+ int maxGeometryImageStorages() const { return fMaxGeometryImageStorages; }
+
+ int maxFragmentImageStorages() const { return fMaxFragmentImageStorages; }
+
+ int maxCombinedImageStorages() const { return fMaxCombinedImageStorages; }
+
+ /**
+ * Given a texture's config, this determines what swizzle must be appended to accesses to the
+ * texture in generated shader code. Swizzling may be implemented in texture parameters or a
+ * sampler rather than in the shader. In this case the returned swizzle will always be "rgba".
+ */
+ const GrSwizzle& configTextureSwizzle(GrPixelConfig config) const {
+ return fConfigTextureSwizzle[config];
+ }
+
+ /** Swizzle that should occur on the fragment shader outputs for a given config. */
+ const GrSwizzle& configOutputSwizzle(GrPixelConfig config) const {
+ return fConfigOutputSwizzle[config];
+ }
+
+ /** Precision qualifier that should be used with a sampler, given its config and visibility. */
+ GrSLPrecision samplerPrecision(GrPixelConfig config, GrShaderFlags visibility) const {
+ return static_cast<GrSLPrecision>(fSamplerPrecisions[visibility][config]);
+ }
+
+ GrGLSLGeneration generation() const { return fGLSLGeneration; }
+
+private:
+ /** GrCaps subclasses must call this after filling in the shader precision table. */
+ void initSamplerPrecisionTable();
+
+ void applyOptionsOverrides(const GrContextOptions& options);
+
+ GrGLSLGeneration fGLSLGeneration;
+
+ bool fShaderDerivativeSupport : 1;
+ bool fGeometryShaderSupport : 1;
+ bool fPathRenderingSupport : 1;
+ bool fDstReadInShaderSupport : 1;
+ bool fDualSourceBlendingSupport : 1;
+ bool fIntegerSupport : 1;
+ bool fTexelBufferSupport : 1;
+ bool fImageLoadStoreSupport : 1;
+ bool fPLSPathRenderingSupport : 1;
+ bool fShaderPrecisionVaries : 1;
+ bool fDropsTileOnZeroDivide : 1;
+ bool fFBFetchSupport : 1;
+ bool fFBFetchNeedsCustomOutput : 1;
+ bool fBindlessTextureSupport : 1;
+ bool fUsesPrecisionModifiers : 1;
+ bool fCanUseAnyFunctionInShader : 1;
+ bool fFlatInterpolationSupport : 1;
+ bool fNoPerspectiveInterpolationSupport : 1;
+ bool fMultisampleInterpolationSupport : 1;
+ bool fSampleVariablesSupport : 1;
+ bool fSampleMaskOverrideCoverageSupport : 1;
+ bool fExternalTextureSupport : 1;
+ bool fTexelFetchSupport : 1;
+
+ // Used for specific driver bug work arounds
+ bool fCanUseMinAndAbsTogether : 1;
+ bool fMustForceNegatedAtanParamToFloat : 1;
+ bool fRequiresLocalOutputColorForFBFetch : 1;
+
+ PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
+ int fPixelLocalStorageSize;
+
+ const char* fVersionDeclString;
+
+ const char* fShaderDerivativeExtensionString;
+ const char* fFragCoordConventionsExtensionString;
+ const char* fSecondaryOutputExtensionString;
+ const char* fExternalTextureExtensionString;
+ const char* fTexelBufferExtensionString;
+ const char* fNoPerspectiveInterpolationExtensionString;
+ const char* fMultisampleInterpolationExtensionString;
+ const char* fSampleVariablesExtensionString;
+ const char* fImageLoadStoreExtensionString;
+
+ const char* fFBFetchColorName;
+ const char* fFBFetchExtensionString;
+
+ int fMaxVertexSamplers;
+ int fMaxGeometrySamplers;
+ int fMaxFragmentSamplers;
+ int fMaxCombinedSamplers;
+
+ int fMaxVertexImageStorages;
+ int fMaxGeometryImageStorages;
+ int fMaxFragmentImageStorages;
+ int fMaxCombinedImageStorages;
+
+ AdvBlendEqInteraction fAdvBlendEqInteraction;
+
+ GrSwizzle fConfigTextureSwizzle[kGrPixelConfigCnt];
+ GrSwizzle fConfigOutputSwizzle[kGrPixelConfigCnt];
+
+ uint8_t fSamplerPrecisions[(1 << kGrShaderTypeCount)][kGrPixelConfigCnt];
+
+ friend class GrGLCaps; // For initialization.
+ friend class GrVkCaps;
+ friend class SkSL::GLSLCapsFactory;
+};
+
+#endif
#include "SkString.h"
#include "GrTypesPriv.h"
-class GrGLSLCaps;
+class GrShaderCaps;
#define USE_UNIFORM_FLOAT_ARRAYS true
/**
* Write a declaration of this variable to out.
*/
- void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const;
+ void appendDecl(const GrShaderCaps*, SkString* out) const;
void appendArrayAccess(int index, SkString* out) const {
out->appendf("%s[%d]%s",
SkString fExtraModifiers;
};
- #endif
+#endif
#include "GrTypes.h"
class GrShaderCaps;
-class GrGLSLCaps;
class GrGLSLXferProcessor;
class GrProcOptInfo;
struct GrPipelineOptimizations;
* Sets a unique key on the GrProcessorKeyBuilder calls onGetGLSLProcessorKey(...) to get the
* specific subclass's key.
*/
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const;
+ void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const;
/** Returns a new instance of the appropriate *GL* implementation class
for the given GrXferProcessor; caller is responsible for deleting
* Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this xfer
* processor's GL backend implementation.
*/
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
- GrProcessorKeyBuilder* b) const = 0;
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const = 0;
/**
* Determines the type of barrier (if any) required by the subclass. Note that the possibility
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
--- /dev/null
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSL_DEFINED
+#define GrGLSL_DEFINED
+
+#include "GrTypesPriv.h"
+#include "SkString.h"
+
+class GrShaderCaps;
+
+// Limited set of GLSL versions we build shaders for. Caller should round
+// down the GLSL version to one of these enums.
+enum GrGLSLGeneration {
+ /**
+ * Desktop GLSL 1.10 and ES2 shading language (based on desktop GLSL 1.20)
+ */
+ k110_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 1.30
+ */
+ k130_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 1.40
+ */
+ k140_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 1.50
+ */
+ k150_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 3.30, and ES GLSL 3.00
+ */
+ k330_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 4.00
+ */
+ k400_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 4.20
+ */
+ k420_GrGLSLGeneration,
+ /**
+ * ES GLSL 3.10 only TODO Make GLSLCap objects to make this more granular
+ */
+ k310es_GrGLSLGeneration,
+ /**
+ * ES GLSL 3.20
+ */
+ k320es_GrGLSLGeneration,
+};
+
+bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration);
+
+/**
+ * Adds a line of GLSL code to declare the default precision for float types.
+ */
+void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision,
+ const GrShaderCaps&,
+ SkString* out);
+
+/**
+ * Converts a GrSLPrecision to its corresponding GLSL precision qualifier.
+ */
+static inline const char* GrGLSLPrecisionString(GrSLPrecision p) {
+ switch (p) {
+ case kLow_GrSLPrecision:
+ return "lowp";
+ case kMedium_GrSLPrecision:
+ return "mediump";
+ case kHigh_GrSLPrecision:
+ return "highp";
+ default:
+ SkFAIL("Unexpected precision type.");
+ return "";
+ }
+}
+
+/**
+ * Converts a GrSLType to a string containing the name of the equivalent GLSL type.
+ */
+static inline const char* GrGLSLTypeString(GrSLType t) {
+ switch (t) {
+ case kVoid_GrSLType:
+ return "void";
+ case kFloat_GrSLType:
+ return "float";
+ case kVec2f_GrSLType:
+ return "vec2";
+ case kVec3f_GrSLType:
+ return "vec3";
+ case kVec4f_GrSLType:
+ return "vec4";
+ case kMat22f_GrSLType:
+ return "mat2";
+ case kMat33f_GrSLType:
+ return "mat3";
+ case kMat44f_GrSLType:
+ return "mat4";
+ case kTexture2DSampler_GrSLType:
+ return "sampler2D";
+ case kITexture2DSampler_GrSLType:
+ return "isampler2D";
+ case kTextureExternalSampler_GrSLType:
+ return "samplerExternalOES";
+ case kTexture2DRectSampler_GrSLType:
+ return "sampler2DRect";
+ case kBufferSampler_GrSLType:
+ return "samplerBuffer";
+ case kBool_GrSLType:
+ return "bool";
+ case kInt_GrSLType:
+ return "int";
+ case kUint_GrSLType:
+ return "uint";
+ case kTexture2D_GrSLType:
+ return "texture2D";
+ case kSampler_GrSLType:
+ return "sampler";
+ case kImageStorage2D_GrSLType:
+ return "image2D";
+ case kIImageStorage2D_GrSLType:
+ return "iimage2D";
+ }
+ SkFAIL("Unknown shader var type.");
+ return ""; // suppress warning
+}
+
+/** A generic base-class representing a GLSL expression.
+ * The instance can be a variable name, expression or vecN(0) or vecN(1). Does simple constant
+ * folding with help of 1 and 0.
+ *
+ * Clients should not use this class, rather the specific instantiations defined
+ * later, for example GrGLSLExpr4.
+ */
+template <typename Self>
+class GrGLSLExpr {
+public:
+ bool isOnes() const { return kOnes_ExprType == fType; }
+ bool isZeros() const { return kZeros_ExprType == fType; }
+
+ const char* c_str() const {
+ if (kZeros_ExprType == fType) {
+ return Self::ZerosStr();
+ } else if (kOnes_ExprType == fType) {
+ return Self::OnesStr();
+ }
+ SkASSERT(!fExpr.isEmpty()); // Empty expressions should not be used.
+ return fExpr.c_str();
+ }
+
+ bool isValid() const {
+ return kFullExpr_ExprType != fType || !fExpr.isEmpty();
+ }
+
+protected:
+ /** Constructs an invalid expression.
+ * Useful only as a return value from functions that never actually return
+ * this and instances that will be assigned to later. */
+ GrGLSLExpr()
+ : fType(kFullExpr_ExprType) {
+ // The only constructor that is allowed to build an empty expression.
+ SkASSERT(!this->isValid());
+ }
+
+ /** Constructs an expression with all components as value v */
+ explicit GrGLSLExpr(int v) {
+ if (v == 0) {
+ fType = kZeros_ExprType;
+ } else if (v == 1) {
+ fType = kOnes_ExprType;
+ } else {
+ fType = kFullExpr_ExprType;
+ fExpr.appendf(Self::CastIntStr(), v);
+ }
+ }
+
+ /** Constructs an expression from a string.
+ * Argument expr is a simple expression or a parenthesized expression. */
+ // TODO: make explicit once effects input Exprs.
+ GrGLSLExpr(const char expr[]) {
+ if (nullptr == expr) { // TODO: remove this once effects input Exprs.
+ fType = kOnes_ExprType;
+ } else {
+ fType = kFullExpr_ExprType;
+ fExpr = expr;
+ }
+ SkASSERT(this->isValid());
+ }
+
+ /** Constructs an expression from a string.
+ * Argument expr is a simple expression or a parenthesized expression. */
+ // TODO: make explicit once effects input Exprs.
+ GrGLSLExpr(const SkString& expr) {
+ if (expr.isEmpty()) { // TODO: remove this once effects input Exprs.
+ fType = kOnes_ExprType;
+ } else {
+ fType = kFullExpr_ExprType;
+ fExpr = expr;
+ }
+ SkASSERT(this->isValid());
+ }
+
+ /** Constructs an expression from a string with one substitution. */
+ GrGLSLExpr(const char format[], const char in0[])
+ : fType(kFullExpr_ExprType) {
+ fExpr.appendf(format, in0);
+ }
+
+ /** Constructs an expression from a string with two substitutions. */
+ GrGLSLExpr(const char format[], const char in0[], const char in1[])
+ : fType(kFullExpr_ExprType) {
+ fExpr.appendf(format, in0, in1);
+ }
+
+ /** Returns expression casted to another type.
+ * Generic implementation that is called for non-trivial cases of casts. */
+ template <typename T>
+ static Self VectorCastImpl(const T& other);
+
+ /** Returns a GLSL multiplication: component-wise or component-by-scalar.
+ * The multiplication will be component-wise or multiply each component by a scalar.
+ *
+ * The returned expression will compute the value of:
+ * vecN(in0.x * in1.x, ...) if dim(T0) == dim(T1) (component-wise)
+ * vecN(in0.x * in1, ...) if dim(T1) == 1 (vector by scalar)
+ * vecN(in0 * in1.x, ...) if dim(T0) == 1 (scalar by vector)
+ */
+ template <typename T0, typename T1>
+ static Self Mul(T0 in0, T1 in1);
+
+ /** Returns a GLSL addition: component-wise or add a scalar to each component.
+ * Return value computes:
+ * vecN(in0.x + in1.x, ...) or vecN(in0.x + in1, ...) or vecN(in0 + in1.x, ...).
+ */
+ template <typename T0, typename T1>
+ static Self Add(T0 in0, T1 in1);
+
+ /** Returns a GLSL subtraction: component-wise or subtract compoments by a scalar.
+ * Return value computes
+ * vecN(in0.x - in1.x, ...) or vecN(in0.x - in1, ...) or vecN(in0 - in1.x, ...).
+ */
+ template <typename T0, typename T1>
+ static Self Sub(T0 in0, T1 in1);
+
+ /** Returns expression that accesses component(s) of the expression.
+ * format should be the form "%s.x" where 'x' is the component(s) to access.
+ * Caller is responsible for making sure the amount of components in the
+ * format string is equal to dim(T).
+ */
+ template <typename T>
+ T extractComponents(const char format[]) const;
+
+private:
+ enum ExprType {
+ kZeros_ExprType,
+ kOnes_ExprType,
+ kFullExpr_ExprType,
+ };
+ ExprType fType;
+ SkString fExpr;
+};
+
+class GrGLSLExpr1;
+class GrGLSLExpr4;
+
+/** Class representing a float GLSL expression. */
+class GrGLSLExpr1 : public GrGLSLExpr<GrGLSLExpr1> {
+public:
+ GrGLSLExpr1()
+ : INHERITED() {
+ }
+ explicit GrGLSLExpr1(int v)
+ : INHERITED(v) {
+ }
+ GrGLSLExpr1(const char* expr)
+ : INHERITED(expr) {
+ }
+ GrGLSLExpr1(const SkString& expr)
+ : INHERITED(expr) {
+ }
+
+ static GrGLSLExpr1 VectorCast(const GrGLSLExpr1& expr);
+
+private:
+ GrGLSLExpr1(const char format[], const char in0[])
+ : INHERITED(format, in0) {
+ }
+ GrGLSLExpr1(const char format[], const char in0[], const char in1[])
+ : INHERITED(format, in0, in1) {
+ }
+
+ static const char* ZerosStr();
+ static const char* OnesStr();
+ static const char* CastStr();
+ static const char* CastIntStr();
+
+ friend GrGLSLExpr1 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr1&in1);
+ friend GrGLSLExpr1 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr1&in1);
+ friend GrGLSLExpr1 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr1&in1);
+
+ friend class GrGLSLExpr<GrGLSLExpr1>;
+ friend class GrGLSLExpr<GrGLSLExpr4>;
+
+ typedef GrGLSLExpr<GrGLSLExpr1> INHERITED;
+};
+
+/** Class representing a float vector (vec4) GLSL expression. */
+class GrGLSLExpr4 : public GrGLSLExpr<GrGLSLExpr4> {
+public:
+ GrGLSLExpr4()
+ : INHERITED() {
+ }
+ explicit GrGLSLExpr4(int v)
+ : INHERITED(v) {
+ }
+ GrGLSLExpr4(const char* expr)
+ : INHERITED(expr) {
+ }
+ GrGLSLExpr4(const SkString& expr)
+ : INHERITED(expr) {
+ }
+
+ typedef GrGLSLExpr1 AExpr;
+ AExpr a() const;
+
+ /** GLSL vec4 cast / constructor, eg vec4(floatv) -> vec4(floatv, floatv, floatv, floatv) */
+ static GrGLSLExpr4 VectorCast(const GrGLSLExpr1& expr);
+ static GrGLSLExpr4 VectorCast(const GrGLSLExpr4& expr);
+
+private:
+ GrGLSLExpr4(const char format[], const char in0[])
+ : INHERITED(format, in0) {
+ }
+ GrGLSLExpr4(const char format[], const char in0[], const char in1[])
+ : INHERITED(format, in0, in1) {
+ }
+
+ static const char* ZerosStr();
+ static const char* OnesStr();
+ static const char* CastStr();
+ static const char* CastIntStr();
+
+ // The vector-by-scalar and scalar-by-vector binary operations.
+ friend GrGLSLExpr4 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr4&in1);
+ friend GrGLSLExpr4 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr4&in1);
+ friend GrGLSLExpr4 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr4&in1);
+ friend GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr1&in1);
+ friend GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr1&in1);
+ friend GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr1&in1);
+
+ // The vector-by-vector, i.e. component-wise, binary operations.
+ friend GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr4&in1);
+ friend GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr4&in1);
+ friend GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr4&in1);
+
+ friend class GrGLSLExpr<GrGLSLExpr4>;
+
+ typedef GrGLSLExpr<GrGLSLExpr4> INHERITED;
+};
+
+/**
+ * Does an inplace mul, *=, of vec4VarName by mulFactor.
+ * A semicolon is added after the assignment.
+ */
+void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSLExpr4& mulFactor);
+
+#include "GrGLSL_impl.h"
+
+#endif
--- /dev/null
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSL_impl_DEFINED
+#define GrGLSL_impl_DEFINED
+
+template<typename Self>
+template<typename T>
+inline Self GrGLSLExpr<Self>::VectorCastImpl(const T& expr) {
+ if (expr.isZeros()) {
+ return Self(0);
+ }
+ if (expr.isOnes()) {
+ return Self(1);
+ }
+ return Self(Self::CastStr(), expr.c_str());
+}
+
+template<typename Self>
+template<typename T0, typename T1>
+inline Self GrGLSLExpr<Self>::Mul(T0 in0, T1 in1) {
+ if (in0.isZeros() || in1.isZeros()) {
+ return Self(0);
+ }
+ if (in0.isOnes()) {
+ return Self::VectorCast(in1);
+ }
+ if (in1.isOnes()) {
+ return Self::VectorCast(in0);
+ }
+ return Self("(%s * %s)", in0.c_str(), in1.c_str());
+}
+
+template<typename Self>
+template<typename T0, typename T1>
+inline Self GrGLSLExpr<Self>::Add(T0 in0, T1 in1) {
+ if (in1.isZeros()) {
+ return Self::VectorCast(in0);
+ }
+ if (in0.isZeros()) {
+ return Self::VectorCast(in1);
+ }
+ if (in0.isOnes() && in1.isOnes()) {
+ return Self(2);
+ }
+ return Self("(%s + %s)", in0.c_str(), in1.c_str());
+}
+
+template<typename Self>
+template<typename T0, typename T1>
+inline Self GrGLSLExpr<Self>::Sub(T0 in0, T1 in1) {
+ if (in1.isZeros()) {
+ return Self::VectorCast(in0);
+ }
+ if (in1.isOnes()) {
+ if (in0.isOnes()) {
+ return Self(0);
+ }
+ }
+
+ return Self("(%s - %s)", in0.c_str(), in1.c_str());
+}
+
+template <typename Self>
+template <typename T>
+T GrGLSLExpr<Self>::extractComponents(const char format[]) const {
+ if (this->isZeros()) {
+ return T(0);
+ }
+ if (this->isOnes()) {
+ return T(1);
+ }
+ return T(format, this->c_str());
+}
+
+inline GrGLSLExpr1 GrGLSLExpr1::VectorCast(const GrGLSLExpr1& expr) {
+ return expr;
+}
+
+inline const char* GrGLSLExpr1::ZerosStr() {
+ return "0";
+}
+
+inline const char* GrGLSLExpr1::OnesStr() {
+ return "1.0";
+}
+
+// GrGLSLExpr1::CastStr() is unimplemented because using them is likely an
+// error. This is now caught compile-time.
+
+inline const char* GrGLSLExpr1::CastIntStr() {
+ return "%d";
+}
+
+inline GrGLSLExpr1 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr1::Mul(in0, in1);
+}
+
+inline GrGLSLExpr1 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr1::Add(in0, in1);
+}
+
+inline GrGLSLExpr1 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr1::Sub(in0, in1);
+}
+
+inline const char* GrGLSLExpr4::ZerosStr() {
+ return "vec4(0)";
+}
+
+inline const char* GrGLSLExpr4::OnesStr() {
+ return "vec4(1)";
+}
+
+inline const char* GrGLSLExpr4::CastStr() {
+ return "vec4(%s)";
+}
+
+inline const char* GrGLSLExpr4::CastIntStr() {
+ return "vec4(%d)";
+}
+
+inline GrGLSLExpr4 GrGLSLExpr4::VectorCast(const GrGLSLExpr1& expr) {
+ return INHERITED::VectorCastImpl(expr);
+}
+
+inline GrGLSLExpr4 GrGLSLExpr4::VectorCast(const GrGLSLExpr4& expr) {
+ return expr;
+}
+
+inline GrGLSLExpr4::AExpr GrGLSLExpr4::a() const {
+ return this->extractComponents<GrGLSLExpr4::AExpr>("%s.a");
+}
+
+inline GrGLSLExpr4 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
+ return GrGLSLExpr4::Mul(in0, in1);
+}
+
+inline GrGLSLExpr4 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
+ return GrGLSLExpr4::Add(in0, in1);
+}
+
+inline GrGLSLExpr4 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
+ return GrGLSLExpr4::Sub(in0, in1);
+}
+
+inline GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr4::Mul(in0, in1);
+}
+
+inline GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr4::Add(in0, in1);
+}
+
+inline GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr4::Sub(in0, in1);
+}
+
+inline GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
+ return GrGLSLExpr4::Mul(in0, in1);
+}
+
+inline GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
+ return GrGLSLExpr4::Add(in0, in1);
+}
+
+inline GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
+ return GrGLSLExpr4::Sub(in0, in1);
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrSwizzle_DEFINED
+#define GrSwizzle_DEFINED
+
+#include "GrColor.h"
+#include "SkRandom.h"
+
+/** Represents a rgba swizzle. It can be converted either into a string or a eight bit int.
+ Currently there is no way to specify an arbitrary swizzle, just some static swizzles and an
+ assignment operator. That could be relaxed. */
+class GrSwizzle {
+private:
+ char fSwiz[5];
+ uint8_t fKey;
+
+ static constexpr int CToI(char c) {
+ return ('r' == c) ? (GrColor_SHIFT_R / 8) :
+ ('g' == c) ? (GrColor_SHIFT_G / 8) :
+ ('b' == c) ? (GrColor_SHIFT_B / 8) :
+ ('a' == c) ? (GrColor_SHIFT_A / 8) : -1;
+ }
+
+ static constexpr char IToC(int idx) {
+ return (8 * idx) == GrColor_SHIFT_R ? 'r' :
+ (8 * idx) == GrColor_SHIFT_G ? 'g' :
+ (8 * idx) == GrColor_SHIFT_B ? 'b' :
+ (8 * idx) == GrColor_SHIFT_A ? 'a' : 'x';
+ }
+
+ constexpr GrSwizzle(const char c[4])
+ : fSwiz{c[0], c[1], c[2], c[3], 0}
+ , fKey((CToI(c[0]) << 0) | (CToI(c[1]) << 2) | (CToI(c[2]) << 4) | (CToI(c[3]) << 6)) {}
+
+ GR_STATIC_ASSERT(sizeof(char[4]) == sizeof(uint32_t));
+ uint32_t* asUIntPtr() { return SkTCast<uint32_t*>(fSwiz); }
+ uint32_t asUInt() const { return *SkTCast<const uint32_t*>(fSwiz); }
+
+public:
+ GrSwizzle() { *this = RGBA(); }
+
+ GrSwizzle(const GrSwizzle& that) { *this = that; }
+
+ GrSwizzle& operator=(const GrSwizzle& that) {
+ memcpy(this, &that, sizeof(GrSwizzle));
+ return *this;
+ }
+
+ /** Recreates a GrSwizzle from the output of asKey() */
+ void setFromKey(uint8_t key) {
+ fKey = key;
+ for (int i = 0; i < 4; ++i) {
+ fSwiz[i] = IToC(key & 3);
+ key >>= 2;
+ }
+ SkASSERT(fSwiz[4] == 0);
+ }
+
+ bool operator==(const GrSwizzle& that) const { return this->asUInt() == that.asUInt(); }
+
+ bool operator!=(const GrSwizzle& that) const { return !(*this == that); }
+
+ /** Compact representation of the swizzle suitable for a key. */
+ uint8_t asKey() const { return fKey; }
+
+ /** 4 char null terminated string consisting only of chars 'r', 'g', 'b', 'a'. */
+ const char* c_str() const { return fSwiz; }
+
+ /** Applies this swizzle to the input color and returns the swizzled color. */
+ GrColor applyTo(GrColor color) const {
+ int idx;
+ uint32_t key = fKey;
+ // Index of the input color that should be mapped to output r.
+ idx = (key & 3);
+ uint32_t outR = (color >> idx * 8) & 0xFF;
+ key >>= 2;
+ idx = (key & 3);
+ uint32_t outG = (color >> idx * 8) & 0xFF;
+ key >>= 2;
+ idx = (key & 3);
+ uint32_t outB = (color >> idx * 8) & 0xFF;
+ key >>= 2;
+ idx = (key & 3);
+ uint32_t outA = (color >> idx * 8) & 0xFF;
+ return GrColorPackRGBA(outR, outG, outB, outA);
+ }
+
+ static GrSwizzle RGBA() { return GrSwizzle("rgba"); }
+ static GrSwizzle AAAA() { return GrSwizzle("aaaa"); }
+ static GrSwizzle RRRR() { return GrSwizzle("rrrr"); }
+ static GrSwizzle BGRA() { return GrSwizzle("bgra"); }
+
+ static GrSwizzle CreateRandom(SkRandom* random) {
+ switch (random->nextU() % 4) {
+ case 0:
+ return RGBA();
+ case 1:
+ return BGRA();
+ case 2:
+ return RRRR();
+ case 3:
+ return AAAA();
+ default:
+ SkFAIL("Mod is broken?!?");
+ return RGBA();
+ }
+ }
+};
+
+#endif
class GLSLProcessor : public GrGLSLFragmentProcessor {
public:
// this class always generates the same code.
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
void emitCode(EmitArgs& args) override {
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
return new GLSLProcessor;
}
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
"diffuseColor.a);", args.fOutputColor);
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
- GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
const LightingFP& lightingFP = proc.cast<LightingFP>();
b->add32(lightingFP.fDirectionalLights.count());
}
GrGLSLProgramDataManager::UniformHandle fAmbientColorUni;
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLLightingFP::GenKey(*this, caps, b);
}
fragBuilder->codeAppendf("%s = vec4(normal, 0.0);", args.fOutputColor);
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
- GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
const NormalBevelFP& fp = proc.cast<NormalBevelFP>();
b->add32(static_cast<int>(fp.fBevelType));
}
GrGLSLProgramDataManager::UniformHandle fNormalizedHeightUni;
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLNormalBevelFP::GenKey(*this, caps, b);
}
fragBuilder->codeAppendf("%s = vec4(0, 0, 1, 0);", args.fOutputColor);
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
- GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(0x0);
}
const GrProcessor& proc) override {}
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLNormalFlatFP::GenKey(*this, caps, b);
}
fragBuilder->codeAppend( "}");
}
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(0x0);
}
GrGLSLProgramDataManager::UniformHandle fXformUni;
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLNormalMapFP::GenKey(*this, caps, b);
}
fragBuilder->codeAppendf("%s = vec4(vec3(closestDistHere / 2.0),1);", args.fOutputColor);
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
b->add32(0); // nothing to add here
}
GrGLSLProgramDataManager::UniformHandle fHeightUni;
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLRadialShadowMapFP::GenKey(*this, caps, b);
}
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const ShadowFP& shadowFP = proc.cast<ShadowFP>();
b->add32(shadowFP.fNumNonAmbLights);
GrGLSLProgramDataManager::UniformHandle fAmbientColorUni;
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLShadowFP::GenKey(*this, caps, b);
}
#include "GrInvariantOutput.h"
#include "SkRefCnt.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::Make(
GrTexture* texture,
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&,
+ static inline void GenKey(const GrProcessor& effect, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrAlphaThresholdFragmentProcessor& atfp =
effect.cast<GrAlphaThresholdFragmentProcessor>();
///////////////////////////////////////////////////////////////////////////////
-void GrAlphaThresholdFragmentProcessor::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrAlphaThresholdFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLAlphaThresholdFragmentProcessor::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
return new GLSLProcessor;
}
-void GrCircleBlurFragmentProcessor::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrCircleBlurFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
// The code for this processor is always the same so there is nothing to add to the key.
return;
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrFragmentProcessor& other) const override {
const GrCircleBlurFragmentProcessor& cbfp = other.cast<GrCircleBlurFragmentProcessor>();
arith.enforcePMColor());
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>();
uint32_t key = arith.enforcePMColor() ? 1 : 0;
b->add32(key);
SkASSERT(0 == dstIndex);
}
-void GrArithmeticFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+void GrArithmeticFP::onGetGLSLProcessorKey(const GrShaderCaps& caps,
+ GrProcessorKeyBuilder* b) const {
GLArithmeticFP::GenKey(*this, caps, b);
}
GrColor* overrideColor,
const GrCaps& caps) const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrXferProcessor& xpBase) const override {
const ArithmeticXP& xp = xpBase.cast<ArithmeticXP>();
~GLArithmeticXP() override {}
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
+ static void GenKey(const GrProcessor& processor, const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) {
const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
uint32_t key = arith.enforcePMColor() ? 1 : 0;
this->initClassID<ArithmeticXP>();
}
-void ArithmeticXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+void ArithmeticXP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
GLArithmeticXP::GenKey(*this, caps, b);
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#include "GrTexture.h"
#include "GrFragmentProcessor.h"
#include "GrInvariantOutput.h"
+#include "GrShaderCaps.h"
#include "GrStyle.h"
#include "effects/GrSimpleTextureEffect.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
public:
void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder* b);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
}
-void GrGLRectBlurEffect::GenKey(const GrProcessor& proc, const GrGLSLCaps&,
+void GrGLRectBlurEffect::GenKey(const GrProcessor& proc, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>();
this->setWillReadFragmentPosition();
}
-void GrRectBlurEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrRectBlurEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLRectBlurEffect::GenKey(*this, caps, b);
}
GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture);
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrFragmentProcessor& other) const override;
pdman.set1f(fCornerRadiusUniform, radius);
}
-void GrRRectBlurEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrRRectBlurEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLRRectBlurEffect::GenKey(*this, caps, b);
}
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
};
private:
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
GrColorCubeEffect::~GrColorCubeEffect() {
}
-void GrColorCubeEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrColorCubeEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLSLProcessor::GenKey(*this, caps, b);
}
}
void GrColorCubeEffect::GLSLProcessor::GenKey(const GrProcessor& proc,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
}
sk_sp<GrFragmentProcessor> SkColorCubeFilter::asFragmentProcessor(GrContext* context,
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
return new GrGLDisplacementMapEffect;
}
-void GrDisplacementMapEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrDisplacementMapEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLDisplacementMapEffect::GenKey(*this, caps, b);
}
}
void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
uint32_t xKey = displacementMap.xChannelSelector();
}
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
- GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
// only one shader generated currently
b->add32(0x0);
}
bool fLargerBlur;
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLGaussianEdgeFP::GenKey(*this, caps, b);
}
#include "SkGrPriv.h"
#include "effects/GrSingleTextureEffect.h"
#include "effects/GrTextureDomain.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
class GrGLDiffuseLightingEffect;
class GrGLSpecularLightingEffect;
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
SkScalar shininess() const { return fShininess; }
private:
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder* b);
protected:
/**
return INHERITED::onIsEqual(sBase) && this->kd() == s.kd();
}
-void GrDiffuseLightingEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrDiffuseLightingEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLDiffuseLightingEffect::GenKey(*this, caps, b);
}
}
void GrGLLightingEffect::GenKey(const GrProcessor& proc,
- const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps& caps, GrProcessorKeyBuilder* b) {
const GrLightingEffect& lighting = proc.cast<GrLightingEffect>();
b->add32(lighting.boundaryMode() << 2 | lighting.light()->type());
b->add32(GrTextureDomain::GLDomain::DomainKey(lighting.domain()));
this->shininess() == s.shininess();
}
-void GrSpecularLightingEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrSpecularLightingEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLSpecularLightingEffect::GenKey(*this, caps, b);
}
class GLSLProcessor : public GrGLSLFragmentProcessor {
public:
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
void emitCode(EmitArgs& args) override {
if (nullptr == args.fInputColor) {
return new GLSLProcessor;
}
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
#include "GrContext.h"
#include "GrInvariantOutput.h"
#include "effects/GrSingleTextureEffect.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
class GrMagnifierEffect : public GrSingleTextureEffect {
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
/////////////////////////////////////////////////////////////////////
-void GrMagnifierEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrMagnifierEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLMagnifierEffect::GenKey(*this, caps, b);
}
#include "SkGr.h"
#include "SkGrPriv.h"
#include "effects/Gr1DKernelEffect.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
#endif
sk_sp<SkImageFilter> SkDilateImageFilter::Make(int radiusX, int radiusY,
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
}
void GrGLMorphologyEffect::GenKey(const GrProcessor& proc,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
uint32_t key = static_cast<uint32_t>(m.radius());
key |= (m.type() << 8);
GrMorphologyEffect::~GrMorphologyEffect() {
}
-void GrMorphologyEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrMorphologyEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLMorphologyEffect::GenKey(*this, caps, b);
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {}
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override;
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
return new GrGLPerlinNoise;
}
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GrGLPerlinNoise::GenKey(*this, caps, b);
}
args.fOutputColor, args.fOutputColor);
}
-void GrGLPerlinNoise::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GrGLPerlinNoise::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>();
args.fOutputColor, args.fInputColor);
}
- static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
- GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& proc, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
const RRectsGaussianEdgeFP& fp = proc.cast<RRectsGaussianEdgeFP>();
b->add32(fp.firstMode() | (fp.secondMode() << 4));
typedef GrGLSLFragmentProcessor INHERITED;
};
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLRRectsGaussianEdgeFP::GenKey(*this, caps, b);
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
public:
void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
}
}
-void ColorTableEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void ColorTableEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLColorTableEffect::GenKey(*this, caps, b);
}
#include "GrContext.h"
#include "GrInvariantOutput.h"
+#include "GrShaderCaps.h"
#include "GrTextureStripAtlas.h"
#include "gl/GrGLContext.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
- const GrGLSLCaps* glslCaps,
+ const GrShaderCaps* glslCaps,
const GrGradientEffect& ge,
const char* gradientTValue,
const char* outputColor,
// of hard stop gradients
void emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
- const GrGLSLCaps* caps,
+ const GrShaderCaps* caps,
const GrGradientEffect&,
const char* gradientTValue,
const char* outputColor,
#if SK_SUPPORT_GPU
#include "GrColorSpaceXform.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "SkGr.h"
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& processor, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
return new GrLinearGradient::GLSLLinearProcessor(*this);
}
-void GrLinearGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrLinearGradient::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrLinearGradient::GLSLLinearProcessor::GenKey(*this, caps, b);
}
#if SK_SUPPORT_GPU
#include "SkGr.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrRadialGradient : public GrGradientEffect {
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& processor, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
return new GrRadialGradient::GLSLRadialProcessor(*this);
}
-void GrRadialGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrRadialGradient::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrRadialGradient::GLSLRadialProcessor::GenKey(*this, caps, b);
}
#if SK_SUPPORT_GPU
#include "SkGr.h"
+#include "GrShaderCaps.h"
#include "gl/GrGLContext.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrSweepGradient : public GrGradientEffect {
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor& processor, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
return new GrSweepGradient::GLSLSweepProcessor(*this);
}
-void GrSweepGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrSweepGradient::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrSweepGradient::GLSLSweepProcessor::GenKey(*this, caps, b);
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
};
-void Edge2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void Edge2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(*this, caps, b);
}
}
void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(const GrProcessor& processor,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConicalEffect>();
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
};
-void FocalOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void FocalOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(*this, caps, b);
}
void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
uint32_t* key = b->add32n(2);
key[0] = GenBaseGradientKey(processor);
key[1] = processor.cast<FocalOutside2PtConicalEffect>().isFlipped();
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalEffect>();
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
};
-void FocalInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void FocalInside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(*this, caps, b);
}
void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
};
-void CircleInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void CircleInside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(*this, caps, b);
}
void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
const CircleOutside2PtConicalEffect& s = sBase.cast<CircleOutside2PtConicalEffect>();
virtual void emitCode(EmitArgs&) override;
- static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
};
-void CircleOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void CircleOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey(*this, caps, b);
}
void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
uint32_t* key = b->add32n(2);
key[0] = GenBaseGradientKey(processor);
key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped();
#include "GrContextOptions.h"
#include "GrWindowRectangles.h"
-GrShaderCaps::GrShaderCaps() {
- fShaderDerivativeSupport = false;
- fGeometryShaderSupport = false;
- fPathRenderingSupport = false;
- fDstReadInShaderSupport = false;
- fDualSourceBlendingSupport = false;
- fIntegerSupport = false;
- fTexelBufferSupport = false;
- fImageLoadStoreSupport = false;
- fShaderPrecisionVaries = false;
- fPLSPathRenderingSupport = false;
- fPixelLocalStorageSize = 0;
-}
-
-static const char* shader_type_to_string(GrShaderType type) {
- switch (type) {
- case kVertex_GrShaderType:
- return "vertex";
- case kGeometry_GrShaderType:
- return "geometry";
- case kFragment_GrShaderType:
- return "fragment";
- }
- return "";
-}
-
-static const char* precision_to_string(GrSLPrecision p) {
- switch (p) {
- case kLow_GrSLPrecision:
- return "low";
- case kMedium_GrSLPrecision:
- return "medium";
- case kHigh_GrSLPrecision:
- return "high";
- }
- return "";
-}
-
-SkString GrShaderCaps::dump() const {
- SkString r;
- static const char* gNY[] = { "NO", "YES" };
- r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
- r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
- r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]);
- r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]);
- r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]);
- r.appendf("Integer Support : %s\n", gNY[fIntegerSupport]);
- r.appendf("Texel Buffer Support : %s\n", gNY[fTexelBufferSupport]);
- r.appendf("Image Load Store Support : %s\n", gNY[fImageLoadStoreSupport]);
-
- r.appendf("Shader Float Precisions (varies: %s):\n", gNY[fShaderPrecisionVaries]);
-
- for (int s = 0; s < kGrShaderTypeCount; ++s) {
- GrShaderType shaderType = static_cast<GrShaderType>(s);
- r.appendf("\t%s:\n", shader_type_to_string(shaderType));
- for (int p = 0; p < kGrSLPrecisionCount; ++p) {
- if (fFloatPrecisions[s][p].supported()) {
- GrSLPrecision precision = static_cast<GrSLPrecision>(p);
- r.appendf("\t\t%s: log_low: %d log_high: %d bits: %d\n",
- precision_to_string(precision),
- fFloatPrecisions[s][p].fLogRangeLow,
- fFloatPrecisions[s][p].fLogRangeHigh,
- fFloatPrecisions[s][p].fBits);
- }
- }
- }
-
- return r;
-}
-
-void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) {
- fDualSourceBlendingSupport = fDualSourceBlendingSupport && !options.fSuppressDualSourceBlending;
- this->onApplyOptionsOverrides(options);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
GrCaps::GrCaps(const GrContextOptions& options) {
fMipMapSupport = false;
fNPOTTextureTileSupport = false;
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
uint32_t key = def.fFlags;
typedef GrGLSLGeometryProcessor INHERITED;
};
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
}
return new GLFP;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {}
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
return new GLFP;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {}
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
}
private:
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override
{}
bool onIsEqual(const GrFragmentProcessor& that) const override {
}
private:
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {}
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
#include "GrInvariantOutput.h"
#include "GrProcessor.h"
#include "GrResourceProvider.h"
+#include "GrShaderCaps.h"
#include "GrStyle.h"
#include "SkRRect.h"
#include "SkStrokeRec.h"
#include "batches/GrVertexBatch.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
const char* name() const override { return "CircleEdge"; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
}
}
static void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const CircleGeometryProcessor& cgp = gp.cast<CircleGeometryProcessor>();
uint16_t key;
const char* name() const override { return "EllipseEdge"; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
}
}
static void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const EllipseGeometryProcessor& egp = gp.cast<EllipseGeometryProcessor>();
uint16_t key = egp.fStroke ? 0x1 : 0x0;
const char* name() const override { return "DIEllipseEdge"; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
}
}
static void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const DIEllipseGeometryProcessor& diegp = gp.cast<DIEllipseGeometryProcessor>();
uint16_t key = static_cast<uint16_t>(diegp.fStyle);
#include "GrPathProcessor.h"
+#include "GrShaderCaps.h"
#include "gl/GrGLGpu.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLVarying.h"
GrGLPathProcessor() : fColor(GrColor_ILLEGAL) {}
static void GenKey(const GrPathProcessor& pathProc,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
b->add32(SkToInt(pathProc.overrides().readsColor()) |
(SkToInt(pathProc.overrides().readsCoverage()) << 1) |
this->initClassID<GrPathProcessor>();
}
-void GrPathProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrPathProcessor::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLPathProcessor::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrGLSLCaps& caps) const {
+GrGLSLPrimitiveProcessor* GrPathProcessor::createGLSLInstance(const GrShaderCaps& caps) const {
SkASSERT(caps.pathRenderingSupport());
return new GrGLPathProcessor();
}
bool willUseGeoShader() const override { return false; }
- virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override;
- virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const override;
+ virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
const GrXPOverridesForBatch& overrides() const { return fOverrides; }
#include "GrPathRendererChain.h"
#include "GrCaps.h"
+#include "GrShaderCaps.h"
#include "gl/GrGLCaps.h"
-#include "glsl/GrGLSLCaps.h"
#include "GrContext.h"
#include "GrGpu.h"
* it emits the appropriate color, or none at all, as directed.
*/
-class GrGLSLCaps;
class GrGLSLPrimitiveProcessor;
struct GrInitInvariantOutput;
*
* TODO: A better name for this function would be "compute" instead of "get".
*/
- virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
- GrProcessorKeyBuilder* b) const = 0;
+ virtual void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const = 0;
/** Returns a new instance of the appropriate *GL* implementation class
for the given GrProcessor; caller is responsible for deleting
the object. */
- virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const = 0;
+ virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const = 0;
virtual bool isPathRendering() const { return false; }
#include "GrProcessor.h"
#include "GrPipeline.h"
#include "GrRenderTargetPriv.h"
+#include "GrShaderCaps.h"
#include "GrTexturePriv.h"
#include "SkChecksum.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLCaps.h"
enum {
kSamplerOrImageTypeKeyBits = 4
}
static uint16_t sampler_key(GrSLType samplerType, GrPixelConfig config, GrShaderFlags visibility,
- const GrGLSLCaps& caps) {
+ const GrShaderCaps& caps) {
int samplerTypeKey = image_storage_or_sampler_uniform_type_key(samplerType);
GR_STATIC_ASSERT(1 == sizeof(caps.configTextureSwizzle(config).asKey()));
}
static void add_sampler_and_image_keys(GrProcessorKeyBuilder* b, const GrProcessor& proc,
- const GrGLSLCaps& caps) {
+ const GrShaderCaps& caps) {
int numTextureSamplers = proc.numTextureSamplers();
int numBuffers = proc.numBuffers();
int numImageStorages = proc.numImageStorages();
* function because it is hairy, though FPs do not have attribs, and GPs do not have transforms
*/
static bool gen_meta_key(const GrProcessor& proc,
- const GrGLSLCaps& glslCaps,
+ const GrShaderCaps& glslCaps,
uint32_t transformKey,
GrProcessorKeyBuilder* b) {
size_t processorKeySize = b->size();
static bool gen_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc,
const GrFragmentProcessor& fp,
- const GrGLSLCaps& glslCaps,
+ const GrShaderCaps& glslCaps,
GrProcessorKeyBuilder* b) {
for (int i = 0; i < fp.numChildProcessors(); ++i) {
if (!gen_frag_proc_and_meta_keys(primProc, fp.childProcessor(i), glslCaps, b)) {
const GrPrimitiveProcessor& primProc,
bool hasPointSize,
const GrPipeline& pipeline,
- const GrGLSLCaps& glslCaps) {
+ const GrShaderCaps& glslCaps) {
// The descriptor is used as a cache key. Thus when a field of the
// descriptor will not affect program generation (because of the attribute
// bindings in use or other descriptor field settings) it should be set
#include "SkOpts.h"
#include "SkTArray.h"
-class GrGLSLCaps;
+class GrShaderCaps;
class GrPipeline;
class GrPrimitiveProcessor;
* general draw information, as well as the specific color, geometry,
* and coverage stages which will be used to generate the GL Program for
* this optstate.
- * @param GrGLSLCaps Capabilities of the GLSL backend.
+ * @param GrShaderCaps Capabilities of the shading language.
* @param GrProgramDesc The built and finalized descriptor
**/
static bool Build(GrProgramDesc*,
const GrPrimitiveProcessor&,
bool hasPointSize,
const GrPipeline&,
- const GrGLSLCaps&);
+ const GrShaderCaps&);
// Returns this as a uint32_t array to be used as a key in the program cache.
const uint32_t* asKey() const {
}
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
- GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
+ const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.getColor(),
paint.usesDistanceVectorField(),
viewMatrix,
//}
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
- GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
+ const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawBatch> batch(CreateShadowRRectBatch(
paint.getColor(),
viewMatrix,
}
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
- GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
+ const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.getColor(),
viewMatrix,
oval,
const GrStyle& style) {
bool useHWAA;
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
- GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
+ const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawBatch> batch(GrOvalRenderer::CreateArcBatch(paint.getColor(),
viewMatrix,
oval,
bool isOval = path.isOval(&ovalRect);
if (isOval && !path.isInverseFillType()) {
- GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
+ const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.getColor(),
viewMatrix,
ovalRect,
--- /dev/null
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#include "GrShaderCaps.h"
+
+#include "GrContextOptions.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////
+
+static const char* shader_type_to_string(GrShaderType type) {
+ switch (type) {
+ case kVertex_GrShaderType:
+ return "vertex";
+ case kGeometry_GrShaderType:
+ return "geometry";
+ case kFragment_GrShaderType:
+ return "fragment";
+ }
+ return "";
+}
+
+static const char* precision_to_string(GrSLPrecision p) {
+ switch (p) {
+ case kLow_GrSLPrecision:
+ return "low";
+ case kMedium_GrSLPrecision:
+ return "medium";
+ case kHigh_GrSLPrecision:
+ return "high";
+ }
+ return "";
+}
+
+GrShaderCaps::GrShaderCaps(const GrContextOptions& options) {
+ fGLSLGeneration = k330_GrGLSLGeneration;
+ fShaderDerivativeSupport = false;
+ fGeometryShaderSupport = false;
+ fPathRenderingSupport = false;
+ fDstReadInShaderSupport = false;
+ fDualSourceBlendingSupport = false;
+ fIntegerSupport = false;
+ fTexelBufferSupport = false;
+ fImageLoadStoreSupport = false;
+ fShaderPrecisionVaries = false;
+ fPLSPathRenderingSupport = false;
+ fDropsTileOnZeroDivide = false;
+ fFBFetchSupport = false;
+ fFBFetchNeedsCustomOutput = false;
+ fBindlessTextureSupport = false;
+ fUsesPrecisionModifiers = false;
+ fCanUseAnyFunctionInShader = true;
+ fCanUseMinAndAbsTogether = true;
+ fMustForceNegatedAtanParamToFloat = false;
+ fRequiresLocalOutputColorForFBFetch = false;
+ fFlatInterpolationSupport = false;
+ fNoPerspectiveInterpolationSupport = false;
+ fMultisampleInterpolationSupport = false;
+ fSampleVariablesSupport = false;
+ fSampleMaskOverrideCoverageSupport = false;
+ fExternalTextureSupport = false;
+ fTexelFetchSupport = false;
+
+ fPixelLocalStorageSize = 0;
+
+ fVersionDeclString = nullptr;
+ fShaderDerivativeExtensionString = nullptr;
+ fFragCoordConventionsExtensionString = nullptr;
+ fSecondaryOutputExtensionString = nullptr;
+ fExternalTextureExtensionString = nullptr;
+ fTexelBufferExtensionString = nullptr;
+ fNoPerspectiveInterpolationExtensionString = nullptr;
+ fMultisampleInterpolationExtensionString = nullptr;
+ fSampleVariablesExtensionString = nullptr;
+ fFBFetchColorName = nullptr;
+ fFBFetchExtensionString = nullptr;
+ fImageLoadStoreExtensionString = nullptr;
+ fMaxVertexSamplers = 0;
+ fMaxGeometrySamplers = 0;
+ fMaxFragmentSamplers = 0;
+ fMaxCombinedSamplers = 0;
+ fMaxVertexImageStorages = 0;
+ fMaxGeometryImageStorages = 0;
+ fMaxFragmentImageStorages = 0;
+ fMaxCombinedImageStorages = 0;
+ fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
+}
+
+SkString GrShaderCaps::dump() const {
+ SkString r;
+ static const char* gNY[] = { "NO", "YES" };
+ r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
+ r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
+ r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]);
+ r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]);
+ r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]);
+ r.appendf("Integer Support : %s\n", gNY[fIntegerSupport]);
+ r.appendf("Texel Buffer Support : %s\n", gNY[fTexelBufferSupport]);
+ r.appendf("Image Load Store Support : %s\n", gNY[fImageLoadStoreSupport]);
+
+ r.appendf("Shader Float Precisions (varies: %s):\n", gNY[fShaderPrecisionVaries]);
+
+ for (int s = 0; s < kGrShaderTypeCount; ++s) {
+ GrShaderType shaderType = static_cast<GrShaderType>(s);
+ r.appendf("\t%s:\n", shader_type_to_string(shaderType));
+ for (int p = 0; p < kGrSLPrecisionCount; ++p) {
+ if (fFloatPrecisions[s][p].supported()) {
+ GrSLPrecision precision = static_cast<GrSLPrecision>(p);
+ r.appendf("\t\t%s: log_low: %d log_high: %d bits: %d\n",
+ precision_to_string(precision),
+ fFloatPrecisions[s][p].fLogRangeLow,
+ fFloatPrecisions[s][p].fLogRangeHigh,
+ fFloatPrecisions[s][p].fBits);
+ }
+ }
+ }
+
+ static const char* kAdvBlendEqInteractionStr[] = {
+ "Not Supported",
+ "Automatic",
+ "General Enable",
+ "Specific Enables",
+ };
+ GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction);
+ GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction);
+ GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction);
+ GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction);
+ GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlendEqInteraction + 1);
+
+ r.appendf("--- GLSL-Specific ---\n");
+
+ r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
+ r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
+ r.appendf("Bindless texture support: %s\n", (fBindlessTextureSupport ? "YES" : "NO"));
+ r.appendf("Uses precision modifiers: %s\n", (fUsesPrecisionModifiers ? "YES" : "NO"));
+ r.appendf("Can use any() function: %s\n", (fCanUseAnyFunctionInShader ? "YES" : "NO"));
+ r.appendf("Can use min() and abs() together: %s\n", (fCanUseMinAndAbsTogether ? "YES" : "NO"));
+ r.appendf("Must force negated atan param to float: %s\n", (fMustForceNegatedAtanParamToFloat ?
+ "YES" : "NO"));
+ r.appendf("Must use local out color for FBFetch: %s\n", (fRequiresLocalOutputColorForFBFetch ?
+ "YES" : "NO"));
+ r.appendf("Flat interpolation support: %s\n", (fFlatInterpolationSupport ? "YES" : "NO"));
+ r.appendf("No perspective interpolation support: %s\n", (fNoPerspectiveInterpolationSupport ?
+ "YES" : "NO"));
+ r.appendf("Multisample interpolation support: %s\n", (fMultisampleInterpolationSupport ?
+ "YES" : "NO"));
+ r.appendf("Sample variables support: %s\n", (fSampleVariablesSupport ? "YES" : "NO"));
+ r.appendf("Sample mask override coverage support: %s\n", (fSampleMaskOverrideCoverageSupport ?
+ "YES" : "NO"));
+ r.appendf("External texture support: %s\n", (fExternalTextureSupport ? "YES" : "NO"));
+ r.appendf("texelFetch support: %s\n", (fTexelFetchSupport ? "YES" : "NO"));
+ r.appendf("Max VS Samplers: %d\n", fMaxVertexSamplers);
+ r.appendf("Max GS Samplers: %d\n", fMaxGeometrySamplers);
+ r.appendf("Max FS Samplers: %d\n", fMaxFragmentSamplers);
+ r.appendf("Max Combined Samplers: %d\n", fMaxFragmentSamplers);
+ r.appendf("Max VS Image Storages: %d\n", fMaxVertexImageStorages);
+ r.appendf("Max GS Image Storages: %d\n", fMaxGeometryImageStorages);
+ r.appendf("Max FS Image Storages: %d\n", fMaxFragmentImageStorages);
+ r.appendf("Max Combined Image Storages: %d\n", fMaxFragmentImageStorages);
+ r.appendf("Advanced blend equation interaction: %s\n",
+ kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]);
+ return r;
+}
+
+void GrShaderCaps::initSamplerPrecisionTable() {
+ // Determine the largest precision qualifiers that are effectively the same as lowp/mediump.
+ // e.g. if lowp == mediump, then use mediump instead of lowp.
+ GrSLPrecision effectiveMediumP[kGrShaderTypeCount];
+ GrSLPrecision effectiveLowP[kGrShaderTypeCount];
+ for (int s = 0; s < kGrShaderTypeCount; ++s) {
+ const PrecisionInfo* info = fFloatPrecisions[s];
+ effectiveMediumP[s] = info[kHigh_GrSLPrecision] == info[kMedium_GrSLPrecision] ?
+ kHigh_GrSLPrecision : kMedium_GrSLPrecision;
+ effectiveLowP[s] = info[kMedium_GrSLPrecision] == info[kLow_GrSLPrecision] ?
+ effectiveMediumP[s] : kLow_GrSLPrecision;
+ }
+
+ // Determine which precision qualifiers should be used with samplers.
+ for (int visibility = 0; visibility < (1 << kGrShaderTypeCount); ++visibility) {
+ GrSLPrecision mediump = kHigh_GrSLPrecision;
+ GrSLPrecision lowp = kHigh_GrSLPrecision;
+ for (int s = 0; s < kGrShaderTypeCount; ++s) {
+ if (visibility & (1 << s)) {
+ mediump = SkTMin(mediump, effectiveMediumP[s]);
+ lowp = SkTMin(lowp, effectiveLowP[s]);
+ }
+
+ GR_STATIC_ASSERT(0 == kLow_GrSLPrecision);
+ GR_STATIC_ASSERT(1 == kMedium_GrSLPrecision);
+ GR_STATIC_ASSERT(2 == kHigh_GrSLPrecision);
+
+ GR_STATIC_ASSERT((1 << kVertex_GrShaderType) == kVertex_GrShaderFlag);
+ GR_STATIC_ASSERT((1 << kGeometry_GrShaderType) == kGeometry_GrShaderFlag);
+ GR_STATIC_ASSERT((1 << kFragment_GrShaderType) == kFragment_GrShaderFlag);
+ GR_STATIC_ASSERT(3 == kGrShaderTypeCount);
+ }
+
+ uint8_t* table = fSamplerPrecisions[visibility];
+ table[kUnknown_GrPixelConfig] = kDefault_GrSLPrecision;
+ table[kAlpha_8_GrPixelConfig] = lowp;
+ table[kIndex_8_GrPixelConfig] = lowp;
+ table[kRGB_565_GrPixelConfig] = lowp;
+ table[kRGBA_4444_GrPixelConfig] = lowp;
+ table[kRGBA_8888_GrPixelConfig] = lowp;
+ table[kBGRA_8888_GrPixelConfig] = lowp;
+ table[kSRGBA_8888_GrPixelConfig] = lowp;
+ table[kSBGRA_8888_GrPixelConfig] = lowp;
+ table[kRGBA_8888_sint_GrPixelConfig] = lowp;
+ table[kETC1_GrPixelConfig] = lowp;
+ table[kLATC_GrPixelConfig] = lowp;
+ table[kR11_EAC_GrPixelConfig] = lowp;
+ table[kASTC_12x12_GrPixelConfig] = lowp;
+ table[kRGBA_float_GrPixelConfig] = kHigh_GrSLPrecision;
+ table[kAlpha_half_GrPixelConfig] = mediump;
+ table[kRGBA_half_GrPixelConfig] = mediump;
+
+ GR_STATIC_ASSERT(17 == kGrPixelConfigCnt);
+ }
+}
+
+void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) {
+ fDualSourceBlendingSupport = fDualSourceBlendingSupport && !options.fSuppressDualSourceBlending;
+}
#include "GrShaderVar.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
static const char* type_modifier_string(GrShaderVar::TypeModifier t) {
switch (t) {
SkFAIL("Unknown io type.");
}
-void GrShaderVar::appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
+void GrShaderVar::appendDecl(const GrShaderCaps* glslCaps, SkString* out) const {
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
SkString layout = fLayoutQualifier;
if (!fLayoutQualifier.isEmpty()) {
+++ /dev/null
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrSwizzle_DEFINED
-#define GrSwizzle_DEFINED
-
-#include "GrColor.h"
-#include "SkRandom.h"
-
-/** Represents a rgba swizzle. It can be converted either into a string or a eight bit int.
- Currently there is no way to specify an arbitrary swizzle, just some static swizzles and an
- assignment operator. That could be relaxed. */
-class GrSwizzle {
-private:
- char fSwiz[5];
- uint8_t fKey;
-
- static constexpr int CToI(char c) {
- return ('r' == c) ? (GrColor_SHIFT_R / 8) :
- ('g' == c) ? (GrColor_SHIFT_G / 8) :
- ('b' == c) ? (GrColor_SHIFT_B / 8) :
- ('a' == c) ? (GrColor_SHIFT_A / 8) : -1;
- }
-
- static constexpr char IToC(int idx) {
- return (8 * idx) == GrColor_SHIFT_R ? 'r' :
- (8 * idx) == GrColor_SHIFT_G ? 'g' :
- (8 * idx) == GrColor_SHIFT_B ? 'b' :
- (8 * idx) == GrColor_SHIFT_A ? 'a' : 'x';
- }
-
- constexpr GrSwizzle(const char c[4])
- : fSwiz{c[0], c[1], c[2], c[3], 0}
- , fKey((CToI(c[0]) << 0) | (CToI(c[1]) << 2) | (CToI(c[2]) << 4) | (CToI(c[3]) << 6)) {}
-
- GR_STATIC_ASSERT(sizeof(char[4]) == sizeof(uint32_t));
- uint32_t* asUIntPtr() { return SkTCast<uint32_t*>(fSwiz); }
- uint32_t asUInt() const { return *SkTCast<const uint32_t*>(fSwiz); }
-
-public:
- GrSwizzle() { *this = RGBA(); }
-
- GrSwizzle(const GrSwizzle& that) { *this = that; }
-
- GrSwizzle& operator=(const GrSwizzle& that) {
- memcpy(this, &that, sizeof(GrSwizzle));
- return *this;
- }
-
- /** Recreates a GrSwizzle from the output of asKey() */
- void setFromKey(uint8_t key) {
- fKey = key;
- for (int i = 0; i < 4; ++i) {
- fSwiz[i] = IToC(key & 3);
- key >>= 2;
- }
- SkASSERT(fSwiz[4] == 0);
- }
-
- bool operator==(const GrSwizzle& that) const { return this->asUInt() == that.asUInt(); }
-
- bool operator!=(const GrSwizzle& that) const { return !(*this == that); }
-
- /** Compact representation of the swizzle suitable for a key. */
- uint8_t asKey() const { return fKey; }
-
- /** 4 char null terminated string consisting only of chars 'r', 'g', 'b', 'a'. */
- const char* c_str() const { return fSwiz; }
-
- /** Applies this swizzle to the input color and returns the swizzled color. */
- GrColor applyTo(GrColor color) const {
- int idx;
- uint32_t key = fKey;
- // Index of the input color that should be mapped to output r.
- idx = (key & 3);
- uint32_t outR = (color >> idx * 8) & 0xFF;
- key >>= 2;
- idx = (key & 3);
- uint32_t outG = (color >> idx * 8) & 0xFF;
- key >>= 2;
- idx = (key & 3);
- uint32_t outB = (color >> idx * 8) & 0xFF;
- key >>= 2;
- idx = (key & 3);
- uint32_t outA = (color >> idx * 8) & 0xFF;
- return GrColorPackRGBA(outR, outG, outB, outA);
- }
-
- static GrSwizzle RGBA() { return GrSwizzle("rgba"); }
- static GrSwizzle AAAA() { return GrSwizzle("aaaa"); }
- static GrSwizzle RRRR() { return GrSwizzle("rrrr"); }
- static GrSwizzle BGRA() { return GrSwizzle("bgra"); }
-
- static GrSwizzle CreateRandom(SkRandom* random) {
- switch (random->nextU() % 4) {
- case 0:
- return RGBA();
- case 1:
- return BGRA();
- case 2:
- return RRRR();
- case 3:
- return AAAA();
- default:
- SkFAIL("Mod is broken?!?");
- return RGBA();
- }
- }
-};
-
-#endif
}
}
-void GrXferProcessor::getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+void GrXferProcessor::getGLSLProcessorKey(const GrShaderCaps& caps,
+ GrProcessorKeyBuilder* b) const {
uint32_t key = this->willReadDstColor() ? 0x1 : 0x0;
if (key) {
if (const GrTexture* dstTexture = this->getDstTexture()) {
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>();
uint32_t key = 0;
typedef GrGLSLGeometryProcessor INHERITED;
};
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
}
}
static void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
b->add32(0x0);
}
typedef GrGLSLGeometryProcessor INHERITED;
};
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor();
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const MSAAQuadProcessor& qp = gp.cast<MSAAQuadProcessor>();
uint32_t key = 0;
UniformHandle fViewMatrixUniform;
};
- virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor(*this);
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const PLSAATriangleEffect& te = gp.cast<PLSAATriangleEffect>();
uint32_t key = 0;
typedef GrGLSLGeometryProcessor INHERITED;
};
- virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor(*this);
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const PLSQuadEdgeEffect& qee = gp.cast<PLSQuadEdgeEffect>();
uint32_t key = 0;
typedef GrGLSLGeometryProcessor INHERITED;
};
- virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor(*this);
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const PLSFinishEffect& fe = gp.cast<PLSFinishEffect>();
uint32_t key = 0;
typedef GrGLSLGeometryProcessor INHERITED;
};
- virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GLSLProcessor::GenKey(*this, caps, b);
}
- virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
return new GLSLProcessor(*this);
}
#include "GrBezierEffect.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
void onEmitCode(EmitArgs&, GrGPArgs*) override;
static inline void GenKey(const GrGeometryProcessor&,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder*);
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
}
void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrConicEffect& ce = gp.cast<GrConicEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
GrConicEffect::~GrConicEffect() {}
-void GrConicEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrConicEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLConicEffect::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrConicEffect::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* GrConicEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLConicEffect(*this);
}
void onEmitCode(EmitArgs&, GrGPArgs*) override;
static inline void GenKey(const GrGeometryProcessor&,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder*);
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
}
void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrQuadEffect& ce = gp.cast<GrQuadEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
GrQuadEffect::~GrQuadEffect() {}
-void GrQuadEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrQuadEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLQuadEffect::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrQuadEffect::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* GrQuadEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLQuadEffect(*this);
}
void onEmitCode(EmitArgs&, GrGPArgs*) override;
static inline void GenKey(const GrGeometryProcessor&,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder*);
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
}
void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrCubicEffect& ce = gp.cast<GrCubicEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
GrCubicEffect::~GrCubicEffect() {}
-void GrCubicEffect::getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+void GrCubicEffect::getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
GrGLCubicEffect::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrCubicEffect::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* GrCubicEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLCubicEffect(*this);
}
bool usesLocalCoords() const { return fUsesLocalCoords; }
uint8_t coverageScale() const { return fCoverageScale; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
GrConicEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimitiveEdgeType,
bool usesLocalCoords() const { return fUsesLocalCoords; }
uint8_t coverageScale() const { return fCoverageScale; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
GrQuadEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimitiveEdgeType,
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
GrCubicEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType);
#include "GrBicubicEffect.h"
#include "GrInvariantOutput.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
#define DS(x) SkDoubleToScalar(x)
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&,
+ static inline void GenKey(const GrProcessor& effect, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrBicubicEffect& bicubicEffect = effect.cast<GrBicubicEffect>();
b->add32(GrTextureDomain::GLDomain::DomainKey(bicubicEffect.domain()));
GrBicubicEffect::~GrBicubicEffect() {
}
-void GrBicubicEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrBicubicEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLBicubicEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
}
static inline void GenKey(const GrGeometryProcessor& proc,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
uint32_t key = 0;
this->addTextureSampler(&fTextureSampler);
}
-void GrBitmapTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrBitmapTextGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLBitmapTextGeoProc::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrGLSLCaps& caps) const {
+GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrShaderCaps& caps) const {
return new GrGLBitmapTextGeoProc();
}
const SkMatrix& localMatrix() const { return fLocalMatrix; }
bool usesLocalCoords() const { return fUsesLocalCoords; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
private:
GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrSamplerParams& params,
#include "GrInvariantOutput.h"
#include "GrSimpleTextureEffect.h"
#include "SkMatrix.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "../private/GrGLSL.h"
class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor {
public:
fragBuilder->codeAppend(modulate.c_str());
}
- static inline void GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+ static inline void GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrConfigConversionEffect& cce = processor.cast<GrConfigConversionEffect>();
uint32_t key = (cce.swizzle().asKey()) | (cce.pmConversion() << 16);
///////////////////////////////////////////////////////////////////////////////
-void GrConfigConversionEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrConfigConversionEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLConfigConversionEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
}
}
-void GrConstColorProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&,
+void GrConstColorProcessor::onGetGLSLProcessorKey(const GrShaderCaps&,
GrProcessorKeyBuilder* b) const {
b->add32(fMode);
}
#include "GrInvariantOutput.h"
#include "SkPathPriv.h"
#include "effects/GrConstColorProcessor.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
//////////////////////////////////////////////////////////////////////////////
class AARectEffect : public GrFragmentProcessor {
const char* name() const override { return "AARect"; }
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
private:
AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect)
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
}
}
-void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GLAARectEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const AARectEffect& aare = processor.cast<AARectEffect>();
b->add32(aare.getEdgeType());
}
-void AARectEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+void AARectEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
GLAARectEffect::GenKey(*this, caps, b);
}
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
}
}
-void GrGLConvexPolyEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GrGLConvexPolyEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrConvexPolyEffect& cpe = processor.cast<GrConvexPolyEffect>();
GR_STATIC_ASSERT(kGrProcessorEdgeTypeCnt <= 8);
inout->mulByUnknownSingleComponent();
}
-void GrConvexPolyEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrConvexPolyEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLConvexPolyEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& other) const override;
*/
#include "GrConvolutionEffect.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
// For brevity
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&) override;
pdman.set4fv(fKernelUni, arrayCount, conv.kernel());
}
-void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>();
uint32_t key = conv.radius();
GrConvolutionEffect::~GrConvolutionEffect() {
}
-void GrConvolutionEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrConvolutionEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLConvolutionEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
GrColor* color,
const GrCaps& caps) const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override;
~GLCoverageSetOpXP() override {}
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
+ static void GenKey(const GrProcessor& processor, const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) {
const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>();
uint32_t key = xp.invertCoverage() ? 0x0 : 0x1;
CoverageSetOpXP::~CoverageSetOpXP() {
}
-void CoverageSetOpXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void CoverageSetOpXP::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLCoverageSetOpXP::GenKey(*this, caps, b);
}
return GrXferProcessor::kIgnoreColor_OptFlag;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrXferProcessor& xpBase) const override {
const ShaderCSOXferProcessor& xp = xpBase.cast<ShaderCSOXferProcessor>();
///////////////////////////////////////////////////////////////////////////////
-void ShaderCSOXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&,
+void ShaderCSOXferProcessor::onGetGLSLProcessorKey(const GrShaderCaps&,
GrProcessorKeyBuilder* b) const {
GLShaderCSOXferProcessor::GenKey(*this, b);
}
#include "GrInvariantOutput.h"
#include "GrPipeline.h"
#include "GrProcessor.h"
+#include "GrShaderCaps.h"
#include "GrTexture.h"
#include "glsl/GrGLSLBlend.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
GrColor* overrideColor,
const GrCaps& caps) const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
GrXferBarrierType onXferBarrier(const GrRenderTarget*, const GrCaps&) const override;
GLCustomXP(const GrXferProcessor&) {}
~GLCustomXP() override {}
- static void GenKey(const GrXferProcessor& p, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrXferProcessor& p, const GrShaderCaps& caps,
+ GrProcessorKeyBuilder* b) {
const CustomXP& xp = p.cast<CustomXP>();
uint32_t key = 0;
if (xp.hasHWBlendEquation()) {
SkASSERT(caps.advBlendEqInteraction() > 0); // 0 will mean !xp.hasHWBlendEquation().
key |= caps.advBlendEqInteraction();
- GR_STATIC_ASSERT(GrGLSLCaps::kLast_AdvBlendEqInteraction < 4);
+ GR_STATIC_ASSERT(GrShaderCaps::kLast_AdvBlendEqInteraction < 4);
}
if (!xp.hasHWBlendEquation() || caps.mustEnableSpecificAdvBlendEqs()) {
key |= (int)xp.mode() << 3;
///////////////////////////////////////////////////////////////////////////////
-void CustomXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+void CustomXP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
GLCustomXP::GenKey(*this, caps, b);
}
bool usesLocalCoords() const { return fUsesLocalCoords; }
- void getGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
DashingCircleEffect(GrColor, AAMode aaMode, const SkMatrix& localMatrix,
void onEmitCode(EmitArgs&, GrGPArgs*) override;
static inline void GenKey(const GrGeometryProcessor&,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder*);
void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&,
}
void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const DashingCircleEffect& dce = gp.cast<DashingCircleEffect>();
uint32_t key = 0;
new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords));
}
-void DashingCircleEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void DashingCircleEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLDashingCircleEffect::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* DashingCircleEffect::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* DashingCircleEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GLDashingCircleEffect();
}
bool usesLocalCoords() const { return fUsesLocalCoords; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
DashingLineEffect(GrColor, AAMode aaMode, const SkMatrix& localMatrix,
void onEmitCode(EmitArgs&, GrGPArgs*) override;
static inline void GenKey(const GrGeometryProcessor&,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder*);
void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&,
}
void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const DashingLineEffect& de = gp.cast<DashingLineEffect>();
uint32_t key = 0;
new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords));
}
-void DashingLineEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void DashingLineEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLDashingLineEffect::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* DashingLineEffect::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* DashingLineEffect::createGLSLInstance(const GrShaderCaps&) const {
return new GLDashingLineEffect();
}
return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreCoverage_OptFlag;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override;
~GLDisableColorXP() override {}
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
private:
void emitOutputsForBlendState(const EmitArgs& args) override {
this->initClassID<DisableColorXP>();
}
-void DisableColorXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
+void DisableColorXP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
GLDisableColorXP::GenKey(*this, caps, b);
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrDistanceFieldA8TextGeoProc& dfTexEffect = gp.cast<GrDistanceFieldA8TextGeoProc>();
uint32_t key = dfTexEffect.getFlags();
this->addTextureSampler(&fTextureSampler);
}
-void GrDistanceFieldA8TextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrDistanceFieldA8TextGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLDistanceFieldA8TextGeoProc::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrDistanceFieldA8TextGeoProc::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor*
+GrDistanceFieldA8TextGeoProc::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLDistanceFieldA8TextGeoProc();
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrDistanceFieldPathGeoProc& dfTexEffect = gp.cast<GrDistanceFieldPathGeoProc>();
this->addTextureSampler(&fTextureSampler);
}
-void GrDistanceFieldPathGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrDistanceFieldPathGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLDistanceFieldPathGeoProc::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrDistanceFieldPathGeoProc::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor*
+GrDistanceFieldPathGeoProc::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLDistanceFieldPathGeoProc();
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrDistanceFieldLCDTextGeoProc& dfTexEffect = gp.cast<GrDistanceFieldLCDTextGeoProc>();
this->addTextureSampler(&fTextureSampler);
}
-void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLDistanceFieldLCDTextGeoProc();
}
#endif
uint32_t getFlags() const { return fFlags; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix,
uint32_t getFlags() const { return fFlags; }
bool usesLocalCoords() const { return fUsesLocalCoords; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* texture,
uint32_t getFlags() const { return fFlags; }
bool usesLocalCoords() const { return fUsesLocalCoords; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix,
#include "GrFragmentProcessor.h"
#include "GrInvariantOutput.h"
#include "SkRect.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "../private/GrGLSL.h"
//////////////////////////////////////////////////////////////////////////////
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
// All dither effects are equal
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
//////////////////////////////////////////////////////////////////////////////
-void DitherEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void DitherEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLDitherEffect::GenKey(*this, caps, b);
}
}
}
- static inline void GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+ static inline void GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrGammaEffect& ge = processor.cast<GrGammaEffect>();
uint32_t key = static_cast<uint32_t>(ge.mode());
///////////////////////////////////////////////////////////////////////////////
-void GrGammaEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
- GrProcessorKeyBuilder* b) const {
+void GrGammaEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
+ GrProcessorKeyBuilder* b) const {
GrGLGammaEffect::GenKey(*this, caps, b);
}
GrGammaEffect(Mode mode, SkScalar gamma);
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
* found in the LICENSE file.
*/
#include "GrMatrixConvolutionEffect.h"
-#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
class GrGLMatrixConvolutionEffect : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
}
void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
- const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ const GrShaderCaps&, GrProcessorKeyBuilder* b) {
const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffect>();
SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFFFF);
uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height();
fKernelOffset[1] = static_cast<float>(kernelOffset.y());
}
-void GrMatrixConvolutionEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrMatrixConvolutionEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLMatrixConvolutionEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#include "GrFragmentProcessor.h"
#include "GrInvariantOutput.h"
#include "SkRect.h"
-#include "glsl/GrGLSL.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "../private/GrGLSL.h"
//////////////////////////////////////////////////////////////////////////////
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
virtual void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("d")).c_str());
}
-void GLCircleEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GLCircleEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const CircleEffect& ce = processor.cast<CircleEffect>();
b->add32(ce.getEdgeType());
///////////////////////////////////////////////////////////////////////////////////////////////////
-void CircleEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void CircleEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLCircleEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLEllipseEffect::GenKey(const GrProcessor& effect, const GrGLSLCaps&,
+void GLEllipseEffect::GenKey(const GrProcessor& effect, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const EllipseEffect& ee = effect.cast<EllipseEffect>();
b->add32(ee.getEdgeType());
///////////////////////////////////////////////////////////////////////////////////////////////////
-void EllipseEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void EllipseEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLEllipseEffect::GenKey(*this, caps, b);
}
GrColor* overrideColor,
const GrCaps& caps) const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onHasSecondaryOutput() const override { return fBlendFormula.hasSecondaryOutput(); }
///////////////////////////////////////////////////////////////////////////////
-void PorterDuffXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&,
+void PorterDuffXferProcessor::onGetGLSLProcessorKey(const GrShaderCaps&,
GrProcessorKeyBuilder* b) const {
GLPorterDuffXferProcessor::GenKey(*this, b);
}
return kNone_OptFlags;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
bool onIsEqual(const GrXferProcessor& xpBase) const override {
const ShaderPDXferProcessor& xp = xpBase.cast<ShaderPDXferProcessor>();
///////////////////////////////////////////////////////////////////////////////
-void ShaderPDXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&,
+void ShaderPDXferProcessor::onGetGLSLProcessorKey(const GrShaderCaps&,
GrProcessorKeyBuilder* b) const {
GLShaderPDXferProcessor::GenKey(*this, b);
}
GrColor* overrideColor,
const GrCaps& caps) const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override {
blendInfo->fSrcBlend = kConstC_GrBlendCoeff;
virtual ~GLPDLCDXferProcessor() {}
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
+ static void GenKey(const GrProcessor& processor, const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) {}
private:
PDLCDXferProcessor::~PDLCDXferProcessor() {
}
-void PDLCDXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void PDLCDXferProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLPDLCDXferProcessor::GenKey(*this, caps, b);
}
#include "GrFragmentProcessor.h"
#include "GrInvariantOutput.h"
#include "GrOvalEffect.h"
+#include "GrShaderCaps.h"
#include "SkRRect.h"
#include "SkTLazy.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& other) const override;
virtual void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLCircularRRectEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
+void GLCircularRRectEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>();
GR_STATIC_ASSERT(kGrProcessorEdgeTypeCnt <= 8);
////////////////////////////////////////////////////////////////////////////////////////////////////
-void CircularRRectEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void CircularRRectEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLCircularRRectEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& other) const override;
void emitCode(EmitArgs&) override;
- static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*);
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLEllipticalRRectEffect::GenKey(const GrProcessor& effect, const GrGLSLCaps&,
+void GLEllipticalRRectEffect::GenKey(const GrProcessor& effect, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
GR_STATIC_ASSERT(kLast_GrProcessorEdgeType < (1 << 3));
////////////////////////////////////////////////////////////////////////////////////////////////////
-void EllipticalRRectEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void EllipticalRRectEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GLEllipticalRRectEffect::GenKey(*this, caps, b);
}
}
static inline void GenKey(const GrGeometryProcessor& gp,
- const GrGLSLCaps&,
+ const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrRRectShadowGeoProc& rsgp = gp.cast<GrRRectShadowGeoProc>();
uint16_t key;
fInShadowParams = &this->addVertexAttrib("inShadowParams", kVec4f_GrVertexAttribType);
}
-void GrRRectShadowGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrRRectShadowGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLSLRRectShadowGeoProc::GenKey(*this, caps, b);
}
-GrGLSLPrimitiveProcessor* GrRRectShadowGeoProc::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* GrRRectShadowGeoProc::createGLSLInstance(const GrShaderCaps&) const {
return new GrGLSLRRectShadowGeoProc();
}
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
- void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override;
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
GrRRectShadowGeoProc(const SkMatrix& localMatrix);
fragBuilder->codeAppend(";");
}
- static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&,
+ static inline void GenKey(const GrProcessor& effect, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrSimpleTextureEffect& textureEffect = effect.cast<GrSimpleTextureEffect>();
b->add32(GrColorSpaceXform::XformKey(textureEffect.colorSpaceXform()));
this->updateInvariantOutputForModulation(inout);
}
-void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLSimpleTextureEffect::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
#include "GrTextureDomain.h"
#include "GrInvariantOutput.h"
+#include "GrShaderCaps.h"
#include "GrSimpleTextureEffect.h"
#include "SkFloatingPoint.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
GrGLSLUniformHandler* uniformHandler,
- const GrGLSLCaps* glslCaps,
+ const GrShaderCaps* glslCaps,
const GrTextureDomain& textureDomain,
const char* outColor,
const SkString& inCoords,
this->initClassID<GrTextureDomainEffect>();
}
-void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
b->add32(GrTextureDomain::GLDomain::DomainKey(fTextureDomain));
}
*/
void sampleTexture(GrGLSLShaderBuilder* builder,
GrGLSLUniformHandler* uniformHandler,
- const GrGLSLCaps* glslCaps,
+ const GrShaderCaps* glslCaps,
const GrTextureDomain& textureDomain,
const char* outColor,
const SkString& inCoords,
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
// Since we always use decal mode, there is no need for key data.
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {}
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor& fp) const override;
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
const char* name() const override { return "ComposeTwo"; }
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
b->add32((int)fMode);
}
return str;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GR_STATIC_ASSERT(((int)SkBlendMode::kLastMode & SK_MaxU16) == (int)SkBlendMode::kLastMode);
b->add32((int)fMode | (fChild << 16));
}
return new GLSLProcessor;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
b->add32(fNV12);
}
return new GLSLProcessor;
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
// kY, kU, and kV all generate the same code, just upload different coefficients.
if (kU_OutputChannels == fOutputChannels || kV_OutputChannels == fOutputChannels) {
b->add32(kY_OutputChannels);
#include "GrContextOptions.h"
#include "GrGLContext.h"
#include "GrGLRenderTarget.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "instanced/GLInstancedRendering.h"
#include "SkTSearch.h"
#include "SkTSort.h"
fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag;
- fShaderCaps.reset(new GrGLSLCaps(contextOptions));
+ fShaderCaps.reset(new GrShaderCaps(contextOptions));
this->init(contextOptions, ctxInfo, glInterface);
}
// This must be called after fCoreProfile is set on the GrGLCaps
this->initGLSL(ctxInfo);
- GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
+ GrShaderCaps* glslCaps = static_cast<GrShaderCaps*>(fShaderCaps.get());
glslCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli);
* Caps specific to GrGLSLCaps
**************************************************************************/
- GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
+ GrShaderCaps* glslCaps = fShaderCaps.get();
glslCaps->fGLSLGeneration = ctxInfo.glslGeneration();
if (kGLES_GrGLStandard == standard) {
if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
}
void GrGLCaps::initBlendEqationSupport(const GrGLContextInfo& ctxInfo) {
- GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
+ GrShaderCaps* glslCaps = static_cast<GrShaderCaps*>(fShaderCaps.get());
// Disabling advanced blend on various platforms with major known issues. We also block Chrome
// for now until its own blacklists can be updated.
if (ctxInfo.hasExtension("GL_NV_blend_equation_advanced_coherent")) {
fBlendEquationSupport = kAdvancedCoherent_BlendEquationSupport;
- glslCaps->fAdvBlendEqInteraction = GrGLSLCaps::kAutomatic_AdvBlendEqInteraction;
+ glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kAutomatic_AdvBlendEqInteraction;
} else if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced_coherent")) {
fBlendEquationSupport = kAdvancedCoherent_BlendEquationSupport;
- glslCaps->fAdvBlendEqInteraction = GrGLSLCaps::kGeneralEnable_AdvBlendEqInteraction;
+ glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kGeneralEnable_AdvBlendEqInteraction;
} else if (kNVIDIA_GrGLDriver == ctxInfo.driver() &&
ctxInfo.driverVersion() < GR_GL_DRIVER_VER(337,00)) {
// Non-coherent advanced blend has an issue on NVIDIA pre 337.00.
return;
} else if (ctxInfo.hasExtension("GL_NV_blend_equation_advanced")) {
fBlendEquationSupport = kAdvanced_BlendEquationSupport;
- glslCaps->fAdvBlendEqInteraction = GrGLSLCaps::kAutomatic_AdvBlendEqInteraction;
+ glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kAutomatic_AdvBlendEqInteraction;
} else if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced")) {
fBlendEquationSupport = kAdvanced_BlendEquationSupport;
- glslCaps->fAdvBlendEqInteraction = GrGLSLCaps::kGeneralEnable_AdvBlendEqInteraction;
+ glslCaps->fAdvBlendEqInteraction = GrShaderCaps::kGeneralEnable_AdvBlendEqInteraction;
// TODO: Use kSpecificEnables_AdvBlendEqInteraction if "blend_support_all_equations" is
// slow on a particular platform.
} else {
void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
const GrGLInterface* intf,
- GrGLSLCaps* glslCaps) {
+ GrShaderCaps* glslCaps) {
if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4, 1) ||
ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
for (int s = 0; s < kGrShaderTypeCount; ++s) {
}
void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli,
- GrGLSLCaps* glslCaps) {
+ GrShaderCaps* glslCaps) {
/*
Comments on renderability of configs on various GL versions.
OpenGL < 3.0:
#include <functional>
-#include "glsl/GrGLSL.h"
#include "GrCaps.h"
#include "GrGLStencilAttachment.h"
#include "GrSwizzle.h"
#include "SkChecksum.h"
#include "SkTHash.h"
#include "SkTArray.h"
+#include "../private/GrGLSL.h"
class GrGLContextInfo;
-class GrGLSLCaps;
class GrGLRenderTarget;
/**
return fRGBAToBGRAReadbackConversionsAreSlow;
}
- const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
+ const GrShaderCaps* glslCaps() const { return fShaderCaps.get(); }
private:
enum ExternalFormatUsage {
void initBlendEqationSupport(const GrGLContextInfo&);
void initStencilFormats(const GrGLContextInfo&);
// This must be called after initFSAASupport().
- void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps);
+ void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrShaderCaps* glslCaps);
void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
const GrGLInterface* intf,
- GrGLSLCaps* glslCaps);
+ GrShaderCaps* glslCaps);
GrGLStandard fStandard;
* found in the LICENSE file.
*/
-#include "GrGLGLSL.h"
#include "GrGLContext.h"
#include "GrGLUtil.h"
#include "SkString.h"
+#include "../private/GrGLSL.h"
bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
SkASSERT(generation);
#define GrGLInitGLSL_DEFINED
#include "gl/GrGLInterface.h"
-#include "glsl/GrGLSL.h"
#include "GrColor.h"
#include "GrTypesPriv.h"
#include "SkString.h"
+#include "../private/GrGLSL.h"
class GrGLContextInfo;
#include "GrGLGpu.h"
#include "GrGLBuffer.h"
-#include "GrGLGLSL.h"
#include "GrGLGpuCommandBuffer.h"
#include "GrGLStencilAttachment.h"
#include "GrGLTextureRenderTarget.h"
#include "GrPipeline.h"
#include "GrPLSGeometryProcessor.h"
#include "GrRenderTargetPriv.h"
+#include "GrShaderCaps.h"
#include "GrSurfacePriv.h"
#include "GrTexturePriv.h"
#include "GrTypes.h"
#include "builders/GrGLShaderStringBuilder.h"
-#include "glsl/GrGLSL.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLPLSPathRendering.h"
#include "instanced/GLInstancedRendering.h"
#include "SkMakeUnique.h"
#include "SkStrokeRec.h"
#include "SkTemplates.h"
#include "SkTypes.h"
+#include "../private/GrGLSL.h"
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X)
return false;
}
- const GrGLSLCaps* glslCaps = this->glCaps().glslCaps();
+ const GrShaderCaps* glslCaps = this->glCaps().glslCaps();
const char* version = glslCaps->versionDeclString();
GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
int progIdx = TextureToCopyProgramIdx(srcTex);
- const GrGLSLCaps* glslCaps = this->glCaps().glslCaps();
+ const GrShaderCaps* glslCaps = this->glCaps().glslCaps();
GrSLType samplerType = srcTex->texturePriv().samplerType();
if (!fCopyProgramArrayBuffer) {
const bool oddHeight = SkToBool(progIdx & 0x1);
const int numTaps = (oddWidth ? 2 : 1) * (oddHeight ? 2 : 1);
- const GrGLSLCaps* glslCaps = this->glCaps().glslCaps();
+ const GrShaderCaps* glslCaps = this->glCaps().glslCaps();
SkASSERT(!fMipmapPrograms[progIdx].fProgram);
GL_CALL_RET(fMipmapPrograms[progIdx].fProgram, CreateProgram());
#include "GrGLTexture.h"
#include "GrGLGpu.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "SkTraceMemoryDump.h"
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
void GrGLUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString* out) const {
for (int i = 0; i < fUniforms.count(); ++i) {
if (fUniforms[i].fVisibility & visibility) {
- fUniforms[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
+ fUniforms[i].fVariable.appendDecl(fProgramBuilder->shaderCaps(), out);
out->append(";");
}
}
for (int i = 0; i < fSamplers.count(); ++i) {
if (fSamplers[i].fVisibility & visibility) {
- fSamplers[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
+ fSamplers[i].fVariable.appendDecl(fProgramBuilder->shaderCaps(), out);
out->append(";\n");
}
}
for (int i = 0; i < fImageStorages.count(); ++i) {
if (fImageStorages[i].fVisibility & visibility) {
- fImageStorages[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
+ fImageStorages[i].fVariable.appendDecl(fProgramBuilder->shaderCaps(), out);
out->append(";");
}
}
#include "GrCoordTransform.h"
#include "GrGLProgramBuilder.h"
#include "GrProgramDesc.h"
+#include "GrShaderCaps.h"
#include "GrSwizzle.h"
#include "GrTexture.h"
#include "SkTraceEvent.h"
#include "gl/GrGLProgram.h"
#include "gl/GrGLSLPrettyPrint.h"
#include "gl/builders/GrGLShaderStringBuilder.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
return fGpu->caps();
}
-const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const {
- return fGpu->ctxInfo().caps()->glslCaps();
-}
-
bool GrGLProgramBuilder::compileAndAttachShaders(GrGLSLShaderBuilder& shader,
GrGLuint programId,
GrGLenum type,
class GrGLContextInfo;
class GrProgramDesc;
class GrGLSLShaderBuilder;
-class GrGLSLCaps;
+class GrShaderCaps;
class GrGLProgramBuilder : public GrGLSLProgramBuilder {
public:
GrGLGpu*);
const GrCaps* caps() const override;
- const GrGLSLCaps* glslCaps() const override;
GrGLGpu* gpu() const { return fGpu; }
* found in the LICENSE file.
*/
-#include "GrGLSL.h"
-#include "GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "SkString.h"
+#include "../private/GrGLSL.h"
bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) {
switch (gen) {
}
void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p,
- const GrGLSLCaps& glslCaps,
+ const GrShaderCaps& glslCaps,
SkString* out) {
if (glslCaps.usesPrecisionModifiers()) {
switch (p) {
+++ /dev/null
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLSL_DEFINED
-#define GrGLSL_DEFINED
-
-#include "GrTypesPriv.h"
-#include "SkString.h"
-
-class GrGLSLCaps;
-
-// Limited set of GLSL versions we build shaders for. Caller should round
-// down the GLSL version to one of these enums.
-enum GrGLSLGeneration {
- /**
- * Desktop GLSL 1.10 and ES2 shading language (based on desktop GLSL 1.20)
- */
- k110_GrGLSLGeneration,
- /**
- * Desktop GLSL 1.30
- */
- k130_GrGLSLGeneration,
- /**
- * Desktop GLSL 1.40
- */
- k140_GrGLSLGeneration,
- /**
- * Desktop GLSL 1.50
- */
- k150_GrGLSLGeneration,
- /**
- * Desktop GLSL 3.30, and ES GLSL 3.00
- */
- k330_GrGLSLGeneration,
- /**
- * Desktop GLSL 4.00
- */
- k400_GrGLSLGeneration,
- /**
- * Desktop GLSL 4.20
- */
- k420_GrGLSLGeneration,
- /**
- * ES GLSL 3.10 only TODO Make GLSLCap objects to make this more granular
- */
- k310es_GrGLSLGeneration,
- /**
- * ES GLSL 3.20
- */
- k320es_GrGLSLGeneration,
-};
-
-bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration);
-
-/**
- * Adds a line of GLSL code to declare the default precision for float types.
- */
-void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision,
- const GrGLSLCaps& glslCaps,
- SkString* out);
-
-/**
- * Converts a GrSLPrecision to its corresponding GLSL precision qualifier.
- */
-static inline const char* GrGLSLPrecisionString(GrSLPrecision p) {
- switch (p) {
- case kLow_GrSLPrecision:
- return "lowp";
- case kMedium_GrSLPrecision:
- return "mediump";
- case kHigh_GrSLPrecision:
- return "highp";
- default:
- SkFAIL("Unexpected precision type.");
- return "";
- }
-}
-
-/**
- * Converts a GrSLType to a string containing the name of the equivalent GLSL type.
- */
-static inline const char* GrGLSLTypeString(GrSLType t) {
- switch (t) {
- case kVoid_GrSLType:
- return "void";
- case kFloat_GrSLType:
- return "float";
- case kVec2f_GrSLType:
- return "vec2";
- case kVec3f_GrSLType:
- return "vec3";
- case kVec4f_GrSLType:
- return "vec4";
- case kMat22f_GrSLType:
- return "mat2";
- case kMat33f_GrSLType:
- return "mat3";
- case kMat44f_GrSLType:
- return "mat4";
- case kTexture2DSampler_GrSLType:
- return "sampler2D";
- case kITexture2DSampler_GrSLType:
- return "isampler2D";
- case kTextureExternalSampler_GrSLType:
- return "samplerExternalOES";
- case kTexture2DRectSampler_GrSLType:
- return "sampler2DRect";
- case kBufferSampler_GrSLType:
- return "samplerBuffer";
- case kBool_GrSLType:
- return "bool";
- case kInt_GrSLType:
- return "int";
- case kUint_GrSLType:
- return "uint";
- case kTexture2D_GrSLType:
- return "texture2D";
- case kSampler_GrSLType:
- return "sampler";
- case kImageStorage2D_GrSLType:
- return "image2D";
- case kIImageStorage2D_GrSLType:
- return "iimage2D";
- }
- SkFAIL("Unknown shader var type.");
- return ""; // suppress warning
-}
-
-/** A generic base-class representing a GLSL expression.
- * The instance can be a variable name, expression or vecN(0) or vecN(1). Does simple constant
- * folding with help of 1 and 0.
- *
- * Clients should not use this class, rather the specific instantiations defined
- * later, for example GrGLSLExpr4.
- */
-template <typename Self>
-class GrGLSLExpr {
-public:
- bool isOnes() const { return kOnes_ExprType == fType; }
- bool isZeros() const { return kZeros_ExprType == fType; }
-
- const char* c_str() const {
- if (kZeros_ExprType == fType) {
- return Self::ZerosStr();
- } else if (kOnes_ExprType == fType) {
- return Self::OnesStr();
- }
- SkASSERT(!fExpr.isEmpty()); // Empty expressions should not be used.
- return fExpr.c_str();
- }
-
- bool isValid() const {
- return kFullExpr_ExprType != fType || !fExpr.isEmpty();
- }
-
-protected:
- /** Constructs an invalid expression.
- * Useful only as a return value from functions that never actually return
- * this and instances that will be assigned to later. */
- GrGLSLExpr()
- : fType(kFullExpr_ExprType) {
- // The only constructor that is allowed to build an empty expression.
- SkASSERT(!this->isValid());
- }
-
- /** Constructs an expression with all components as value v */
- explicit GrGLSLExpr(int v) {
- if (v == 0) {
- fType = kZeros_ExprType;
- } else if (v == 1) {
- fType = kOnes_ExprType;
- } else {
- fType = kFullExpr_ExprType;
- fExpr.appendf(Self::CastIntStr(), v);
- }
- }
-
- /** Constructs an expression from a string.
- * Argument expr is a simple expression or a parenthesized expression. */
- // TODO: make explicit once effects input Exprs.
- GrGLSLExpr(const char expr[]) {
- if (nullptr == expr) { // TODO: remove this once effects input Exprs.
- fType = kOnes_ExprType;
- } else {
- fType = kFullExpr_ExprType;
- fExpr = expr;
- }
- SkASSERT(this->isValid());
- }
-
- /** Constructs an expression from a string.
- * Argument expr is a simple expression or a parenthesized expression. */
- // TODO: make explicit once effects input Exprs.
- GrGLSLExpr(const SkString& expr) {
- if (expr.isEmpty()) { // TODO: remove this once effects input Exprs.
- fType = kOnes_ExprType;
- } else {
- fType = kFullExpr_ExprType;
- fExpr = expr;
- }
- SkASSERT(this->isValid());
- }
-
- /** Constructs an expression from a string with one substitution. */
- GrGLSLExpr(const char format[], const char in0[])
- : fType(kFullExpr_ExprType) {
- fExpr.appendf(format, in0);
- }
-
- /** Constructs an expression from a string with two substitutions. */
- GrGLSLExpr(const char format[], const char in0[], const char in1[])
- : fType(kFullExpr_ExprType) {
- fExpr.appendf(format, in0, in1);
- }
-
- /** Returns expression casted to another type.
- * Generic implementation that is called for non-trivial cases of casts. */
- template <typename T>
- static Self VectorCastImpl(const T& other);
-
- /** Returns a GLSL multiplication: component-wise or component-by-scalar.
- * The multiplication will be component-wise or multiply each component by a scalar.
- *
- * The returned expression will compute the value of:
- * vecN(in0.x * in1.x, ...) if dim(T0) == dim(T1) (component-wise)
- * vecN(in0.x * in1, ...) if dim(T1) == 1 (vector by scalar)
- * vecN(in0 * in1.x, ...) if dim(T0) == 1 (scalar by vector)
- */
- template <typename T0, typename T1>
- static Self Mul(T0 in0, T1 in1);
-
- /** Returns a GLSL addition: component-wise or add a scalar to each component.
- * Return value computes:
- * vecN(in0.x + in1.x, ...) or vecN(in0.x + in1, ...) or vecN(in0 + in1.x, ...).
- */
- template <typename T0, typename T1>
- static Self Add(T0 in0, T1 in1);
-
- /** Returns a GLSL subtraction: component-wise or subtract compoments by a scalar.
- * Return value computes
- * vecN(in0.x - in1.x, ...) or vecN(in0.x - in1, ...) or vecN(in0 - in1.x, ...).
- */
- template <typename T0, typename T1>
- static Self Sub(T0 in0, T1 in1);
-
- /** Returns expression that accesses component(s) of the expression.
- * format should be the form "%s.x" where 'x' is the component(s) to access.
- * Caller is responsible for making sure the amount of components in the
- * format string is equal to dim(T).
- */
- template <typename T>
- T extractComponents(const char format[]) const;
-
-private:
- enum ExprType {
- kZeros_ExprType,
- kOnes_ExprType,
- kFullExpr_ExprType,
- };
- ExprType fType;
- SkString fExpr;
-};
-
-class GrGLSLExpr1;
-class GrGLSLExpr4;
-
-/** Class representing a float GLSL expression. */
-class GrGLSLExpr1 : public GrGLSLExpr<GrGLSLExpr1> {
-public:
- GrGLSLExpr1()
- : INHERITED() {
- }
- explicit GrGLSLExpr1(int v)
- : INHERITED(v) {
- }
- GrGLSLExpr1(const char* expr)
- : INHERITED(expr) {
- }
- GrGLSLExpr1(const SkString& expr)
- : INHERITED(expr) {
- }
-
- static GrGLSLExpr1 VectorCast(const GrGLSLExpr1& expr);
-
-private:
- GrGLSLExpr1(const char format[], const char in0[])
- : INHERITED(format, in0) {
- }
- GrGLSLExpr1(const char format[], const char in0[], const char in1[])
- : INHERITED(format, in0, in1) {
- }
-
- static const char* ZerosStr();
- static const char* OnesStr();
- static const char* CastStr();
- static const char* CastIntStr();
-
- friend GrGLSLExpr1 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr1&in1);
- friend GrGLSLExpr1 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr1&in1);
- friend GrGLSLExpr1 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr1&in1);
-
- friend class GrGLSLExpr<GrGLSLExpr1>;
- friend class GrGLSLExpr<GrGLSLExpr4>;
-
- typedef GrGLSLExpr<GrGLSLExpr1> INHERITED;
-};
-
-/** Class representing a float vector (vec4) GLSL expression. */
-class GrGLSLExpr4 : public GrGLSLExpr<GrGLSLExpr4> {
-public:
- GrGLSLExpr4()
- : INHERITED() {
- }
- explicit GrGLSLExpr4(int v)
- : INHERITED(v) {
- }
- GrGLSLExpr4(const char* expr)
- : INHERITED(expr) {
- }
- GrGLSLExpr4(const SkString& expr)
- : INHERITED(expr) {
- }
-
- typedef GrGLSLExpr1 AExpr;
- AExpr a() const;
-
- /** GLSL vec4 cast / constructor, eg vec4(floatv) -> vec4(floatv, floatv, floatv, floatv) */
- static GrGLSLExpr4 VectorCast(const GrGLSLExpr1& expr);
- static GrGLSLExpr4 VectorCast(const GrGLSLExpr4& expr);
-
-private:
- GrGLSLExpr4(const char format[], const char in0[])
- : INHERITED(format, in0) {
- }
- GrGLSLExpr4(const char format[], const char in0[], const char in1[])
- : INHERITED(format, in0, in1) {
- }
-
- static const char* ZerosStr();
- static const char* OnesStr();
- static const char* CastStr();
- static const char* CastIntStr();
-
- // The vector-by-scalar and scalar-by-vector binary operations.
- friend GrGLSLExpr4 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr4&in1);
- friend GrGLSLExpr4 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr4&in1);
- friend GrGLSLExpr4 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr4&in1);
- friend GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr1&in1);
- friend GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr1&in1);
- friend GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr1&in1);
-
- // The vector-by-vector, i.e. component-wise, binary operations.
- friend GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr4&in1);
- friend GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr4&in1);
- friend GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr4&in1);
-
- friend class GrGLSLExpr<GrGLSLExpr4>;
-
- typedef GrGLSLExpr<GrGLSLExpr4> INHERITED;
-};
-
-/**
- * Does an inplace mul, *=, of vec4VarName by mulFactor.
- * A semicolon is added after the assignment.
- */
-void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSLExpr4& mulFactor);
-
-#include "GrGLSL_impl.h"
-
-#endif
+++ /dev/null
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#include "GrGLSLCaps.h"
-
-#include "GrContextOptions.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////
-
-GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
- fGLSLGeneration = k330_GrGLSLGeneration;
-
- fDropsTileOnZeroDivide = false;
- fFBFetchSupport = false;
- fFBFetchNeedsCustomOutput = false;
- fBindlessTextureSupport = false;
- fUsesPrecisionModifiers = false;
- fCanUseAnyFunctionInShader = true;
- fCanUseMinAndAbsTogether = true;
- fMustForceNegatedAtanParamToFloat = false;
- fRequiresLocalOutputColorForFBFetch = false;
- fFlatInterpolationSupport = false;
- fNoPerspectiveInterpolationSupport = false;
- fMultisampleInterpolationSupport = false;
- fSampleVariablesSupport = false;
- fSampleMaskOverrideCoverageSupport = false;
- fExternalTextureSupport = false;
- fTexelFetchSupport = false;
- fVersionDeclString = nullptr;
- fShaderDerivativeExtensionString = nullptr;
- fFragCoordConventionsExtensionString = nullptr;
- fSecondaryOutputExtensionString = nullptr;
- fExternalTextureExtensionString = nullptr;
- fTexelBufferExtensionString = nullptr;
- fNoPerspectiveInterpolationExtensionString = nullptr;
- fMultisampleInterpolationExtensionString = nullptr;
- fSampleVariablesExtensionString = nullptr;
- fFBFetchColorName = nullptr;
- fFBFetchExtensionString = nullptr;
- fImageLoadStoreExtensionString = nullptr;
- fMaxVertexSamplers = 0;
- fMaxGeometrySamplers = 0;
- fMaxFragmentSamplers = 0;
- fMaxCombinedSamplers = 0;
- fMaxVertexImageStorages = 0;
- fMaxGeometryImageStorages = 0;
- fMaxFragmentImageStorages = 0;
- fMaxCombinedImageStorages = 0;
- fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
-}
-
-SkString GrGLSLCaps::dump() const {
- SkString r = INHERITED::dump();
-
- static const char* kAdvBlendEqInteractionStr[] = {
- "Not Supported",
- "Automatic",
- "General Enable",
- "Specific Enables",
- };
- GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction);
- GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction);
- GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction);
- GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction);
- GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlendEqInteraction + 1);
-
- r.appendf("--- GLSL-Specific ---\n");
-
- r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
- r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
- r.appendf("Bindless texture support: %s\n", (fBindlessTextureSupport ? "YES" : "NO"));
- r.appendf("Uses precision modifiers: %s\n", (fUsesPrecisionModifiers ? "YES" : "NO"));
- r.appendf("Can use any() function: %s\n", (fCanUseAnyFunctionInShader ? "YES" : "NO"));
- r.appendf("Can use min() and abs() together: %s\n", (fCanUseMinAndAbsTogether ? "YES" : "NO"));
- r.appendf("Must force negated atan param to float: %s\n", (fMustForceNegatedAtanParamToFloat ?
- "YES" : "NO"));
- r.appendf("Must use local out color for FBFetch: %s\n", (fRequiresLocalOutputColorForFBFetch ?
- "YES" : "NO"));
- r.appendf("Flat interpolation support: %s\n", (fFlatInterpolationSupport ? "YES" : "NO"));
- r.appendf("No perspective interpolation support: %s\n", (fNoPerspectiveInterpolationSupport ?
- "YES" : "NO"));
- r.appendf("Multisample interpolation support: %s\n", (fMultisampleInterpolationSupport ?
- "YES" : "NO"));
- r.appendf("Sample variables support: %s\n", (fSampleVariablesSupport ? "YES" : "NO"));
- r.appendf("Sample mask override coverage support: %s\n", (fSampleMaskOverrideCoverageSupport ?
- "YES" : "NO"));
- r.appendf("External texture support: %s\n", (fExternalTextureSupport ? "YES" : "NO"));
- r.appendf("texelFetch support: %s\n", (fTexelFetchSupport ? "YES" : "NO"));
- r.appendf("Max VS Samplers: %d\n", fMaxVertexSamplers);
- r.appendf("Max GS Samplers: %d\n", fMaxGeometrySamplers);
- r.appendf("Max FS Samplers: %d\n", fMaxFragmentSamplers);
- r.appendf("Max Combined Samplers: %d\n", fMaxFragmentSamplers);
- r.appendf("Max VS Image Storages: %d\n", fMaxVertexImageStorages);
- r.appendf("Max GS Image Storages: %d\n", fMaxGeometryImageStorages);
- r.appendf("Max FS Image Storages: %d\n", fMaxFragmentImageStorages);
- r.appendf("Max Combined Image Storages: %d\n", fMaxFragmentImageStorages);
- r.appendf("Advanced blend equation interaction: %s\n",
- kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]);
- return r;
-}
-
-void GrGLSLCaps::initSamplerPrecisionTable() {
- // Determine the largest precision qualifiers that are effectively the same as lowp/mediump.
- // e.g. if lowp == mediump, then use mediump instead of lowp.
- GrSLPrecision effectiveMediumP[kGrShaderTypeCount];
- GrSLPrecision effectiveLowP[kGrShaderTypeCount];
- for (int s = 0; s < kGrShaderTypeCount; ++s) {
- const PrecisionInfo* info = fFloatPrecisions[s];
- effectiveMediumP[s] = info[kHigh_GrSLPrecision] == info[kMedium_GrSLPrecision] ?
- kHigh_GrSLPrecision : kMedium_GrSLPrecision;
- effectiveLowP[s] = info[kMedium_GrSLPrecision] == info[kLow_GrSLPrecision] ?
- effectiveMediumP[s] : kLow_GrSLPrecision;
- }
-
- // Determine which precision qualifiers should be used with samplers.
- for (int visibility = 0; visibility < (1 << kGrShaderTypeCount); ++visibility) {
- GrSLPrecision mediump = kHigh_GrSLPrecision;
- GrSLPrecision lowp = kHigh_GrSLPrecision;
- for (int s = 0; s < kGrShaderTypeCount; ++s) {
- if (visibility & (1 << s)) {
- mediump = SkTMin(mediump, effectiveMediumP[s]);
- lowp = SkTMin(lowp, effectiveLowP[s]);
- }
-
- GR_STATIC_ASSERT(0 == kLow_GrSLPrecision);
- GR_STATIC_ASSERT(1 == kMedium_GrSLPrecision);
- GR_STATIC_ASSERT(2 == kHigh_GrSLPrecision);
-
- GR_STATIC_ASSERT((1 << kVertex_GrShaderType) == kVertex_GrShaderFlag);
- GR_STATIC_ASSERT((1 << kGeometry_GrShaderType) == kGeometry_GrShaderFlag);
- GR_STATIC_ASSERT((1 << kFragment_GrShaderType) == kFragment_GrShaderFlag);
- GR_STATIC_ASSERT(3 == kGrShaderTypeCount);
- }
-
- uint8_t* table = fSamplerPrecisions[visibility];
- table[kUnknown_GrPixelConfig] = kDefault_GrSLPrecision;
- table[kAlpha_8_GrPixelConfig] = lowp;
- table[kIndex_8_GrPixelConfig] = lowp;
- table[kRGB_565_GrPixelConfig] = lowp;
- table[kRGBA_4444_GrPixelConfig] = lowp;
- table[kRGBA_8888_GrPixelConfig] = lowp;
- table[kBGRA_8888_GrPixelConfig] = lowp;
- table[kSRGBA_8888_GrPixelConfig] = lowp;
- table[kSBGRA_8888_GrPixelConfig] = lowp;
- table[kRGBA_8888_sint_GrPixelConfig] = lowp;
- table[kETC1_GrPixelConfig] = lowp;
- table[kLATC_GrPixelConfig] = lowp;
- table[kR11_EAC_GrPixelConfig] = lowp;
- table[kASTC_12x12_GrPixelConfig] = lowp;
- table[kRGBA_float_GrPixelConfig] = kHigh_GrSLPrecision;
- table[kAlpha_half_GrPixelConfig] = mediump;
- table[kRGBA_half_GrPixelConfig] = mediump;
-
- GR_STATIC_ASSERT(17 == kGrPixelConfigCnt);
- }
-}
-
-void GrGLSLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
-}
+++ /dev/null
-/*
- * 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"
-#include "GrSwizzle.h"
-
-namespace SkSL {
- class GLSLCapsFactory;
-}
-
-class GrGLSLCaps : public GrShaderCaps {
-public:
- /**
- * 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; }
-
- const char* versionDeclString() const { return fVersionDeclString; }
-
- const char* fbFetchColorName() const { return fFBFetchColorName; }
-
- const char* fbFetchExtensionString() const { return fFBFetchExtensionString; }
-
- bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
-
- bool flatInterpolationSupport() const { return fFlatInterpolationSupport; }
-
- bool noperspectiveInterpolationSupport() const { return fNoPerspectiveInterpolationSupport; }
-
- bool multisampleInterpolationSupport() const { return fMultisampleInterpolationSupport; }
-
- bool sampleVariablesSupport() const { return fSampleVariablesSupport; }
-
- bool sampleMaskOverrideCoverageSupport() const { return fSampleMaskOverrideCoverageSupport; }
-
- bool externalTextureSupport() const { return fExternalTextureSupport; }
-
- bool texelFetchSupport() const { return fTexelFetchSupport; }
-
- 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;
- }
-
- bool usesPrecisionModifiers() const { return fUsesPrecisionModifiers; }
-
- // Returns whether we can use the glsl funciton any() in our shader code.
- bool canUseAnyFunctionInShader() const { return fCanUseAnyFunctionInShader; }
-
- bool canUseMinAndAbsTogether() const { return fCanUseMinAndAbsTogether; }
-
- bool mustForceNegatedAtanParamToFloat() const { return fMustForceNegatedAtanParamToFloat; }
-
- bool requiresLocalOutputColorForFBFetch() const { return fRequiresLocalOutputColorForFBFetch; }
-
- // 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;
- }
-
- // 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;
- }
-
- const char* externalTextureExtensionString() const {
- SkASSERT(this->externalTextureSupport());
- return fExternalTextureExtensionString;
- }
-
- const char* texelBufferExtensionString() const {
- SkASSERT(this->texelBufferSupport());
- return fTexelBufferExtensionString;
- }
-
- const char* noperspectiveInterpolationExtensionString() const {
- SkASSERT(this->noperspectiveInterpolationSupport());
- return fNoPerspectiveInterpolationExtensionString;
- }
-
- const char* multisampleInterpolationExtensionString() const {
- SkASSERT(this->multisampleInterpolationSupport());
- return fMultisampleInterpolationExtensionString;
- }
-
- const char* sampleVariablesExtensionString() const {
- SkASSERT(this->sampleVariablesSupport());
- return fSampleVariablesExtensionString;
- }
-
- const char* imageLoadStoreExtensionString() const {
- SkASSERT(this->imageLoadStoreSupport());
- return fImageLoadStoreExtensionString;
- }
-
- int maxVertexSamplers() const { return fMaxVertexSamplers; }
-
- int maxGeometrySamplers() const { return fMaxGeometrySamplers; }
-
- int maxFragmentSamplers() const { return fMaxFragmentSamplers; }
-
- int maxCombinedSamplers() const { return fMaxCombinedSamplers; }
-
- int maxVertexImageStorages() const { return fMaxVertexImageStorages; }
-
- int maxGeometryImageStorages() const { return fMaxGeometryImageStorages; }
-
- int maxFragmentImageStorages() const { return fMaxFragmentImageStorages; }
-
- int maxCombinedImageStorages() const { return fMaxCombinedImageStorages; }
-
- /**
- * Given a texture's config, this determines what swizzle must be appended to accesses to the
- * texture in generated shader code. Swizzling may be implemented in texture parameters or a
- * sampler rather than in the shader. In this case the returned swizzle will always be "rgba".
- */
- const GrSwizzle& configTextureSwizzle(GrPixelConfig config) const {
- return fConfigTextureSwizzle[config];
- }
-
- /** Swizzle that should occur on the fragment shader outputs for a given config. */
- const GrSwizzle& configOutputSwizzle(GrPixelConfig config) const {
- return fConfigOutputSwizzle[config];
- }
-
- /** Precision qualifier that should be used with a sampler, given its config and visibility. */
- GrSLPrecision samplerPrecision(GrPixelConfig config, GrShaderFlags visibility) const {
- return static_cast<GrSLPrecision>(fSamplerPrecisions[visibility][config]);
- }
-
- GrGLSLGeneration generation() const { return fGLSLGeneration; }
-
- /**
- * Returns a string containing the caps info.
- */
- SkString dump() const override;
-
-private:
- /** GrCaps subclasses must call this after filling in the shader precision table. */
- void initSamplerPrecisionTable();
-
- void onApplyOptionsOverrides(const GrContextOptions& options) override;
-
- GrGLSLGeneration fGLSLGeneration;
-
- bool fDropsTileOnZeroDivide : 1;
- bool fFBFetchSupport : 1;
- bool fFBFetchNeedsCustomOutput : 1;
- bool fBindlessTextureSupport : 1;
- bool fUsesPrecisionModifiers : 1;
- bool fCanUseAnyFunctionInShader : 1;
- bool fFlatInterpolationSupport : 1;
- bool fNoPerspectiveInterpolationSupport : 1;
- bool fMultisampleInterpolationSupport : 1;
- bool fSampleVariablesSupport : 1;
- bool fSampleMaskOverrideCoverageSupport : 1;
- bool fExternalTextureSupport : 1;
- bool fTexelFetchSupport : 1;
-
- // Used for specific driver bug work arounds
- bool fCanUseMinAndAbsTogether : 1;
- bool fMustForceNegatedAtanParamToFloat : 1;
- bool fRequiresLocalOutputColorForFBFetch : 1;
-
- const char* fVersionDeclString;
-
- const char* fShaderDerivativeExtensionString;
- const char* fFragCoordConventionsExtensionString;
- const char* fSecondaryOutputExtensionString;
- const char* fExternalTextureExtensionString;
- const char* fTexelBufferExtensionString;
- const char* fNoPerspectiveInterpolationExtensionString;
- const char* fMultisampleInterpolationExtensionString;
- const char* fSampleVariablesExtensionString;
- const char* fImageLoadStoreExtensionString;
-
- const char* fFBFetchColorName;
- const char* fFBFetchExtensionString;
-
- int fMaxVertexSamplers;
- int fMaxGeometrySamplers;
- int fMaxFragmentSamplers;
- int fMaxCombinedSamplers;
-
- int fMaxVertexImageStorages;
- int fMaxGeometryImageStorages;
- int fMaxFragmentImageStorages;
- int fMaxCombinedImageStorages;
-
- AdvBlendEqInteraction fAdvBlendEqInteraction;
-
- GrSwizzle fConfigTextureSwizzle[kGrPixelConfigCnt];
- GrSwizzle fConfigOutputSwizzle[kGrPixelConfigCnt];
-
- uint8_t fSamplerPrecisions[(1 << kGrShaderTypeCount)][kGrPixelConfigCnt];
-
- friend class GrGLCaps; // For initialization.
- friend class GrVkCaps;
- friend class SkSL::GLSLCapsFactory;
-
- typedef GrShaderCaps INHERITED;
-};
-
-#endif
class GrProcessor;
class GrProcessorKeyBuilder;
-class GrGLSLCaps;
class GrGLSLFPBuilder;
class GrGLSLFPFragmentBuilder;
struct EmitArgs {
EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
- const GrGLSLCaps* caps,
+ const GrShaderCaps* caps,
const GrFragmentProcessor& fp,
const char* outputColor,
const char* inputColor,
, fGpImplementsDistanceVector(gpImplementsDistanceVector) {}
GrGLSLFPFragmentBuilder* fFragBuilder;
GrGLSLUniformHandler* fUniformHandler;
- const GrGLSLCaps* fGLSLCaps;
+ const GrShaderCaps* fGLSLCaps;
const GrFragmentProcessor& fFp;
const char* fOutputColor;
const char* fInputColor;
void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor);
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
int numChildProcessors() const { return fChildProcessors.count(); }
#include "GrGLSLFragmentShaderBuilder.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetPriv.h"
+#include "GrShaderCaps.h"
#include "gl/GrGLGpu.h"
-#include "glsl/GrGLSL.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLVarying.h"
+#include "../private/GrGLSL.h"
const char* GrGLSLFragmentShaderBuilder::kDstColorName = "_dstColor";
}
bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
- const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps();
+ const GrShaderCaps& glslCaps = *fProgramBuilder->shaderCaps();
switch (feature) {
case kPixelLocalStorage_GLSLFeature:
if (glslCaps.pixelLocalStorageSize() <= 0) {
const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kFragmentPosition_RequiredFeature;)
- const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
+ const GrShaderCaps* glslCaps = fProgramBuilder->shaderCaps();
// We only declare "gl_FragCoord" when we're in the case where we want to use layout qualifiers
// to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the
// declaration varies in earlier GLSL specs. So it is simpler to omit it.
}
void GrGLSLFragmentShaderBuilder::maskSampleCoverage(const char* mask, bool invert) {
- const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps();
+ const GrShaderCaps& glslCaps = *fProgramBuilder->shaderCaps();
if (!glslCaps.sampleVariablesSupport()) {
SkDEBUGFAIL("Attempted to mask sample coverage without support.");
return;
}
void GrGLSLFragmentShaderBuilder::overrideSampleCoverage(const char* mask) {
- const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps();
+ const GrShaderCaps& glslCaps = *fProgramBuilder->shaderCaps();
if (!glslCaps.sampleMaskOverrideCoverageSupport()) {
SkDEBUGFAIL("Attempted to override sample coverage without support.");
return;
return override;
}
- const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
+ const GrShaderCaps* glslCaps = fProgramBuilder->shaderCaps();
if (glslCaps->fbFetchSupport()) {
this->addFeature(1 << kFramebufferFetch_GLSLPrivateFeature,
glslCaps->fbFetchExtensionString());
void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquation equation) {
SkASSERT(GrBlendEquationIsAdvanced(equation));
- const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
+ const GrShaderCaps& caps = *fProgramBuilder->shaderCaps();
if (!caps.mustEnableAdvBlendEqs()) {
return;
}
void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() {
SkASSERT(!fHasSecondaryOutput);
fHasSecondaryOutput = true;
- const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
+ const GrShaderCaps& caps = *fProgramBuilder->shaderCaps();
if (const char* extension = caps.secondaryOutputExtensionString()) {
this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, extension);
}
}
const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const {
- const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
+ const GrShaderCaps& caps = *fProgramBuilder->shaderCaps();
return caps.mustDeclareFragmentShaderOutput() ? DeclaredSecondaryColorOutputName()
: "gl_SecondaryFragColorEXT";
}
void GrGLSLFragmentShaderBuilder::onFinalize() {
fProgramBuilder->varyingHandler()->getFragDecls(&this->inputs(), &this->outputs());
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
- *fProgramBuilder->glslCaps(),
+ *fProgramBuilder->shaderCaps(),
&this->precisionQualifier());
if (fUsedSampleOffsetArrays & (1 << kSkiaDevice_Coordinates)) {
this->defineSampleOffsetArray(sample_offset_array_name(kSkiaDevice_Coordinates),
class GrBatchTracker;
class GrPrimitiveProcessor;
-class GrGLSLCaps;
class GrGLSLPPFragmentBuilder;
class GrGLSLGeometryBuilder;
class GrGLSLGPBuilder;
class GrGLSLVaryingHandler;
class GrGLSLVertexBuilder;
+class GrShaderCaps;
class GrGLSLPrimitiveProcessor {
public:
GrGLSLPPFragmentBuilder* fragBuilder,
GrGLSLVaryingHandler* varyingHandler,
GrGLSLUniformHandler* uniformHandler,
- const GrGLSLCaps* caps,
+ const GrShaderCaps* caps,
const GrPrimitiveProcessor& gp,
const char* outputColor,
const char* outputCoverage,
GrGLSLPPFragmentBuilder* fFragBuilder;
GrGLSLVaryingHandler* fVaryingHandler;
GrGLSLUniformHandler* fUniformHandler;
- const GrGLSLCaps* fGLSLCaps;
+ const GrShaderCaps* fGLSLCaps;
const GrPrimitiveProcessor& fGP;
const char* fOutputColor;
const char* fOutputCoverage;
#include "glsl/GrGLSLProgramBuilder.h"
+#include "GrCaps.h"
#include "GrPipeline.h"
+#include "GrShaderCaps.h"
#include "GrTexturePriv.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLVarying.h"
fVS.codeAppendf("// Primitive Processor %s\n", proc.name());
SkASSERT(!fGeometryProcessor);
- fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps());
+ fGeometryProcessor = proc.createGLSLInstance(*this->shaderCaps());
SkSTArray<4, SamplerHandle> texSamplers(proc.numTextureSamplers());
SkSTArray<2, SamplerHandle> bufferSamplers(proc.numBuffers());
&fFS,
this->varyingHandler(),
this->uniformHandler(),
- this->glslCaps(),
+ this->shaderCaps(),
proc,
outputColor->c_str(),
outputCoverage->c_str(),
GrGLSLFragmentProcessor::ImageStorages imageStorages(&fp, imageStorageArray.begin());
GrGLSLFragmentProcessor::EmitArgs args(&fFS,
this->uniformHandler(),
- this->glslCaps(),
+ this->shaderCaps(),
fp,
output->c_str(),
input.isOnes() ? nullptr : input.c_str(),
fFS.enableSecondaryOutput();
}
- if (this->glslCaps()->mustDeclareFragmentShaderOutput()) {
+ if (this->shaderCaps()->mustDeclareFragmentShaderOutput()) {
fFS.enableCustomOutput();
}
bool usePLSDstRead = (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState);
GrGLSLXferProcessor::EmitArgs args(&fFS,
this->uniformHandler(),
- this->glslCaps(),
+ this->shaderCaps(),
xp, colorIn.c_str(),
ignoresCoverage ? nullptr : coverageIn.c_str(),
fFS.getPrimaryColorOutputName(),
name.printf("TextureSampler_%d", outTexSamplerHandles->count());
GrSLType samplerType = sampler.texture()->texturePriv().samplerType();
if (kTextureExternalSampler_GrSLType == samplerType) {
- const char* externalFeatureString = this->glslCaps()->externalTextureExtensionString();
+ const char* externalFeatureString =
+ this->shaderCaps()->externalTextureExtensionString();
// We shouldn't ever create a GrGLTexture that requires external sampler type
SkASSERT(externalFeatureString);
this->addFeature(sampler.visibility(),
}
if (int numBuffers = processor.numBuffers()) {
- SkASSERT(this->glslCaps()->texelBufferSupport());
+ SkASSERT(this->shaderCaps()->texelBufferSupport());
GrShaderFlags texelBufferVisibility = kNone_GrShaderFlags;
for (int b = 0; b < numBuffers; ++b) {
texelBufferVisibility |= access.visibility();
}
- if (const char* extension = this->glslCaps()->texelBufferExtensionString()) {
+ if (const char* extension = this->shaderCaps()->texelBufferExtensionString()) {
this->addFeature(texelBufferVisibility,
1 << GrGLSLShaderBuilder::kTexelBuffer_GLSLPrivateFeature,
extension);
if (visibility & kFragment_GrShaderFlag) {
++fNumFragmentSamplers;
}
- GrSLPrecision precision = this->glslCaps()->samplerPrecision(config, visibility);
- GrSwizzle swizzle = this->glslCaps()->configTextureSwizzle(config);
+ GrSLPrecision precision = this->shaderCaps()->samplerPrecision(config, visibility);
+ GrSwizzle swizzle = this->shaderCaps()->configTextureSwizzle(config);
outSamplerHandles->emplace_back(this->uniformHandler()->addSampler(visibility,
swizzle,
samplerType,
}
bool GrGLSLProgramBuilder::checkSamplerCounts() {
- const GrGLSLCaps& glslCaps = *this->glslCaps();
+ const GrShaderCaps& glslCaps = *this->shaderCaps();
if (fNumVertexSamplers > glslCaps.maxVertexSamplers()) {
GrCapsDebugf(this->caps(), "Program would use too many vertex samplers\n");
return false;
}
bool GrGLSLProgramBuilder::checkImageStorageCounts() {
- const GrGLSLCaps& glslCaps = *this->glslCaps();
+ const GrShaderCaps& glslCaps = *this->shaderCaps();
if (fNumVertexImageStorages > glslCaps.maxVertexImageStorages()) {
GrCapsDebugf(this->caps(), "Program would use too many vertex images\n");
return false;
this->varyingHandler()->finalize();
fVS.finalize(kVertex_GrShaderFlag);
if (this->primitiveProcessor().willUseGeoShader()) {
- SkASSERT(this->glslCaps()->geometryShaderSupport());
+ SkASSERT(this->shaderCaps()->geometryShaderSupport());
fGS.finalize(kGeometry_GrShaderFlag);
}
fFS.finalize(kFragment_GrShaderFlag);
#ifndef GrGLSLProgramBuilder_DEFINED
#define GrGLSLProgramBuilder_DEFINED
+#include "GrCaps.h"
#include "GrGeometryProcessor.h"
#include "GrGpu.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
#include "glsl/GrGLSLXferProcessor.h"
-class GrGLSLCaps;
class GrShaderVar;
class GrGLSLVaryingHandler;
class GrGLSLExpr4;
+class GrShaderCaps;
typedef SkSTArray<8, GrGLSLFragmentProcessor*, true> GrGLSLFragProcs;
virtual ~GrGLSLProgramBuilder() {}
virtual const GrCaps* caps() const = 0;
- virtual const GrGLSLCaps* glslCaps() const = 0;
+ const GrShaderCaps* shaderCaps() const { return this->caps()->shaderCaps(); }
const GrPrimitiveProcessor& primitiveProcessor() const { return fPrimProc; }
const GrPipeline& pipeline() const { return fPipeline; }
*/
#include "GrShaderVar.h"
+#include "GrShaderCaps.h"
#include "GrSwizzle.h"
#include "glsl/GrGLSLShaderBuilder.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLProgramBuilder.h"
void GrGLSLShaderBuilder::declAppend(const GrShaderVar& var) {
SkString tempDecl;
- var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl);
+ var.appendDecl(fProgramBuilder->shaderCaps(), &tempDecl);
this->codeAppendf("%s;", tempDecl.c_str());
}
this->functions().appendf(" %s", outName->c_str());
this->functions().append("(");
for (int i = 0; i < argCnt; ++i) {
- args[i].appendDecl(fProgramBuilder->glslCaps(), &this->functions());
+ args[i].appendDecl(fProgramBuilder->shaderCaps(), &this->functions());
if (i < argCnt - 1) {
this->functions().append(", ");
}
SamplerHandle samplerHandle,
const char* coordExpr) const {
const GrShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
- SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
+ SkASSERT(fProgramBuilder->shaderCaps()->texelFetchSupport());
SkASSERT(GrSLTypeIsCombinedSamplerType(sampler.getType()));
out->appendf("texelFetch(%s, %s)", sampler.c_str(), coordExpr);
void GrGLSLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
for (int i = 0; i < vars.count(); ++i) {
- vars[i].appendDecl(fProgramBuilder->glslCaps(), out);
+ vars[i].appendDecl(fProgramBuilder->shaderCaps(), out);
out->append(";\n");
}
}
void GrGLSLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) {
- SkASSERT(fProgramBuilder->glslCaps()->generation() >= k330_GrGLSLGeneration ||
- fProgramBuilder->glslCaps()->mustEnableAdvBlendEqs());
+ SkASSERT(fProgramBuilder->shaderCaps()->generation() >= k330_GrGLSLGeneration ||
+ fProgramBuilder->shaderCaps()->mustEnableAdvBlendEqs());
fLayoutParams[interface].push_back() = param;
}
void GrGLSLShaderBuilder::finalize(uint32_t visibility) {
SkASSERT(!fFinalized);
- this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString();
+ this->versionDecl() = fProgramBuilder->shaderCaps()->versionDeclString();
this->compileAndAppendLayoutQualifiers();
SkASSERT(visibility);
fProgramBuilder->appendUniformDecls((GrShaderFlags) visibility, &this->uniforms());
* found in the LICENSE file.
*/
+#include "GrShaderCaps.h"
#include "glsl/GrGLSLVarying.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramBuilder.h"
void GrGLSLVaryingHandler::addPassThroughAttribute(const GrGeometryProcessor::Attribute* input,
}
void GrGLSLVaryingHandler::setNoPerspective() {
- const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
+ const GrShaderCaps& caps = *fProgramBuilder->shaderCaps();
if (!caps.noperspectiveInterpolationSupport()) {
return;
}
void GrGLSLVaryingHandler::appendDecls(const VarArray& vars, SkString* out) const {
for (int i = 0; i < vars.count(); ++i) {
- vars[i].appendDecl(fProgramBuilder->glslCaps(), out);
+ vars[i].appendDecl(fProgramBuilder->shaderCaps(), out);
out->append(";");
}
}
void GrGLSLVaryingHandler::getFragDecls(SkString* inputDecls, SkString* outputDecls) const {
// We should not have any outputs in the fragment shader when using version 1.10
- SkASSERT(k110_GrGLSLGeneration != fProgramBuilder->glslCaps()->generation() ||
+ SkASSERT(k110_GrGLSLGeneration != fProgramBuilder->shaderCaps()->generation() ||
fFragOutputs.empty());
this->appendDecls(fFragInputs, inputDecls);
this->appendDecls(fFragOutputs, outputDecls);
#include "glsl/GrGLSLXferProcessor.h"
+#include "GrShaderCaps.h"
#include "GrXferProcessor.h"
-#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLUniformHandler.h"
class GrXferProcessor;
-class GrGLSLCaps;
class GrGLSLXPBuilder;
class GrGLSLXPFragmentBuilder;
+class GrShaderCaps;
class GrGLSLXferProcessor {
public:
struct EmitArgs {
EmitArgs(GrGLSLXPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
- const GrGLSLCaps* caps,
+ const GrShaderCaps* caps,
const GrXferProcessor& xp,
const char* inputColor,
const char* inputCoverage,
GrGLSLXPFragmentBuilder* fXPFragBuilder;
GrGLSLUniformHandler* fUniformHandler;
- const GrGLSLCaps* fGLSLCaps;
+ const GrShaderCaps* fGLSLCaps;
const GrXferProcessor& fXP;
const char* fInputColor;
const char* fInputCoverage;
+++ /dev/null
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLSL_impl_DEFINED
-#define GrGLSL_impl_DEFINED
-
-template<typename Self>
-template<typename T>
-inline Self GrGLSLExpr<Self>::VectorCastImpl(const T& expr) {
- if (expr.isZeros()) {
- return Self(0);
- }
- if (expr.isOnes()) {
- return Self(1);
- }
- return Self(Self::CastStr(), expr.c_str());
-}
-
-template<typename Self>
-template<typename T0, typename T1>
-inline Self GrGLSLExpr<Self>::Mul(T0 in0, T1 in1) {
- if (in0.isZeros() || in1.isZeros()) {
- return Self(0);
- }
- if (in0.isOnes()) {
- return Self::VectorCast(in1);
- }
- if (in1.isOnes()) {
- return Self::VectorCast(in0);
- }
- return Self("(%s * %s)", in0.c_str(), in1.c_str());
-}
-
-template<typename Self>
-template<typename T0, typename T1>
-inline Self GrGLSLExpr<Self>::Add(T0 in0, T1 in1) {
- if (in1.isZeros()) {
- return Self::VectorCast(in0);
- }
- if (in0.isZeros()) {
- return Self::VectorCast(in1);
- }
- if (in0.isOnes() && in1.isOnes()) {
- return Self(2);
- }
- return Self("(%s + %s)", in0.c_str(), in1.c_str());
-}
-
-template<typename Self>
-template<typename T0, typename T1>
-inline Self GrGLSLExpr<Self>::Sub(T0 in0, T1 in1) {
- if (in1.isZeros()) {
- return Self::VectorCast(in0);
- }
- if (in1.isOnes()) {
- if (in0.isOnes()) {
- return Self(0);
- }
- }
-
- return Self("(%s - %s)", in0.c_str(), in1.c_str());
-}
-
-template <typename Self>
-template <typename T>
-T GrGLSLExpr<Self>::extractComponents(const char format[]) const {
- if (this->isZeros()) {
- return T(0);
- }
- if (this->isOnes()) {
- return T(1);
- }
- return T(format, this->c_str());
-}
-
-inline GrGLSLExpr1 GrGLSLExpr1::VectorCast(const GrGLSLExpr1& expr) {
- return expr;
-}
-
-inline const char* GrGLSLExpr1::ZerosStr() {
- return "0";
-}
-
-inline const char* GrGLSLExpr1::OnesStr() {
- return "1.0";
-}
-
-// GrGLSLExpr1::CastStr() is unimplemented because using them is likely an
-// error. This is now caught compile-time.
-
-inline const char* GrGLSLExpr1::CastIntStr() {
- return "%d";
-}
-
-inline GrGLSLExpr1 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
- return GrGLSLExpr1::Mul(in0, in1);
-}
-
-inline GrGLSLExpr1 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
- return GrGLSLExpr1::Add(in0, in1);
-}
-
-inline GrGLSLExpr1 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
- return GrGLSLExpr1::Sub(in0, in1);
-}
-
-inline const char* GrGLSLExpr4::ZerosStr() {
- return "vec4(0)";
-}
-
-inline const char* GrGLSLExpr4::OnesStr() {
- return "vec4(1)";
-}
-
-inline const char* GrGLSLExpr4::CastStr() {
- return "vec4(%s)";
-}
-
-inline const char* GrGLSLExpr4::CastIntStr() {
- return "vec4(%d)";
-}
-
-inline GrGLSLExpr4 GrGLSLExpr4::VectorCast(const GrGLSLExpr1& expr) {
- return INHERITED::VectorCastImpl(expr);
-}
-
-inline GrGLSLExpr4 GrGLSLExpr4::VectorCast(const GrGLSLExpr4& expr) {
- return expr;
-}
-
-inline GrGLSLExpr4::AExpr GrGLSLExpr4::a() const {
- return this->extractComponents<GrGLSLExpr4::AExpr>("%s.a");
-}
-
-inline GrGLSLExpr4 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
- return GrGLSLExpr4::Mul(in0, in1);
-}
-
-inline GrGLSLExpr4 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
- return GrGLSLExpr4::Add(in0, in1);
-}
-
-inline GrGLSLExpr4 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
- return GrGLSLExpr4::Sub(in0, in1);
-}
-
-inline GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
- return GrGLSLExpr4::Mul(in0, in1);
-}
-
-inline GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
- return GrGLSLExpr4::Add(in0, in1);
-}
-
-inline GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
- return GrGLSLExpr4::Sub(in0, in1);
-}
-
-inline GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
- return GrGLSLExpr4::Mul(in0, in1);
-}
-
-inline GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
- return GrGLSLExpr4::Add(in0, in1);
-}
-
-inline GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
- return GrGLSLExpr4::Sub(in0, in1);
-}
-
-#endif
#include "GrRenderTargetPriv.h"
#include "GrResourceCache.h"
#include "GrResourceProvider.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
namespace gr_instanced {
-GrCaps::InstancedSupport InstanceProcessor::CheckSupport(const GrGLSLCaps& glslCaps,
+GrCaps::InstancedSupport InstanceProcessor::CheckSupport(const GrShaderCaps& glslCaps,
const GrCaps& caps) {
if (!glslCaps.canUseAnyFunctionInShader() ||
!glslCaps.flatInterpolationSupport() ||
typedef GrGLSLGeometryProcessor INHERITED;
};
-GrGLSLPrimitiveProcessor* InstanceProcessor::createGLSLInstance(const GrGLSLCaps&) const {
+GrGLSLPrimitiveProcessor* InstanceProcessor::createGLSLInstance(const GrShaderCaps&) const {
return new GLSLInstanceProcessor();
}
const char* name() const override { return "Instance Processor"; }
BatchInfo batchInfo() const { return fBatchInfo; }
- void getGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const override {
+ void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override {
b->add32(fBatchInfo.fData);
}
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
/**
* Returns a buffer of ShapeVertex that defines the canonical instanced geometry.
* Called by the platform-specific instanced rendering implementation to determine the level of
* support this class can offer on the given GLSL platform.
*/
- static GrCaps::InstancedSupport CheckSupport(const GrGLSLCaps&, const GrCaps&);
+ static GrCaps::InstancedSupport CheckSupport(const GrShaderCaps&, const GrCaps&);
const BatchInfo fBatchInfo;
BufferAccess fParamsAccess;
#include "GrVkCaps.h"
+#include "GrShaderCaps.h"
#include "GrVkUtil.h"
-#include "glsl/GrGLSLCaps.h"
#include "vk/GrVkInterface.h"
#include "vk/GrVkBackendContext.h"
fMaxColorSampleCount = 4; // minimum required by spec
fMaxStencilSampleCount = 4; // minimum required by spec
- fShaderCaps.reset(new GrGLSLCaps(contextOptions));
+ fShaderCaps.reset(new GrShaderCaps(contextOptions));
this->init(contextOptions, vkInterface, physDev, featureFlags, extensionFlags);
}
}
this->applyOptionsOverrides(contextOptions);
- GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
+ GrShaderCaps* glslCaps = fShaderCaps.get();
glslCaps->applyOptionsOverrides(contextOptions);
}
void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceProperties& properties,
uint32_t featureFlags) {
- GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
+ GrShaderCaps* glslCaps = fShaderCaps.get();
glslCaps->fVersionDeclString = "#version 330\n";
#include "vk/GrVkDefines.h"
struct GrVkInterface;
-class GrGLSLCaps;
+class GrShaderCaps;
/**
* Stores some capabilities of a Vk backend.
return fPreferedStencilFormat;
}
- GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
+ GrShaderCaps* glslCaps() const { return fShaderCaps.get(); }
private:
enum VkVendor {
#include "GrVkCopyManager.h"
-#include "GrSurface.h"
#include "GrSamplerParams.h"
+#include "GrShaderCaps.h"
+#include "GrSurface.h"
#include "GrTexturePriv.h"
#include "GrVkCommandBuffer.h"
#include "GrVkCopyPipeline.h"
#include "GrVkTexture.h"
#include "GrVkUniformBuffer.h"
#include "GrVkVertexBuffer.h"
-#include "glsl/GrGLSLCaps.h"
#include "SkPoint.h"
#include "SkRect.h"
bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
- const GrGLSLCaps* glslCaps = gpu->vkCaps().glslCaps();
+ const GrShaderCaps* glslCaps = gpu->vkCaps().glslCaps();
const char* version = glslCaps->versionDeclString();
SkString vertShaderText(version);
vertShaderText.append(
const GrPipeline& pipeline,
const GrStencilSettings& stencil,
GrPrimitiveType primitiveType,
- const GrGLSLCaps& caps) {
+ const GrShaderCaps& caps) {
if (!INHERITED::Build(desc, primProc, primitiveType == kPoints_GrPrimitiveType, pipeline,
caps)) {
return false;
const GrPipeline&,
const GrStencilSettings&,
GrPrimitiveType primitiveType,
- const GrGLSLCaps&);
+ const GrShaderCaps&);
private:
typedef GrProgramDesc INHERITED;
};
#include "vk/GrVkPipelineStateBuilder.h"
-#include "glsl/GrGLSLCaps.h"
+#include "GrShaderCaps.h"
#include "vk/GrVkDescriptorSetManager.h"
#include "vk/GrVkGpu.h"
#include "vk/GrVkRenderPass.h"
const GrCaps* GrVkPipelineStateBuilder::caps() const {
return fGpu->caps();
}
-const GrGLSLCaps* GrVkPipelineStateBuilder::glslCaps() const {
- return fGpu->vkCaps().glslCaps();
-}
void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrShaderVar& outputColor) {
outputColor.addLayoutQualifier("location = 0, index = 0");
const GrVkRenderPass& renderPass);
const GrCaps* caps() const override;
- const GrGLSLCaps* glslCaps() const override;
GrVkGpu* gpu() const { return fGpu; }
const UniformInfo& sampler = fSamplers[i];
SkASSERT(sampler.fVariable.getType() == kTexture2DSampler_GrSLType);
if (visibility == sampler.fVisibility) {
- sampler.fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
+ sampler.fVariable.appendDecl(fProgramBuilder->shaderCaps(), out);
out->append(";\n");
}
}
const UniformInfo& localUniform = fUniforms[i];
if (visibility == localUniform.fVisibility) {
if (GrSLTypeIsFloatType(localUniform.fVariable.getType())) {
- localUniform.fVariable.appendDecl(fProgramBuilder->glslCaps(), &uniformsString);
+ localUniform.fVariable.appendDecl(fProgramBuilder->shaderCaps(), &uniformsString);
uniformsString.append(";\n");
}
}
return result;
}
-static void fill_caps(const GrGLSLCaps& caps, std::unordered_map<SkString, CapValue>* capsMap) {
+static void fill_caps(const GrShaderCaps& caps, std::unordered_map<SkString, CapValue>* capsMap) {
#define CAP(name) capsMap->insert(std::make_pair(SkString(#name), CapValue(caps.name())));
CAP(fbFetchSupport);
CAP(fbFetchNeedsCustomOutput);
#undef CAP
}
-bool Compiler::toGLSL(Program::Kind kind, const SkString& text, const GrGLSLCaps& caps,
+bool Compiler::toGLSL(Program::Kind kind, const SkString& text, const GrShaderCaps& caps,
SkWStream& out) {
std::unordered_map<SkString, CapValue> capsMap;
fill_caps(caps, &capsMap);
return fErrorCount == 0;
}
-bool Compiler::toGLSL(Program::Kind kind, const SkString& text, const GrGLSLCaps& caps,
+bool Compiler::toGLSL(Program::Kind kind, const SkString& text, const GrShaderCaps& caps,
SkString* out) {
SkDynamicMemoryWStream buffer;
bool result = this->toGLSL(kind, text, caps, buffer);
bool toSPIRV(Program::Kind kind, const SkString& text, SkString* out);
- bool toGLSL(Program::Kind kind, const SkString& text, const GrGLSLCaps& caps,
+ bool toGLSL(Program::Kind kind, const SkString& text, const GrShaderCaps& caps,
SkWStream& out);
- bool toGLSL(Program::Kind kind, const SkString& text, const GrGLSLCaps& caps,
+ bool toGLSL(Program::Kind kind, const SkString& text, const GrShaderCaps& caps,
SkString* out);
void error(Position position, SkString msg) override;
#include <tuple>
#include <unordered_map>
+#include "GrShaderCaps.h"
#include "SkStream.h"
-#include "glsl/GrGLSLCaps.h"
#include "SkSLCodeGenerator.h"
#include "ir/SkSLBinaryExpression.h"
#include "ir/SkSLBoolLiteral.h"
kTopLevel_Precedence = 18
};
- GLSLCodeGenerator(const Context* context, const GrGLSLCaps* caps)
+ GLSLCodeGenerator(const Context* context, const GrShaderCaps* caps)
: fContext(*context)
, fCaps(*caps) {}
void writeReturnStatement(const ReturnStatement& r);
const Context& fContext;
- const GrGLSLCaps& fCaps;
+ const GrShaderCaps& fCaps;
SkWStream* fOut = nullptr;
SkDynamicMemoryWStream fHeader;
SkString fFunctionHeader;
#include "SkStream.h"
#include "SkString.h"
#include "SkTypes.h"
-#include "glsl/GrGLSLCaps.h"
#include "GrContextOptions.h"
+#include "GrShaderCaps.h"
namespace SkSL {
// Various sets of caps for use in tests
class GLSLCapsFactory {
public:
- static sk_sp<GrGLSLCaps> Default() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> Default() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 400";
result->fShaderDerivativeSupport = true;
return result;
}
- static sk_sp<GrGLSLCaps> Version450Core() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> Version450Core() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 450 core";
return result;
}
- static sk_sp<GrGLSLCaps> Version110() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> Version110() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 110";
result->fGLSLGeneration = GrGLSLGeneration::k110_GrGLSLGeneration;
return result;
}
- static sk_sp<GrGLSLCaps> UsesPrecisionModifiers() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> UsesPrecisionModifiers() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 400";
result->fUsesPrecisionModifiers = true;
return result;
}
- static sk_sp<GrGLSLCaps> CannotUseMinAndAbsTogether() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> CannotUseMinAndAbsTogether() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 400";
result->fCanUseMinAndAbsTogether = false;
return result;
}
- static sk_sp<GrGLSLCaps> MustForceNegatedAtanParamToFloat() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> MustForceNegatedAtanParamToFloat() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 400";
result->fMustForceNegatedAtanParamToFloat = true;
return result;
}
- static sk_sp<GrGLSLCaps> ShaderDerivativeExtensionString() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> ShaderDerivativeExtensionString() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 400";
result->fShaderDerivativeSupport = true;
result->fShaderDerivativeExtensionString = "GL_OES_standard_derivatives";
return result;
}
- static sk_sp<GrGLSLCaps> VariousCaps() {
- sk_sp<GrGLSLCaps> result = sk_make_sp<GrGLSLCaps>(GrContextOptions());
+ static sk_sp<GrShaderCaps> VariousCaps() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
result->fVersionDeclString = "#version 400";
result->fExternalTextureSupport = true;
result->fFBFetchSupport = false;
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextFactory.h"
+#include "GrShaderCaps.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLUtil.h"
#include "gl/GLTestContext.h"
-#include "glsl/GrGLSLCaps.h"
using sk_gpu_test::GLTestContext;
}
}
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
for (uint32_t i = 0; i < kMaxKeySize; i++) {
b->add32(i);
}
BigKeyProcessor() {
this->initClassID<BigKeyProcessor>();
}
- virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const override {
GLBigKeyProcessor::GenKey(*this, caps, b);
}
this->registerChildProcessor(std::move(child));
}
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {}
+ void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
this->addImageStorageAccess(&fImageStorageAccess);
}
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {}
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
}
const char* name() const override { return "Dummy GP"; }
- GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override {
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
class GLSLGP : public GrGLSLGeometryProcessor {
public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
};
return new GLSLGP();
}
- void getGLSLProcessorKey(const GrGLSLCaps&,
+ void getGLSLProcessorKey(const GrShaderCaps&,
GrProcessorKeyBuilder* builder) const override {
builder->add32(this->numAttribs());
}
#if SK_SUPPORT_GPU
-static void test(skiatest::Reporter* r, const char* src, const GrGLSLCaps& caps,
+static void test(skiatest::Reporter* r, const char* src, const GrShaderCaps& caps,
const char* expected) {
SkSL::Compiler compiler;
SkString output;