'<(skia_src_path)/gpu/gl/GrGLDefines.h',
'<(skia_src_path)/gpu/gl/GrGLGeometryProcessor.cpp',
'<(skia_src_path)/gpu/gl/GrGLGeometryProcessor.h',
+ '<(skia_src_path)/gpu/gl/GrGLGLSL.cpp',
+ '<(skia_src_path)/gpu/gl/GrGLGLSL.h',
'<(skia_src_path)/gpu/gl/GrGLGpu.cpp',
'<(skia_src_path)/gpu/gl/GrGLGpu.h',
'<(skia_src_path)/gpu/gl/GrGLGpuProgramCache.cpp',
'<(skia_src_path)/gpu/gl/GrGLRenderTarget.cpp',
'<(skia_src_path)/gpu/gl/GrGLRenderTarget.h',
'<(skia_src_path)/gpu/gl/GrGLShaderVar.h',
- '<(skia_src_path)/gpu/gl/GrGLSL.cpp',
- '<(skia_src_path)/gpu/gl/GrGLSL.h',
- '<(skia_src_path)/gpu/gl/GrGLSL_impl.h',
'<(skia_src_path)/gpu/gl/GrGLStencilAttachment.cpp',
'<(skia_src_path)/gpu/gl/GrGLStencilAttachment.h',
'<(skia_src_path)/gpu/gl/GrGLTexture.cpp',
'<(skia_src_path)/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp',
'<(skia_src_path)/gpu/gl/builders/GrGLGeometryShaderBuilder.h',
+ # GLSL
+ '<(skia_src_path)/gpu/glsl/GrGLSLCaps.cpp',
+ '<(skia_src_path)/gpu/glsl/GrGLSLCaps.h',
+ '<(skia_src_path)/gpu/glsl/GrGLSL.cpp',
+ '<(skia_src_path)/gpu/glsl/GrGLSL.h',
+ '<(skia_src_path)/gpu/glsl/GrGLSL_impl.h',
+
# Sk files
'<(skia_include_path)/gpu/SkGr.h',
'<(skia_include_path)/gpu/SkGrPixelRef.h',
#include "GrInvariantOutput.h"
#include "effects/GrSingleTextureEffect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkString.h"
#include "SkTraceEvent.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkString.h"
#include "SkTraceEvent.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkTLazy.h"
#include "effects/GrRRectEffect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLPathProcessor.h"
#include "gl/GrGLGpu.h"
+#include "glsl/GrGLSLCaps.h"
+
GrPathProcessor::GrPathProcessor(GrColor color,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix)
#include "GrBezierEffect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrInvariantOutput.h"
#include "GrTexture.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "effects/GrConstColorProcessor.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/builders/GrGLProgramBuilder.h"
class GLConstColorProcessor : public GrGLFragmentProcessor {
#include "GrInvariantOutput.h"
#include "SkPathPriv.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/builders/GrGLProgramBuilder.h"
//////////////////////////////////////////////////////////////////////////////
#include "GrConvolutionEffect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLProgramDataManager.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLCaps.h"
bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode;
#include "SkGr.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/builders/GrGLProgramBuilder.h"
///////////////////////////////////////////////////////////////////////////////
#include "SkDistanceFieldGen.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrInvariantOutput.h"
#include "SkRect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/builders/GrGLProgramBuilder.h"
//////////////////////////////////////////////////////////////////////////////
*/
#include "GrMatrixConvolutionEffect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrInvariantOutput.h"
#include "SkRect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/builders/GrGLProgramBuilder.h"
//////////////////////////////////////////////////////////////////////////////
#include "GrOvalEffect.h"
#include "SkRRect.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/builders/GrGLProgramBuilder.h"
// The effects defined here only handle rrect radii >= kRadiusMin.
#include "GrTexture.h"
#include "gl/GrGLCaps.h"
#include "gl/GrGLProcessor.h"
-#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrGLCaps.h"
#include "GrGLContext.h"
+#include "glsl/GrGLSLCaps.h"
#include "SkTSearch.h"
#include "SkTSort.h"
fReadPixelsSupportedCache.reset();
- fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (contextOptions,
- ctxInfo, glInterface, *this)));
+ fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (contextOptions)));
this->init(contextOptions, ctxInfo, glInterface);
}
this->initConfigTexturableTable(ctxInfo, gli);
this->initConfigRenderableTable(ctxInfo);
- glslCaps->initShaderPrecisionTable(ctxInfo, gli);
+ this->initShaderPrecisionTable(ctxInfo, gli, glslCaps);
this->applyOptionsOverrides(contextOptions);
glslCaps->applyOptionsOverrides(contextOptions);
return r;
}
-////////////////////////////////////////////////////////////////////////////////////////////
-
-GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options,
- const GrGLContextInfo& ctxInfo,
- const GrGLInterface* gli,
- const GrGLCaps& glCaps) {
- fDropsTileOnZeroDivide = false;
- fFBFetchSupport = false;
- fFBFetchNeedsCustomOutput = false;
- fBindlessTextureSupport = false;
- fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
- fFBFetchColorName = NULL;
- fFBFetchExtensionString = NULL;
-}
-
-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("Advanced blend equation interaction: %s\n",
- kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]);
- return r;
-}
-
static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
switch (p) {
case kLow_GrSLPrecision:
return -1;
}
-void GrGLSLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
- const GrGLInterface* intf) {
+void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
+ const GrGLInterface* intf,
+ GrGLSLCaps* 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) {
if (kGeometry_GrShaderType != s) {
GrShaderType shaderType = static_cast<GrShaderType>(s);
GrGLenum glShader = shader_type_to_gl_shader(shaderType);
- PrecisionInfo* first = NULL;
- fShaderPrecisionVaries = false;
+ GrShaderCaps::PrecisionInfo* first = NULL;
+ glslCaps->fShaderPrecisionVaries = false;
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
GrSLPrecision precision = static_cast<GrSLPrecision>(p);
GrGLenum glPrecision = precision_to_gl_float_type(precision);
GrGLint bits;
GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
if (bits) {
- fFloatPrecisions[s][p].fLogRangeLow = range[0];
- fFloatPrecisions[s][p].fLogRangeHigh = range[1];
- fFloatPrecisions[s][p].fBits = bits;
+ glslCaps->fFloatPrecisions[s][p].fLogRangeLow = range[0];
+ glslCaps->fFloatPrecisions[s][p].fLogRangeHigh = range[1];
+ glslCaps->fFloatPrecisions[s][p].fBits = bits;
if (!first) {
- first = &fFloatPrecisions[s][p];
+ first = &glslCaps->fFloatPrecisions[s][p];
}
- else if (!fShaderPrecisionVaries) {
- fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]);
+ else if (!glslCaps->fShaderPrecisionVaries) {
+ glslCaps->fShaderPrecisionVaries =
+ (*first != glslCaps->fFloatPrecisions[s][p]);
}
}
}
}
else {
// We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
- fShaderPrecisionVaries = false;
+ glslCaps->fShaderPrecisionVaries = false;
for (int s = 0; s < kGrShaderTypeCount; ++s) {
if (kGeometry_GrShaderType != s) {
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
- fFloatPrecisions[s][p].fLogRangeLow = 127;
- fFloatPrecisions[s][p].fLogRangeHigh = 127;
- fFloatPrecisions[s][p].fBits = 23;
+ glslCaps->fFloatPrecisions[s][p].fLogRangeLow = 127;
+ glslCaps->fFloatPrecisions[s][p].fLogRangeHigh = 127;
+ glslCaps->fFloatPrecisions[s][p].fBits = 23;
}
}
}
// the same as the vertex shader. Only fragment shaders were ever allowed to omit support for
// highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
// are recommended against.
- if (fGeometryShaderSupport) {
+ if (glslCaps->fGeometryShaderSupport) {
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
- fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p];
+ glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] =
+ glslCaps->fFloatPrecisions[kVertex_GrShaderType][p];
}
}
}
#define GrGLCaps_DEFINED
#include "GrCaps.h"
-#include "GrGLSL.h"
+#include "glsl/GrGLSL.h"
#include "GrGLStencilAttachment.h"
#include "SkChecksum.h"
#include "SkTHash.h"
bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLenum type) const;
+ void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
+ const GrGLInterface* intf,
+ GrGLSLCaps* glslCaps);
+
// tracks configs that have been verified to pass the FBO completeness when
// used as a color attachment
VerifiedColorConfigs fVerifiedColorConfigs;
typedef GrCaps INHERITED;
};
-class GrGLSLCaps : public GrShaderCaps {
-public:
- SK_DECLARE_INST_COUNT(GrGLSLCaps)
-
- /**
- * 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 the set of features supported in the current
- * OpenGL context accessible via ctxInfo.
- */
- GrGLSLCaps(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*,
- const GrGLCaps&);
-
- /**
- * 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* fbFetchColorName() const { return fFBFetchColorName; }
-
- const char* fbFetchExtensionString() const { return fFBFetchExtensionString; }
-
- bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
-
- AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
-
- bool mustEnableAdvBlendEqs() const {
- return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction;
- }
-
- bool mustEnableSpecificAdvBlendEqs() const {
- return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction;
- }
-
- bool mustDeclareFragmentShaderOutput() const {
- return fGLSLGeneration > k110_GrGLSLGeneration;
- }
-
- GrGLSLGeneration generation() const { return fGLSLGeneration; }
-
- /**
- * Returns a string containing the caps info.
- */
- SkString dump() const override;
-
-private:
- // Must be called after fGeometryShaderSupport is initialized.
- void initShaderPrecisionTable(const GrGLContextInfo&, const GrGLInterface*);
-
- GrGLSLGeneration fGLSLGeneration;
-
- bool fDropsTileOnZeroDivide : 1;
- bool fFBFetchSupport : 1;
- bool fFBFetchNeedsCustomOutput : 1;
- bool fBindlessTextureSupport : 1;
-
- const char* fFBFetchColorName;
- const char* fFBFetchExtensionString;
-
- AdvBlendEqInteraction fAdvBlendEqInteraction;
-
- friend class GrGLCaps; // For initialization.
-
- typedef GrShaderCaps INHERITED;
-};
-
-
#endif
*/
#include "GrGLContext.h"
+#include "GrGLGLSL.h"
////////////////////////////////////////////////////////////////////////////////
return NULL;
}
- if (!GrGetGLSLGeneration(interface, &args.fGLSLGeneration)) {
+ if (!GrGLGetGLSLGeneration(interface, &args.fGLSLGeneration)) {
return NULL;
}
#include "gl/GrGLExtensions.h"
#include "gl/GrGLInterface.h"
#include "GrGLCaps.h"
-#include "GrGLSL.h"
#include "GrGLUtil.h"
struct GrContextOptions;
--- /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.
+ */
+
+#include "GrGLGLSL.h"
+#include "GrGLShaderVar.h"
+#include "SkString.h"
+
+bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
+ SkASSERT(generation);
+ GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
+ if (GR_GLSL_INVALID_VER == ver) {
+ return false;
+ }
+ switch (gl->fStandard) {
+ case kGL_GrGLStandard:
+ SkASSERT(ver >= GR_GLSL_VER(1,10));
+ if (ver >= GR_GLSL_VER(3,30)) {
+ *generation = k330_GrGLSLGeneration;
+ } else if (ver >= GR_GLSL_VER(1,50)) {
+ *generation = k150_GrGLSLGeneration;
+ } else if (ver >= GR_GLSL_VER(1,40)) {
+ *generation = k140_GrGLSLGeneration;
+ } else if (ver >= GR_GLSL_VER(1,30)) {
+ *generation = k130_GrGLSLGeneration;
+ } else {
+ *generation = k110_GrGLSLGeneration;
+ }
+ return true;
+ case kGLES_GrGLStandard:
+ SkASSERT(ver >= GR_GL_VER(1,00));
+ if (ver >= GR_GLSL_VER(3,1)) {
+ *generation = k310es_GrGLSLGeneration;
+ }
+ else if (ver >= GR_GLSL_VER(3,0)) {
+ *generation = k330_GrGLSLGeneration;
+ } else {
+ *generation = k110_GrGLSLGeneration;
+ }
+ return true;
+ default:
+ SkFAIL("Unknown GL Standard");
+ return false;
+ }
+}
+
+const char* GrGLGetGLSLVersionDecl(const GrGLContextInfo& info) {
+ switch (info.glslGeneration()) {
+ case k110_GrGLSLGeneration:
+ if (kGLES_GrGLStandard == info.standard()) {
+ // ES2s shader language is based on version 1.20 but is version
+ // 1.00 of the ES language.
+ return "#version 100\n";
+ } else {
+ SkASSERT(kGL_GrGLStandard == info.standard());
+ return "#version 110\n";
+ }
+ case k130_GrGLSLGeneration:
+ SkASSERT(kGL_GrGLStandard == info.standard());
+ return "#version 130\n";
+ case k140_GrGLSLGeneration:
+ SkASSERT(kGL_GrGLStandard == info.standard());
+ return "#version 140\n";
+ case k150_GrGLSLGeneration:
+ SkASSERT(kGL_GrGLStandard == info.standard());
+ if (info.caps()->isCoreProfile()) {
+ return "#version 150\n";
+ } else {
+ return "#version 150 compatibility\n";
+ }
+ case k330_GrGLSLGeneration:
+ if (kGLES_GrGLStandard == info.standard()) {
+ return "#version 300 es\n";
+ } else {
+ SkASSERT(kGL_GrGLStandard == info.standard());
+ if (info.caps()->isCoreProfile()) {
+ return "#version 330\n";
+ } else {
+ return "#version 330 compatibility\n";
+ }
+ }
+ case k310es_GrGLSLGeneration:
+ SkASSERT(kGLES_GrGLStandard == info.standard());
+ return "#version 310 es\n";
+ }
+ return "<no version>";
+}
+
+void GrGLAppendGLSLDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandard s, SkString* out) {
+ // Desktop GLSL has added precision qualifiers but they don't do anything.
+ if (kGLES_GrGLStandard == s) {
+ switch (p) {
+ case kHigh_GrSLPrecision:
+ out->append("precision highp float;\n");
+ break;
+ case kMedium_GrSLPrecision:
+ out->append("precision mediump float;\n");
+ break;
+ case kLow_GrSLPrecision:
+ out->append("precision lowp float;\n");
+ break;
+ default:
+ SkFAIL("Unknown precision value.");
+ }
+ }
+}
--- /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 GrGLInitGLSL_DEFINED
+#define GrGLInitGLSL_DEFINED
+
+#include "gl/GrGLInterface.h"
+#include "glsl/GrGLSL.h"
+#include "GrColor.h"
+#include "GrTypesPriv.h"
+#include "SkString.h"
+
+class GrGLContextInfo;
+
+/**
+ * Gets the most recent GLSL Generation compatible with the OpenGL context.
+ */
+bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation);
+
+/**
+ * Returns a string to include at the beginning of a shader to declare the GLSL
+ * version.
+ */
+const char* GrGLGetGLSLVersionDecl(const GrGLContextInfo&);
+
+/**
+ * Adds a line of GLSL code to declare the default precision for float types.
+ */
+void GrGLAppendGLSLDefaultFloatPrecisionDeclaration(GrSLPrecision, GrGLStandard, SkString* out);
+
+
+#endif
#include "GrGLGpu.h"
+#include "GrGLGLSL.h"
#include "GrGLStencilAttachment.h"
#include "GrGLTextureRenderTarget.h"
#include "GrGpuResourcePriv.h"
#include "GrTypes.h"
#include "GrVertices.h"
#include "builders/GrGLShaderStringBuilder.h"
+#include "glsl/GrGLSLCaps.h"
#include "SkStrokeRec.h"
#include "SkTemplates.h"
void GrGLGpu::createCopyProgram() {
- const char* version = GrGetGLSLVersionDecl(this->ctxInfo());
+ const char* version = GrGLGetGLSLVersionDecl(this->ctxInfo());
GrGLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
GrGLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
);
SkString fshaderTxt(version);
- GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, this->glStandard(),
- &fshaderTxt);
+ GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, this->glStandard(),
+ &fshaderTxt);
vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
vTexCoord.appendDecl(this->ctxInfo(), &fshaderTxt);
fshaderTxt.append(";");
#include "GrGLPathProcessor.h"
#include "GrGLPathRendering.h"
#include "GrGLShaderVar.h"
-#include "GrGLSL.h"
#include "GrGLXferProcessor.h"
#include "GrPathProcessor.h"
#include "GrPipeline.h"
#include "builders/GrGLProgramBuilder.h"
#include "GrGLContext.h"
#include "GrGLProgramDesc.h"
-#include "GrGLSL.h"
#include "GrGLTexture.h"
#include "GrGLProgramDataManager.h"
#define GrGLProgramDataManager_DEFINED
#include "gl/GrGLShaderVar.h"
-#include "gl/GrGLSL.h"
#include "GrAllocator.h"
#include "SkTArray.h"
+++ /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.
- */
-
-#include "GrGLSL.h"
-#include "GrGLShaderVar.h"
-#include "SkString.h"
-
-bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
- SkASSERT(generation);
- GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
- if (GR_GLSL_INVALID_VER == ver) {
- return false;
- }
- switch (gl->fStandard) {
- case kGL_GrGLStandard:
- SkASSERT(ver >= GR_GLSL_VER(1,10));
- if (ver >= GR_GLSL_VER(3,30)) {
- *generation = k330_GrGLSLGeneration;
- } else if (ver >= GR_GLSL_VER(1,50)) {
- *generation = k150_GrGLSLGeneration;
- } else if (ver >= GR_GLSL_VER(1,40)) {
- *generation = k140_GrGLSLGeneration;
- } else if (ver >= GR_GLSL_VER(1,30)) {
- *generation = k130_GrGLSLGeneration;
- } else {
- *generation = k110_GrGLSLGeneration;
- }
- return true;
- case kGLES_GrGLStandard:
- SkASSERT(ver >= GR_GL_VER(1,00));
- if (ver >= GR_GLSL_VER(3,1)) {
- *generation = k310es_GrGLSLGeneration;
- }
- else if (ver >= GR_GLSL_VER(3,0)) {
- *generation = k330_GrGLSLGeneration;
- } else {
- *generation = k110_GrGLSLGeneration;
- }
- return true;
- default:
- SkFAIL("Unknown GL Standard");
- return false;
- }
-}
-
-const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
- switch (info.glslGeneration()) {
- case k110_GrGLSLGeneration:
- if (kGLES_GrGLStandard == info.standard()) {
- // ES2s shader language is based on version 1.20 but is version
- // 1.00 of the ES language.
- return "#version 100\n";
- } else {
- SkASSERT(kGL_GrGLStandard == info.standard());
- return "#version 110\n";
- }
- case k130_GrGLSLGeneration:
- SkASSERT(kGL_GrGLStandard == info.standard());
- return "#version 130\n";
- case k140_GrGLSLGeneration:
- SkASSERT(kGL_GrGLStandard == info.standard());
- return "#version 140\n";
- case k150_GrGLSLGeneration:
- SkASSERT(kGL_GrGLStandard == info.standard());
- if (info.caps()->isCoreProfile()) {
- return "#version 150\n";
- } else {
- return "#version 150 compatibility\n";
- }
- case k330_GrGLSLGeneration:
- if (kGLES_GrGLStandard == info.standard()) {
- return "#version 300 es\n";
- } else {
- SkASSERT(kGL_GrGLStandard == info.standard());
- if (info.caps()->isCoreProfile()) {
- return "#version 330\n";
- } else {
- return "#version 330 compatibility\n";
- }
- }
- case k310es_GrGLSLGeneration:
- SkASSERT(kGLES_GrGLStandard == info.standard());
- return "#version 310 es\n";
- }
- return "<no version>";
-}
-
-bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) {
- switch (gen) {
- case k110_GrGLSLGeneration:
- return false;
- case k130_GrGLSLGeneration:
- case k140_GrGLSLGeneration:
- case k150_GrGLSLGeneration:
- case k330_GrGLSLGeneration:
- case k310es_GrGLSLGeneration:
- return true;
- }
- return false;
-}
-
-void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandard s, SkString* out) {
- // Desktop GLSL has added precision qualifiers but they don't do anything.
- if (kGLES_GrGLStandard == s) {
- switch (p) {
- case kHigh_GrSLPrecision:
- out->append("precision highp float;\n");
- break;
- case kMedium_GrSLPrecision:
- out->append("precision mediump float;\n");
- break;
- case kLow_GrSLPrecision:
- out->append("precision lowp float;\n");
- break;
- default:
- SkFAIL("Unknown precision value.");
- }
- }
-}
-
-void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSLExpr4& mulFactor) {
- if (mulFactor.isOnes()) {
- *outAppend = SkString();
- }
-
- if (mulFactor.isZeros()) {
- outAppend->appendf("%s = vec4(0);", vec4VarName);
- } else {
- outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str());
- }
-}
+++ /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 "gl/GrGLInterface.h"
-#include "GrColor.h"
-#include "GrTypesPriv.h"
-#include "SkString.h"
-
-class GrGLContextInfo;
-class GrGLShaderVar;
-
-// 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,
- /**
- * ES GLSL 3.10 only TODO Make GLSLCap objects to make this more granular
- */
- k310es_GrGLSLGeneration,
-};
-
-/**
- * Gets the most recent GLSL Generation compatible with the OpenGL context.
- */
-bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation);
-
-bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration);
-
-/**
- * Returns a string to include at the beginning of a shader to declare the GLSL
- * version.
- */
-const char* GrGetGLSLVersionDecl(const GrGLContextInfo&);
-
-/**
- * Adds a line of GLSL code to declare the default precision for float types.
- */
-void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision, GrGLStandard, SkString* out);
-
-/**
- * Gets the name of the function that should be used to sample a 2D texture. Coord type is used
- * to indicate whether the texture is sampled using projective textured (kVec3f) or not (kVec2f).
- */
-inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrGLSLGeneration glslGen) {
- if (kVec2f_GrSLType == coordType) {
- return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D";
- } else {
- SkASSERT(kVec3f_GrSLType == coordType);
- return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj";
- }
-}
-
-/**
- * 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 kMat33f_GrSLType:
- return "mat3";
- case kMat44f_GrSLType:
- return "mat4";
- case kSampler2D_GrSLType:
- return "sampler2D";
- default:
- 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 (NULL == 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
#define GrGLShaderVar_DEFINED
#include "GrGLContext.h"
-#include "GrGLSL.h"
#include "GrShaderVar.h"
#define USE_UNIFORM_FLOAT_ARRAYS true
#include "GrGLFragmentShaderBuilder.h"
#include "GrGLProgramBuilder.h"
-#include "../GrGLGpu.h"
+#include "gl/GrGLGpu.h"
+#include "gl/GrGLGLSL.h"
+#include "glsl/GrGLSLCaps.h"
#define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X)
#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(), R, X)
bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId,
SkTDArray<GrGLuint>* shaderIds) {
GrGLGpu* gpu = fProgramBuilder->gpu();
- this->versionDecl() = GrGetGLSLVersionDecl(gpu->ctxInfo());
- GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
- gpu->glStandard(),
- &this->precisionQualifier());
+ this->versionDecl() = GrGLGetGLSLVersionDecl(gpu->ctxInfo());
+ GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
+ gpu->glStandard(),
+ &this->precisionQualifier());
this->compileAndAppendLayoutQualifiers();
fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kFragment_Visibility,
&this->uniforms());
#include "gl/GrGLSLPrettyPrint.h"
#include "gl/GrGLUniformHandle.h"
#include "gl/GrGLXferProcessor.h"
+#include "glsl/GrGLSLCaps.h"
#include "GrAutoLocaleSetter.h"
#include "GrCoordTransform.h"
#include "GrGLProgramBuilder.h"
#include "GrGLShaderStringBuilder.h"
#include "../GrGLGpu.h"
#include "../GrGLShaderVar.h"
+#include "glsl/GrGLSLCaps.h"
namespace {
void append_texture_lookup(SkString* out,
#include "GrGLVertexShaderBuilder.h"
#include "GrGLProgramBuilder.h"
+#include "../GrGLGLSL.h"
#include "../GrGLGpu.h"
#define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X)
bool
GrGLVertexBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds) {
- this->versionDecl() = GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo());
+ this->versionDecl() = GrGLGetGLSLVersionDecl(fProgramBuilder->ctxInfo());
this->compileAndAppendLayoutQualifiers();
fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility, &this->uniforms());
this->appendDecls(fInputs, &this->inputs());
--- /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.
+ */
+
+#include "GrGLSL.h"
+#include "SkString.h"
+
+bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) {
+ switch (gen) {
+ case k110_GrGLSLGeneration:
+ return false;
+ case k130_GrGLSLGeneration:
+ case k140_GrGLSLGeneration:
+ case k150_GrGLSLGeneration:
+ case k330_GrGLSLGeneration:
+ case k310es_GrGLSLGeneration:
+ return true;
+ }
+ return false;
+}
+
+void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSLExpr4& mulFactor) {
+ if (mulFactor.isOnes()) {
+ *outAppend = SkString();
+ }
+
+ if (mulFactor.isZeros()) {
+ outAppend->appendf("%s = vec4(0);", vec4VarName);
+ } else {
+ outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str());
+ }
+}
--- /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"
+
+// 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,
+ /**
+ * ES GLSL 3.10 only TODO Make GLSLCap objects to make this more granular
+ */
+ k310es_GrGLSLGeneration,
+};
+
+bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration);
+
+/**
+ * Gets the name of the function that should be used to sample a 2D texture. Coord type is used
+ * to indicate whether the texture is sampled using projective textured (kVec3f) or not (kVec2f).
+ */
+inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrGLSLGeneration glslGen) {
+ if (kVec2f_GrSLType == coordType) {
+ return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D";
+ } else {
+ SkASSERT(kVec3f_GrSLType == coordType);
+ return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj";
+ }
+}
+
+/**
+ * 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 kMat33f_GrSLType:
+ return "mat3";
+ case kMat44f_GrSLType:
+ return "mat4";
+ case kSampler2D_GrSLType:
+ return "sampler2D";
+ default:
+ 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 (NULL == 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"
+
+////////////////////////////////////////////////////////////////////////////////////////////
+
+GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
+ fDropsTileOnZeroDivide = false;
+ fFBFetchSupport = false;
+ fFBFetchNeedsCustomOutput = false;
+ fBindlessTextureSupport = false;
+ fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
+ fFBFetchColorName = NULL;
+ fFBFetchExtensionString = NULL;
+}
+
+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("Advanced blend equation interaction: %s\n",
+ kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]);
+ return r;
+}
+
--- /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"
+
+class GrGLSLCaps : public GrShaderCaps {
+public:
+ SK_DECLARE_INST_COUNT(GrGLSLCaps)
+
+ /**
+ * 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* fbFetchColorName() const { return fFBFetchColorName; }
+
+ const char* fbFetchExtensionString() const { return fFBFetchExtensionString; }
+
+ bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
+
+ AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
+
+ bool mustEnableAdvBlendEqs() const {
+ return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction;
+ }
+
+ bool mustEnableSpecificAdvBlendEqs() const {
+ return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction;
+ }
+
+ bool mustDeclareFragmentShaderOutput() const {
+ return fGLSLGeneration > k110_GrGLSLGeneration;
+ }
+
+ GrGLSLGeneration generation() const { return fGLSLGeneration; }
+
+ /**
+ * Returns a string containing the caps info.
+ */
+ SkString dump() const override;
+
+private:
+ GrGLSLGeneration fGLSLGeneration;
+
+ bool fDropsTileOnZeroDivide : 1;
+ bool fFBFetchSupport : 1;
+ bool fFBFetchNeedsCustomOutput : 1;
+ bool fBindlessTextureSupport : 1;
+
+ const char* fFBFetchColorName;
+ const char* fFBFetchExtensionString;
+
+ AdvBlendEqInteraction fAdvBlendEqInteraction;
+
+ friend class GrGLCaps; // For initialization.
+
+ typedef GrShaderCaps INHERITED;
+};
+
+
+#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