Merge GrGLSLShaderVar and GrShaderVar
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5087
Change-Id: Ib8943a1da1ea495554feaf5b0992b94fbb9539ab
Reviewed-on: https://skia-review.googlesource.com/5087
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/bench/GLInstancedArraysBench.cpp b/bench/GLInstancedArraysBench.cpp
index a97e6c8..ca20673 100644
--- a/bench/GLInstancedArraysBench.cpp
+++ b/bench/GLInstancedArraysBench.cpp
@@ -11,12 +11,12 @@
#if SK_SUPPORT_GPU
#include "GLBench.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 "glsl/GrGLSLShaderVar.h"
/*
* This is a native GL benchmark for instanced arrays vs vertex buffer objects. To benchmark this
@@ -111,9 +111,9 @@
const char* version = glslCaps->versionDeclString();
// setup vertex shader
- GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrGLSLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
aPosition.appendDecl(glslCaps, &vshaderTxt);
@@ -131,7 +131,7 @@
"}\n");
// setup fragment shader
- GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
oColor.setTypeModifier(GrShaderVar::kIn_TypeModifier);
diff --git a/bench/GLVec4ScalarBench.cpp b/bench/GLVec4ScalarBench.cpp
index 01eda88..0da0a0d 100644
--- a/bench/GLVec4ScalarBench.cpp
+++ b/bench/GLVec4ScalarBench.cpp
@@ -11,12 +11,12 @@
#if SK_SUPPORT_GPU
#include "GLBench.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 "glsl/GrGLSLShaderVar.h"
#include <stdio.h>
@@ -101,10 +101,10 @@
// corner of the screen than the previous circle.
// set up vertex shader; this is a trivial vertex shader that passes through position and color
- GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrGLSLShaderVar oPosition("o_position", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
- GrGLSLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar oPosition("o_position", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
aPosition.appendDecl(glslCaps, &vshaderTxt);
@@ -129,7 +129,7 @@
// coded center and compare that to some hard-coded circle radius to compute a coverage.
// Then, this coverage is mixed with the coverage from the previous stage and passed to the
// next stage.
- GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
oPosition.setTypeModifier(GrShaderVar::kIn_TypeModifier);
diff --git a/bench/GLVertexAttributesBench.cpp b/bench/GLVertexAttributesBench.cpp
index 1bd4ff3..c588f9b 100644
--- a/bench/GLVertexAttributesBench.cpp
+++ b/bench/GLVertexAttributesBench.cpp
@@ -11,12 +11,12 @@
#if SK_SUPPORT_GPU
#include "GLBench.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 "glsl/GrGLSLShaderVar.h"
#include <stdio.h>
/*
@@ -69,9 +69,9 @@
const char* version = glslCaps->versionDeclString();
// setup vertex shader
- GrGLSLShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kIn_TypeModifier);
- SkTArray<GrGLSLShaderVar> aVars;
- SkTArray<GrGLSLShaderVar> oVars;
+ GrShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ SkTArray<GrShaderVar> aVars;
+ SkTArray<GrShaderVar> oVars;
SkString vshaderTxt(version);
aPosition.appendDecl(glslCaps, &vshaderTxt);
@@ -80,9 +80,9 @@
for (uint32_t i = 0; i < attribs; i++) {
SkString aname;
aname.appendf("a_color_%d", i);
- aVars.push_back(GrGLSLShaderVar(aname.c_str(),
- kVec4f_GrSLType,
- GrShaderVar::kIn_TypeModifier));
+ aVars.push_back(GrShaderVar(aname.c_str(),
+ kVec4f_GrSLType,
+ GrShaderVar::kIn_TypeModifier));
aVars.back().appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
@@ -91,9 +91,9 @@
for (uint32_t i = 0; i < maxAttribs; i++) {
SkString oname;
oname.appendf("o_color_%d", i);
- oVars.push_back(GrGLSLShaderVar(oname.c_str(),
- kVec4f_GrSLType,
- GrShaderVar::kOut_TypeModifier));
+ oVars.push_back(GrShaderVar(oname.c_str(),
+ kVec4f_GrSLType,
+ GrShaderVar::kOut_TypeModifier));
oVars.back().appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
}
@@ -115,7 +115,7 @@
vshaderTxt.append("}\n");
// setup fragment shader
- GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
index da13732..1dcd8de 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
@@ -774,15 +774,15 @@
const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec2(1.0)), %s);";
// Add noise function
- static const GrGLSLShaderVar gPerlinNoiseArgs[] = {
- GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
- GrGLSLShaderVar(noiseVec, kVec2f_GrSLType)
+ static const GrShaderVar gPerlinNoiseArgs[] = {
+ GrShaderVar(chanCoord, kFloat_GrSLType),
+ GrShaderVar(noiseVec, kVec2f_GrSLType)
};
- static const GrGLSLShaderVar gPerlinNoiseStitchArgs[] = {
- GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
- GrGLSLShaderVar(noiseVec, kVec2f_GrSLType),
- GrGLSLShaderVar(stitchData, kVec2f_GrSLType)
+ static const GrShaderVar gPerlinNoiseStitchArgs[] = {
+ GrShaderVar(chanCoord, kFloat_GrSLType),
+ GrShaderVar(noiseVec, kVec2f_GrSLType),
+ GrShaderVar(stitchData, kVec2f_GrSLType)
};
SkString noiseCode;
@@ -1157,8 +1157,8 @@
const char* zUni = uniformHandler->getUniformCStr(fZUni);
// fade function
- static const GrGLSLShaderVar fadeArgs[] = {
- GrGLSLShaderVar("t", kVec3f_GrSLType)
+ static const GrShaderVar fadeArgs[] = {
+ GrShaderVar("t", kVec3f_GrSLType)
};
SkString fadeFuncName;
fsBuilder->emitFunction(kVec3f_GrSLType, "fade", SK_ARRAY_COUNT(fadeArgs),
@@ -1167,8 +1167,8 @@
&fadeFuncName);
// perm function
- static const GrGLSLShaderVar permArgs[] = {
- GrGLSLShaderVar("x", kFloat_GrSLType)
+ static const GrShaderVar permArgs[] = {
+ GrShaderVar("x", kFloat_GrSLType)
};
SkString permFuncName;
SkString permCode("return ");
@@ -1181,9 +1181,9 @@
permCode.c_str(), &permFuncName);
// grad function
- static const GrGLSLShaderVar gradArgs[] = {
- GrGLSLShaderVar("x", kFloat_GrSLType),
- GrGLSLShaderVar("p", kVec3f_GrSLType)
+ static const GrShaderVar gradArgs[] = {
+ GrShaderVar("x", kFloat_GrSLType),
+ GrShaderVar("p", kVec3f_GrSLType)
};
SkString gradFuncName;
SkString gradCode("return dot(");
@@ -1194,18 +1194,18 @@
gradCode.c_str(), &gradFuncName);
// lerp function
- static const GrGLSLShaderVar lerpArgs[] = {
- GrGLSLShaderVar("a", kFloat_GrSLType),
- GrGLSLShaderVar("b", kFloat_GrSLType),
- GrGLSLShaderVar("w", kFloat_GrSLType)
+ static const GrShaderVar lerpArgs[] = {
+ GrShaderVar("a", kFloat_GrSLType),
+ GrShaderVar("b", kFloat_GrSLType),
+ GrShaderVar("w", kFloat_GrSLType)
};
SkString lerpFuncName;
fsBuilder->emitFunction(kFloat_GrSLType, "lerp", SK_ARRAY_COUNT(lerpArgs), lerpArgs,
"return a + w * (b - a);", &lerpFuncName);
// noise function
- static const GrGLSLShaderVar noiseArgs[] = {
- GrGLSLShaderVar("p", kVec3f_GrSLType),
+ static const GrShaderVar noiseArgs[] = {
+ GrShaderVar("p", kVec3f_GrSLType),
};
SkString noiseFuncName;
SkString noiseCode;
@@ -1241,9 +1241,9 @@
noiseCode.c_str(), &noiseFuncName);
// noiseOctaves function
- static const GrGLSLShaderVar noiseOctavesArgs[] = {
- GrGLSLShaderVar("p", kVec3f_GrSLType),
- GrGLSLShaderVar("octaves", kFloat_GrSLType),
+ static const GrShaderVar noiseOctavesArgs[] = {
+ GrShaderVar("p", kVec3f_GrSLType),
+ GrShaderVar("octaves", kFloat_GrSLType),
};
SkString noiseOctavesFuncName;
SkString noiseOctavesCode;
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 84b3624..fca4939 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -185,6 +185,7 @@
"$_src/gpu/GrTraceMarker.h",
"$_src/gpu/GrTracing.h",
"$_src/gpu/GrTestUtils.cpp",
+ "$_src/gpu/GrShaderVar.cpp",
"$_src/gpu/GrSWMaskHelper.cpp",
"$_src/gpu/GrSWMaskHelper.h",
"$_src/gpu/GrSoftwarePathRenderer.cpp",
@@ -421,7 +422,6 @@
"$_src/gpu/glsl/GrGLSLProgramDataManager.h",
"$_src/gpu/glsl/GrGLSLShaderBuilder.cpp",
"$_src/gpu/glsl/GrGLSLShaderBuilder.h",
- "$_src/gpu/glsl/GrGLSLShaderVar.h",
"$_src/gpu/glsl/GrGLSLUniformHandler.h",
"$_src/gpu/glsl/GrGLSLUtil.cpp",
"$_src/gpu/glsl/GrGLSLUtil.h",
diff --git a/include/gpu/GrShaderVar.h b/include/gpu/GrShaderVar.h
index 60e951c..81a7566 100644
--- a/include/gpu/GrShaderVar.h
+++ b/include/gpu/GrShaderVar.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Google Inc.
+ * Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
@@ -8,20 +8,18 @@
#ifndef GrShaderVar_DEFINED
#define GrShaderVar_DEFINED
-#include "GrTypesPriv.h"
#include "SkString.h"
+#include "GrTypesPriv.h"
+class GrGLSLCaps;
+
+#define USE_UNIFORM_FLOAT_ARRAYS true
+
+/**
+ * Represents a variable in a shader
+ */
class GrShaderVar {
public:
- /**
- * Early versions of GLSL have Varying and Attribute; those are later
- * deprecated, but we still need to know whether a Varying variable
- * should be treated as In or Out.
- *
- * TODO This really shouldn't live here, but until we have c++11, there is really no good way
- * to write extensible enums. In reality, only none, out, in, inout, and uniform really
- * make sense on this base class
- */
enum TypeModifier {
kNone_TypeModifier,
kOut_TypeModifier,
@@ -31,77 +29,178 @@
};
/**
- * Defaults to a float with no precision specifier
- */
- GrShaderVar()
- : fType(kFloat_GrSLType)
- , fTypeModifier(kNone_TypeModifier)
- , fCount(kNonArray)
- , fPrecision(kDefault_GrSLPrecision) {
- }
-
- GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray,
- GrSLPrecision precision = kDefault_GrSLPrecision)
- : fType(type)
- , fTypeModifier(kNone_TypeModifier)
- , fName(name)
- , fCount(arrayCount)
- , fPrecision(precision) {
- SkASSERT(kVoid_GrSLType != type);
- }
-
- GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
- GrSLPrecision precision = kDefault_GrSLPrecision)
- : fType(type)
- , fTypeModifier(kNone_TypeModifier)
- , fName(name)
- , fCount(arrayCount)
- , fPrecision(precision) {
- SkASSERT(kVoid_GrSLType != type);
- }
-
- GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
- int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
- : fType(type)
- , fTypeModifier(typeModifier)
- , fName(name)
- , fCount(arrayCount)
- , fPrecision(precision) {
- SkASSERT(kVoid_GrSLType != type);
- }
-
- /**
- * Values for array count that have special meaning. We allow 1-sized arrays.
+ * Values for array count that have special meaning. We allow 1-sized arrays.git
*/
enum {
kNonArray = 0, // not an array
kUnsizedArray = -1, // an unsized array (declared with [])
};
+ /**
+ * Defaults to a non-arry float with no precision specifier, type modifier, or layout qualifier.
+ */
+ GrShaderVar()
+ : fType(kFloat_GrSLType)
+ , fTypeModifier(kNone_TypeModifier)
+ , fCount(kNonArray)
+ , fPrecision(kDefault_GrSLPrecision)
+ , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
+ }
+
+ GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray,
+ GrSLPrecision precision = kDefault_GrSLPrecision)
+ : fType(type)
+ , fTypeModifier(kNone_TypeModifier)
+ , fCount(arrayCount)
+ , fPrecision(precision)
+ , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
+ , fName(name) {
+ SkASSERT(kVoid_GrSLType != type);
+ fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
+ }
+
+ GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
+ GrSLPrecision precision = kDefault_GrSLPrecision)
+ : fType(type)
+ , fTypeModifier(kNone_TypeModifier)
+ , fCount(arrayCount)
+ , fPrecision(precision)
+ , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
+ , fName(name) {
+ SkASSERT(kVoid_GrSLType != type);
+ fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
+ }
+
+ GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
+ GrSLPrecision precision = kDefault_GrSLPrecision)
+ : fType(type)
+ , fTypeModifier(typeModifier)
+ , fCount(kNonArray)
+ , fPrecision(precision)
+ , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
+ , fName(name) {
+ SkASSERT(kVoid_GrSLType != type);
+ }
+
+ GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
+ int arrayCount, GrSLPrecision precision = kDefault_GrSLPrecision)
+ : fType(type)
+ , fTypeModifier(typeModifier)
+ , fCount(arrayCount)
+ , fPrecision(precision)
+ , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
+ , fName(name) {
+ SkASSERT(kVoid_GrSLType != type);
+ }
+
+ GrShaderVar(const GrShaderVar& that)
+ : fType(that.fType)
+ , fTypeModifier(that.fTypeModifier)
+ , fCount(that.fCount)
+ , fPrecision(that.fPrecision)
+ , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
+ , fName(that.fName)
+ , fLayoutQualifier(that.fLayoutQualifier)
+ , fExtraModifiers(that.fExtraModifiers) {
+ SkASSERT(kVoid_GrSLType != that.getType());
+ }
+
+ /**
+ * Sets as a non-array.
+ */
void set(GrSLType type,
const SkString& name,
TypeModifier typeModifier = kNone_TypeModifier,
GrSLPrecision precision = kDefault_GrSLPrecision,
- int count = kNonArray) {
+ const char* layoutQualifier = nullptr,
+ const char* extraModifiers = nullptr,
+ bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
- fCount = count;
+ fCount = kNonArray;
fPrecision = precision;
+ fLayoutQualifier = layoutQualifier;
+ if (extraModifiers) {
+ fExtraModifiers.printf("%s ", extraModifiers);
+ }
+ fUseUniformFloatArrays = useUniformFloatArrays;
}
+ /**
+ * Sets as a non-array.
+ */
void set(GrSLType type,
const char* name,
TypeModifier typeModifier = kNone_TypeModifier,
GrSLPrecision precision = kDefault_GrSLPrecision,
- int count = kNonArray) {
+ const char* layoutQualifier = nullptr,
+ const char* extraModifiers = nullptr,
+ bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
+ fType = type;
+ fTypeModifier = typeModifier;
+ fName = name;
+ fCount = kNonArray;
+ fPrecision = precision;
+ fLayoutQualifier = layoutQualifier;
+ if (extraModifiers) {
+ fExtraModifiers.printf("%s ", extraModifiers);
+ }
+ fUseUniformFloatArrays = useUniformFloatArrays;
+ }
+
+ /**
+ * Set all var options
+ */
+ void set(GrSLType type,
+ const SkString& name,
+ int count,
+ TypeModifier typeModifier,
+ GrSLPrecision precision = kDefault_GrSLPrecision,
+ const char* layoutQualifier = nullptr,
+ const char* extraModifiers = nullptr,
+ bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
+ SkASSERT(kVoid_GrSLType != type);
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
fCount = count;
fPrecision = precision;
+ fLayoutQualifier = layoutQualifier;
+ if (extraModifiers) {
+ fExtraModifiers.printf("%s ", extraModifiers);
+ }
+ fUseUniformFloatArrays = useUniformFloatArrays;
+ }
+
+ /**
+ * Set all var options
+ */
+ void set(GrSLType type,
+ const char* name,
+ int count,
+ TypeModifier typeModifier,
+ GrSLPrecision precision = kDefault_GrSLPrecision,
+ const char* layoutQualifier = nullptr,
+ const char* extraModifiers = nullptr,
+ bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
+ SkASSERT(kVoid_GrSLType != type);
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
+ fType = type;
+ fTypeModifier = typeModifier;
+ fName = name;
+ fCount = count;
+ fPrecision = precision;
+ fLayoutQualifier = layoutQualifier;
+ if (extraModifiers) {
+ fExtraModifiers.printf("%s ", extraModifiers);
+ }
+ fUseUniformFloatArrays = useUniformFloatArrays;
}
/**
@@ -171,12 +270,67 @@
*/
void setPrecision(GrSLPrecision p) { fPrecision = p; }
-protected:
+ /**
+ * Set the layout qualifier
+ */
+ void setLayoutQualifier(const char* layoutQualifier) {
+ fLayoutQualifier = layoutQualifier;
+ }
+
+ void addModifier(const char* modifier) {
+ if (modifier) {
+ fExtraModifiers.appendf("%s ", modifier);
+ }
+ }
+
+ /**
+ * Write a declaration of this variable to out.
+ */
+ void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const;
+
+ void appendArrayAccess(int index, SkString* out) const {
+ out->appendf("%s[%d]%s",
+ this->getName().c_str(),
+ index,
+ fUseUniformFloatArrays ? "" : ".x");
+ }
+
+ void appendArrayAccess(const char* indexName, SkString* out) const {
+ out->appendf("%s[%s]%s",
+ this->getName().c_str(),
+ indexName,
+ fUseUniformFloatArrays ? "" : ".x");
+ }
+
+private:
+ static const char* TypeModifierString(TypeModifier t) {
+ switch (t) {
+ case kNone_TypeModifier:
+ return "";
+ case kIn_TypeModifier:
+ return "in";
+ case kInOut_TypeModifier:
+ return "inout";
+ case kOut_TypeModifier:
+ return "out";
+ case kUniform_TypeModifier:
+ return "uniform";
+ }
+ SkFAIL("Unknown shader variable type modifier.");
+ return ""; // suppress warning
+ }
+
GrSLType fType;
TypeModifier fTypeModifier;
- SkString fName;
int fCount;
GrSLPrecision fPrecision;
+ /// Work around driver bugs on some hardware that don't correctly
+ /// support uniform float []
+ bool fUseUniformFloatArrays;
+
+ SkString fName;
+ SkString fLayoutQualifier;
+ SkString fExtraModifiers;
};
-#endif
+ #endif
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index 99ce113..ed633b0 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -12,6 +12,7 @@
#include "GrInvariantOutput.h"
#include "SkRefCnt.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 237c563..b237b14 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -24,6 +24,7 @@
#include "GrInvariantOutput.h"
#include "GrStyle.h"
#include "effects/GrSimpleTextureEffect.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index b71c7eb..6b479e9 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -27,6 +27,7 @@
#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"
@@ -1801,14 +1802,14 @@
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString lightFunc;
this->emitLightFunc(uniformHandler, fragBuilder, &lightFunc);
- static const GrGLSLShaderVar gSobelArgs[] = {
- GrGLSLShaderVar("a", kFloat_GrSLType),
- GrGLSLShaderVar("b", kFloat_GrSLType),
- GrGLSLShaderVar("c", kFloat_GrSLType),
- GrGLSLShaderVar("d", kFloat_GrSLType),
- GrGLSLShaderVar("e", kFloat_GrSLType),
- GrGLSLShaderVar("f", kFloat_GrSLType),
- GrGLSLShaderVar("scale", kFloat_GrSLType),
+ static const GrShaderVar gSobelArgs[] = {
+ GrShaderVar("a", kFloat_GrSLType),
+ GrShaderVar("b", kFloat_GrSLType),
+ GrShaderVar("c", kFloat_GrSLType),
+ GrShaderVar("d", kFloat_GrSLType),
+ GrShaderVar("e", kFloat_GrSLType),
+ GrShaderVar("f", kFloat_GrSLType),
+ GrShaderVar("scale", kFloat_GrSLType),
};
SkString sobelFuncName;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
@@ -1819,10 +1820,10 @@
gSobelArgs,
"\treturn (-a + b - 2.0 * c + 2.0 * d -e + f) * scale;\n",
&sobelFuncName);
- static const GrGLSLShaderVar gPointToNormalArgs[] = {
- GrGLSLShaderVar("x", kFloat_GrSLType),
- GrGLSLShaderVar("y", kFloat_GrSLType),
- GrGLSLShaderVar("scale", kFloat_GrSLType),
+ static const GrShaderVar gPointToNormalArgs[] = {
+ GrShaderVar("x", kFloat_GrSLType),
+ GrShaderVar("y", kFloat_GrSLType),
+ GrShaderVar("scale", kFloat_GrSLType),
};
SkString pointToNormalName;
fragBuilder->emitFunction(kVec3f_GrSLType,
@@ -1832,9 +1833,9 @@
"\treturn normalize(vec3(-x * scale, -y * scale, 1));\n",
&pointToNormalName);
- static const GrGLSLShaderVar gInteriorNormalArgs[] = {
- GrGLSLShaderVar("m", kFloat_GrSLType, 9),
- GrGLSLShaderVar("surfaceScale", kFloat_GrSLType),
+ static const GrShaderVar gInteriorNormalArgs[] = {
+ GrShaderVar("m", kFloat_GrSLType, 9),
+ GrShaderVar("surfaceScale", kFloat_GrSLType),
};
SkString normalBody = emitNormalFunc(le.boundaryMode(),
pointToNormalName.c_str(),
@@ -1922,10 +1923,10 @@
kFloat_GrSLType, kDefault_GrSLPrecision,
"KD", &kd);
- static const GrGLSLShaderVar gLightArgs[] = {
- GrGLSLShaderVar("normal", kVec3f_GrSLType),
- GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType),
- GrGLSLShaderVar("lightColor", kVec3f_GrSLType)
+ static const GrShaderVar gLightArgs[] = {
+ GrShaderVar("normal", kVec3f_GrSLType),
+ GrShaderVar("surfaceToLight", kVec3f_GrSLType),
+ GrShaderVar("lightColor", kVec3f_GrSLType)
};
SkString lightBody;
lightBody.appendf("\tfloat colorScale = %s * dot(normal, surfaceToLight);\n", kd);
@@ -2017,10 +2018,10 @@
"Shininess",
&shininess);
- static const GrGLSLShaderVar gLightArgs[] = {
- GrGLSLShaderVar("normal", kVec3f_GrSLType),
- GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType),
- GrGLSLShaderVar("lightColor", kVec3f_GrSLType)
+ static const GrShaderVar gLightArgs[] = {
+ GrShaderVar("normal", kVec3f_GrSLType),
+ GrShaderVar("surfaceToLight", kVec3f_GrSLType),
+ GrShaderVar("lightColor", kVec3f_GrSLType)
};
SkString lightBody;
lightBody.appendf("\tvec3 halfDir = vec3(normalize(surfaceToLight + vec3(0, 0, 1)));\n");
@@ -2156,8 +2157,8 @@
fSUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
kVec3f_GrSLType, kDefault_GrSLPrecision, "S", &s);
- static const GrGLSLShaderVar gLightColorArgs[] = {
- GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType)
+ static const GrShaderVar gLightColorArgs[] = {
+ GrShaderVar("surfaceToLight", kVec3f_GrSLType)
};
SkString lightColorBody;
lightColorBody.appendf("\tfloat cosAngle = -dot(surfaceToLight, %s);\n", s);
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index ccff378..5b5525c 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -19,6 +19,7 @@
#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"
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index d055043..4ececb4 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -26,6 +26,7 @@
#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"
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index d0761d7..529a4fa 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -639,15 +639,15 @@
const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec2(1.0)), %s);";
// Add noise function
- static const GrGLSLShaderVar gPerlinNoiseArgs[] = {
- GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
- GrGLSLShaderVar(noiseVec, kVec2f_GrSLType)
+ static const GrShaderVar gPerlinNoiseArgs[] = {
+ GrShaderVar(chanCoord, kFloat_GrSLType),
+ GrShaderVar(noiseVec, kVec2f_GrSLType)
};
- static const GrGLSLShaderVar gPerlinNoiseStitchArgs[] = {
- GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
- GrGLSLShaderVar(noiseVec, kVec2f_GrSLType),
- GrGLSLShaderVar(stitchData, kVec2f_GrSLType)
+ static const GrShaderVar gPerlinNoiseStitchArgs[] = {
+ GrShaderVar(chanCoord, kFloat_GrSLType),
+ GrShaderVar(noiseVec, kVec2f_GrSLType),
+ GrShaderVar(stitchData, kVec2f_GrSLType)
};
SkString noiseCode;
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 39f5636..e034a1f 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "glsl/GrGLSLCaps.h"
#include "Sk4fLinearGradient.h"
#include "SkColorSpace_XYZ.h"
#include "SkGradientShaderPriv.h"
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index 1275be7..cf2a827 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -708,7 +708,7 @@
// this is the distance along x-axis from the end center to focal point in
// transformed coordinates
- GrGLSLShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
+ GrShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -958,11 +958,11 @@
"Conical2FSParams");
SkString tName("t");
- GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
+ GrShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
// params.x = A
// params.y = B
// params.z = C
- GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
+ GrShaderVar params = uniformHandler->getUniformVariable(fParamUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -1194,11 +1194,11 @@
"Conical2FSParams");
SkString tName("t");
- GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
+ GrShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
// params.x = A
// params.y = B
// params.z = C
- GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
+ GrShaderVar params = uniformHandler->getUniformVariable(fParamUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index e7a8900..a0ed383 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -17,6 +17,7 @@
#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"
diff --git a/src/gpu/GrShaderVar.cpp b/src/gpu/GrShaderVar.cpp
new file mode 100644
index 0000000..ef305cb
--- /dev/null
+++ b/src/gpu/GrShaderVar.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#include "GrShaderVar.h"
+#include "glsl/GrGLSLCaps.h"
+
+void GrShaderVar::appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
+ SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
+ if (!fLayoutQualifier.isEmpty()) {
+ out->appendf("layout(%s) ", fLayoutQualifier.c_str());
+ }
+ out->append(fExtraModifiers);
+ if (this->getTypeModifier() != kNone_TypeModifier) {
+ out->append(TypeModifierString(this->getTypeModifier()));
+ out->append(" ");
+ }
+ GrSLType effectiveType = this->getType();
+ if (glslCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) {
+ // Desktop GLSL has added precision qualifiers but they don't do anything.
+ out->appendf("%s ", GrGLSLPrecisionString(fPrecision));
+ }
+ if (this->isArray()) {
+ if (this->isUnsizedArray()) {
+ out->appendf("%s %s[]",
+ GrGLSLTypeString(effectiveType),
+ this->getName().c_str());
+ } else {
+ SkASSERT(this->getArrayCount() > 0);
+ out->appendf("%s %s[%d]",
+ GrGLSLTypeString(effectiveType),
+ this->getName().c_str(),
+ this->getArrayCount());
+ }
+ } else {
+ out->appendf("%s %s",
+ GrGLSLTypeString(effectiveType),
+ this->getName().c_str());
+ }
+}
diff --git a/src/gpu/batches/GrPLSPathRenderer.cpp b/src/gpu/batches/GrPLSPathRenderer.cpp
index e73f7f5..1aedccb 100644
--- a/src/gpu/batches/GrPLSPathRenderer.cpp
+++ b/src/gpu/batches/GrPLSPathRenderer.cpp
@@ -521,9 +521,9 @@
SkAssertResult(fsBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLFeature));
static const int QUAD_ARGS = 2;
- GrGLSLShaderVar inQuadArgs[QUAD_ARGS] = {
- GrGLSLShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision),
- GrGLSLShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision)
+ GrShaderVar inQuadArgs[QUAD_ARGS] = {
+ GrShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision),
+ GrShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision)
};
SkString inQuadName;
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 7f39b92..cd7f763 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -7,6 +7,7 @@
#include "GrBezierEffect.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
@@ -116,14 +117,14 @@
precision = kMedium_GrSLPrecision;
}
- GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, precision);
- GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, precision);
- GrGLSLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, precision);
- GrGLSLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, precision);
- GrGLSLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, precision);
- GrGLSLShaderVar gF("gF", kVec2f_GrSLType, 0, precision);
- GrGLSLShaderVar gFM("gFM", kFloat_GrSLType, 0, precision);
- GrGLSLShaderVar func("func", kFloat_GrSLType, 0, precision);
+ GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, precision);
+ GrShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, precision);
+ GrShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, precision);
+ GrShaderVar dfdx("dfdx", kFloat_GrSLType, 0, precision);
+ GrShaderVar dfdy("dfdy", kFloat_GrSLType, 0, precision);
+ GrShaderVar gF("gF", kVec2f_GrSLType, 0, precision);
+ GrShaderVar gFM("gFM", kFloat_GrSLType, 0, precision);
+ GrShaderVar func("func", kFloat_GrSLType, 0, precision);
fragBuilder->declAppend(edgeAlpha);
fragBuilder->declAppend(dklmdx);
@@ -564,14 +565,14 @@
args.fFPCoordTransformHandler);
- GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
- GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
- GrGLSLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
- GrGLSLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
- GrGLSLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
- GrGLSLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision);
- GrGLSLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
- GrGLSLShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
fragBuilder->declAppend(edgeAlpha);
fragBuilder->declAppend(dklmdx);
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 4ea358e..ce7f344 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -7,6 +7,7 @@
#include "GrBicubicEffect.h"
#include "GrInvariantOutput.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
@@ -66,13 +67,13 @@
SkString cubicBlendName;
- static const GrGLSLShaderVar gCubicBlendArgs[] = {
- GrGLSLShaderVar("coefficients", kMat44f_GrSLType),
- GrGLSLShaderVar("t", kFloat_GrSLType),
- GrGLSLShaderVar("c0", kVec4f_GrSLType),
- GrGLSLShaderVar("c1", kVec4f_GrSLType),
- GrGLSLShaderVar("c2", kVec4f_GrSLType),
- GrGLSLShaderVar("c3", kVec4f_GrSLType),
+ static const GrShaderVar gCubicBlendArgs[] = {
+ GrShaderVar("coefficients", kMat44f_GrSLType),
+ GrShaderVar("t", kFloat_GrSLType),
+ GrShaderVar("c0", kVec4f_GrSLType),
+ GrShaderVar("c1", kVec4f_GrSLType),
+ GrShaderVar("c2", kVec4f_GrSLType),
+ GrShaderVar("c3", kVec4f_GrSLType),
};
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 545d30b..6f67838 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -11,6 +11,7 @@
#include "GrInvariantOutput.h"
#include "GrSimpleTextureEffect.h"
#include "SkMatrix.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -22,7 +23,7 @@
GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion();
// Using highp for GLES here in order to avoid some precision issues on specific GPUs.
- GrGLSLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision);
SkString tmpDecl;
tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl);
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 7ad2c08..fc28ec7 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -9,6 +9,7 @@
#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"
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 05e9deb..fbca646 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -6,6 +6,7 @@
*/
#include "GrConvolutionEffect.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
@@ -58,7 +59,7 @@
fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor);
- const GrGLSLShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
+ const GrShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
fragBuilder->codeAppendf("vec2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 1fddec6..c00284b 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -9,6 +9,7 @@
#include "GrFragmentProcessor.h"
#include "GrInvariantOutput.h"
#include "SkRect.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
diff --git a/src/gpu/effects/GrGammaEffect.cpp b/src/gpu/effects/GrGammaEffect.cpp
index 63ffc32..9e98b7e 100644
--- a/src/gpu/effects/GrGammaEffect.cpp
+++ b/src/gpu/effects/GrGammaEffect.cpp
@@ -29,8 +29,8 @@
}
SkString srgbFuncName;
- static const GrGLSLShaderVar gSrgbArgs[] = {
- GrGLSLShaderVar("x", kFloat_GrSLType),
+ static const GrShaderVar gSrgbArgs[] = {
+ GrShaderVar("x", kFloat_GrSLType),
};
switch (ge.mode()) {
case GrGammaEffect::Mode::kLinearToSRGB:
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index afc24c9..0194eab 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
#include "GrMatrixConvolutionEffect.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index 97ea1e6..425d767 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -10,6 +10,8 @@
#include "GrFragmentProcessor.h"
#include "GrInvariantOutput.h"
#include "SkRect.h"
+#include "glsl/GrGLSL.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 37bb3f8..36570c9 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -13,6 +13,7 @@
#include "GrOvalEffect.h"
#include "SkRRect.h"
#include "SkTLazy.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index e3129fd..6ee5758 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -9,6 +9,7 @@
#include "GrInvariantOutput.h"
#include "GrSimpleTextureEffect.h"
#include "SkFloatingPoint.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 71b3be3..9c25602 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -334,13 +334,13 @@
const GrGLSLCaps* glslCaps = this->glCaps().glslCaps();
const char* version = glslCaps->versionDeclString();
- GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
- GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
- GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
+ GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
+ GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
if (glslCaps->noperspectiveInterpolationSupport()) {
@@ -3753,13 +3753,13 @@
}
const char* version = glslCaps->versionDeclString();
- GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
- GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar uTexture("u_texture", samplerType, GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
- GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
+ GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar uTexture("u_texture", samplerType, GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
if (glslCaps->noperspectiveInterpolationSupport()) {
@@ -3858,20 +3858,19 @@
}
const char* version = glslCaps->versionDeclString();
- GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
- GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
- GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
+ GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
+ GrShaderVar::kUniform_TypeModifier);
// We need 1, 2, or 4 texture coordinates (depending on parity of each dimension):
- GrGLSLShaderVar vTexCoords[] = {
- GrGLSLShaderVar("v_texCoord0", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
- GrGLSLShaderVar("v_texCoord1", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
- GrGLSLShaderVar("v_texCoord2", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
- GrGLSLShaderVar("v_texCoord3", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar vTexCoords[] = {
+ GrShaderVar("v_texCoord0", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar("v_texCoord1", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar("v_texCoord2", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar("v_texCoord3", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
};
- GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType,
- GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType,GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
if (glslCaps->noperspectiveInterpolationSupport()) {
@@ -4020,9 +4019,9 @@
return false;
}
- GrGLSLShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
- GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
const char* version = this->glCaps().glslCaps()->versionDeclString();
// The rect uniform specifies the rectangle in NDC space as a vec4 (left,top,right,bottom). The
@@ -4042,7 +4041,7 @@
"}"
);
- GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
diff --git a/src/gpu/gl/GrGLProgramDataManager.cpp b/src/gpu/gl/GrGLProgramDataManager.cpp
index 68d0166..3245bd7 100644
--- a/src/gpu/gl/GrGLProgramDataManager.cpp
+++ b/src/gpu/gl/GrGLProgramDataManager.cpp
@@ -12,7 +12,7 @@
#define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
SkASSERT((COUNT) <= (UNI).fArrayCount || \
- (1 == (COUNT) && GrGLSLShaderVar::kNonArray == (UNI).fArrayCount))
+ (1 == (COUNT) && GrShaderVar::kNonArray == (UNI).fArrayCount))
GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
const UniformInfoArray& uniforms,
@@ -24,7 +24,7 @@
for (int i = 0; i < count; i++) {
Uniform& uniform = fUniforms[i];
const UniformInfo& builderUniform = uniforms[i];
- SkASSERT(GrGLSLShaderVar::kNonArray == builderUniform.fVariable.getArrayCount() ||
+ SkASSERT(GrShaderVar::kNonArray == builderUniform.fVariable.getArrayCount() ||
builderUniform.fVariable.getArrayCount() > 0);
SkDEBUGCODE(
uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
@@ -40,7 +40,7 @@
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
PathProcVarying& pathProcVarying = fPathProcVaryings[i];
const VaryingInfo& builderPathProcVarying = pathProcVaryings[i];
- SkASSERT(GrGLSLShaderVar::kNonArray == builderPathProcVarying.fVariable.getArrayCount() ||
+ SkASSERT(GrShaderVar::kNonArray == builderPathProcVarying.fVariable.getArrayCount() ||
builderPathProcVarying.fVariable.getArrayCount() > 0);
SkDEBUGCODE(
pathProcVarying.fArrayCount = builderPathProcVarying.fVariable.getArrayCount();
@@ -68,7 +68,7 @@
void GrGLProgramDataManager::set1i(UniformHandle u, int32_t i) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kInt_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
SkDEBUGCODE(this->printUnused(uni));
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fLocation, i));
@@ -90,7 +90,7 @@
void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kFloat_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
SkDEBUGCODE(this->printUnused(uni);)
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fLocation, v0));
@@ -116,7 +116,7 @@
void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec2f_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
SkDEBUGCODE(this->printUnused(uni);)
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fLocation, v0, v1));
@@ -139,7 +139,7 @@
void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec3f_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
SkDEBUGCODE(this->printUnused(uni);)
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fLocation, v0, v1, v2));
@@ -166,7 +166,7 @@
float v3) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec4f_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
SkDEBUGCODE(this->printUnused(uni);)
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fLocation, v0, v1, v2, v3));
diff --git a/src/gpu/gl/GrGLProgramDataManager.h b/src/gpu/gl/GrGLProgramDataManager.h
index fa1456d..0ef902c 100644
--- a/src/gpu/gl/GrGLProgramDataManager.h
+++ b/src/gpu/gl/GrGLProgramDataManager.h
@@ -8,11 +8,10 @@
#ifndef GrGLProgramDataManager_DEFINED
#define GrGLProgramDataManager_DEFINED
-#include "glsl/GrGLSLProgramDataManager.h"
-
#include "GrAllocator.h"
+#include "GrShaderVar.h"
#include "gl/GrGLTypes.h"
-#include "glsl/GrGLSLShaderVar.h"
+#include "glsl/GrGLSLProgramDataManager.h"
#include "SkTArray.h"
@@ -27,18 +26,17 @@
class GrGLProgramDataManager : public GrGLSLProgramDataManager {
public:
struct UniformInfo {
- GrGLSLShaderVar fVariable;
+ GrShaderVar fVariable;
uint32_t fVisibility;
GrGLint fLocation;
};
struct VaryingInfo {
- GrGLSLShaderVar fVariable;
+ GrShaderVar fVariable;
GrGLint fLocation;
};
-
- // This uses an allocator rather than array so that the GrGLSLShaderVars don't move in memory
+ // This uses an allocator rather than array so that the GrShaderVars don't move in memory
// after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
// name strings. Otherwise, we'd have to hand out copies.
typedef GrTAllocator<UniformInfo> UniformInfoArray;
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index eb28e23..4a4f00b 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -7,6 +7,7 @@
#include "GrGLTexture.h"
#include "GrGLGpu.h"
+#include "glsl/GrGLSLCaps.h"
#include "SkTraceMemoryDump.h"
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
diff --git a/src/gpu/gl/GrGLUniformHandler.cpp b/src/gpu/gl/GrGLUniformHandler.cpp
index 37f2418..2def001 100644
--- a/src/gpu/gl/GrGLUniformHandler.cpp
+++ b/src/gpu/gl/GrGLUniformHandler.cpp
@@ -30,7 +30,7 @@
UniformInfo& uni = fUniforms.push_back();
uni.fVariable.setType(type);
- uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
+ uni.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
// TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
// the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
// exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
@@ -70,7 +70,7 @@
UniformInfo& sampler = fSamplers.push_back();
SkASSERT(GrSLTypeIsCombinedSamplerType(type));
sampler.fVariable.setType(type);
- sampler.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
+ sampler.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
sampler.fVariable.setPrecision(precision);
sampler.fVariable.setName(mangleName);
sampler.fLocation = -1;
diff --git a/src/gpu/gl/GrGLUniformHandler.h b/src/gpu/gl/GrGLUniformHandler.h
index da5b96d..d3aa2f8 100644
--- a/src/gpu/gl/GrGLUniformHandler.h
+++ b/src/gpu/gl/GrGLUniformHandler.h
@@ -18,7 +18,7 @@
public:
static const int kUniformsPerBlock = 8;
- const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
+ const GrShaderVar& getUniformVariable(UniformHandle u) const override {
return fUniforms[u.toIndex()].fVariable;
}
@@ -42,7 +42,7 @@
SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
const char* name) override;
- const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const override {
+ const GrShaderVar& samplerVariable(SamplerHandle handle) const override {
return fSamplers[handle.toIndex()].fVariable;
}
diff --git a/src/gpu/glsl/GrGLSLBlend.cpp b/src/gpu/glsl/GrGLSLBlend.cpp
index da73b66..e9a9f50 100644
--- a/src/gpu/glsl/GrGLSLBlend.cpp
+++ b/src/gpu/glsl/GrGLSLBlend.cpp
@@ -124,8 +124,8 @@
static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumFunction) {
// Emit a helper that gets the luminance of a color.
SkString getFunction;
- GrGLSLShaderVar getLumArgs[] = {
- GrGLSLShaderVar("color", kVec3f_GrSLType),
+ GrShaderVar getLumArgs[] = {
+ GrShaderVar("color", kVec3f_GrSLType),
};
SkString getLumBody("return dot(vec3(0.3, 0.59, 0.11), color);");
fsBuilder->emitFunction(kFloat_GrSLType,
@@ -135,10 +135,10 @@
&getFunction);
// Emit the set luminance function.
- GrGLSLShaderVar setLumArgs[] = {
- GrGLSLShaderVar("hueSat", kVec3f_GrSLType),
- GrGLSLShaderVar("alpha", kFloat_GrSLType),
- GrGLSLShaderVar("lumColor", kVec3f_GrSLType),
+ GrShaderVar setLumArgs[] = {
+ GrShaderVar("hueSat", kVec3f_GrSLType),
+ GrShaderVar("alpha", kFloat_GrSLType),
+ GrShaderVar("lumColor", kVec3f_GrSLType),
};
SkString setLumBody;
setLumBody.printf("float diff = %s(lumColor - hueSat);", getFunction.c_str());
@@ -169,7 +169,7 @@
static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
// Emit a helper that gets the saturation of a color
SkString getFunction;
- GrGLSLShaderVar getSatArgs[] = { GrGLSLShaderVar("color", kVec3f_GrSLType) };
+ GrShaderVar getSatArgs[] = { GrShaderVar("color", kVec3f_GrSLType) };
SkString getSatBody;
getSatBody.printf("return max(max(color.r, color.g), color.b) - "
"min(min(color.r, color.g), color.b);");
@@ -184,11 +184,11 @@
// problems on PowerVR drivers. So instead it returns a vec3 where r, g ,b are the
// adjusted min, mid, and max inputs, respectively.
SkString helperFunction;
- GrGLSLShaderVar helperArgs[] = {
- GrGLSLShaderVar("minComp", kFloat_GrSLType),
- GrGLSLShaderVar("midComp", kFloat_GrSLType),
- GrGLSLShaderVar("maxComp", kFloat_GrSLType),
- GrGLSLShaderVar("sat", kFloat_GrSLType),
+ GrShaderVar helperArgs[] = {
+ GrShaderVar("minComp", kFloat_GrSLType),
+ GrShaderVar("midComp", kFloat_GrSLType),
+ GrShaderVar("maxComp", kFloat_GrSLType),
+ GrShaderVar("sat", kFloat_GrSLType),
};
static const char kHelperBody[] = "if (minComp < maxComp) {"
"vec3 result;"
@@ -205,9 +205,9 @@
kHelperBody,
&helperFunction);
- GrGLSLShaderVar setSatArgs[] = {
- GrGLSLShaderVar("hueLumColor", kVec3f_GrSLType),
- GrGLSLShaderVar("satColor", kVec3f_GrSLType),
+ GrShaderVar setSatArgs[] = {
+ GrShaderVar("hueLumColor", kVec3f_GrSLType),
+ GrShaderVar("satColor", kVec3f_GrSLType),
};
const char* helpFunc = helperFunction.c_str();
SkString setSatBody;
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index a9493b8..46b1947 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -147,8 +147,8 @@
extension);
}
fInputs.push_back().set(kVec4f_GrSLType,
- GrGLSLShaderVar::kIn_TypeModifier,
"gl_FragCoord",
+ GrShaderVar::kIn_TypeModifier,
kDefault_GrSLPrecision,
"origin_upper_left");
fSetupFragPosition = true;
@@ -226,9 +226,8 @@
if (this->addFeature(1 << kSampleMaskOverrideCoverage_GLSLPrivateFeature,
"GL_NV_sample_mask_override_coverage")) {
// Redeclare gl_SampleMask with layout(override_coverage) if we haven't already.
- fOutputs.push_back().set(kInt_GrSLType, GrShaderVar::kOut_TypeModifier,
- "gl_SampleMask", 1, kHigh_GrSLPrecision,
- "override_coverage");
+ fOutputs.push_back().set(kInt_GrSLType, "gl_SampleMask", 1, GrShaderVar::kOut_TypeModifier,
+ kHigh_GrSLPrecision, "override_coverage");
}
this->codeAppendf("gl_SampleMask[0] = %s;", mask);
fHasInitializedSampleMask = true;
@@ -283,9 +282,8 @@
if (!fHasCustomColorOutput) {
fHasCustomColorOutput = true;
fCustomColorOutputIndex = fOutputs.count();
- fOutputs.push_back().set(kVec4f_GrSLType,
- GrGLSLShaderVar::kOut_TypeModifier,
- DeclaredColorOutputName());
+ fOutputs.push_back().set(kVec4f_GrSLType, DeclaredColorOutputName(),
+ GrShaderVar::kOut_TypeModifier);
fProgramBuilder->finalizeFragmentOutputColor(fOutputs.back());
}
}
@@ -303,8 +301,8 @@
// output. The condition also co-incides with the condition in whici GLES SL 2.0
// requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
if (caps.mustDeclareFragmentShaderOutput()) {
- fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModifier,
- DeclaredSecondaryColorOutputName());
+ fOutputs.push_back().set(kVec4f_GrSLType, DeclaredSecondaryColorOutputName(),
+ GrShaderVar::kOut_TypeModifier);
fProgramBuilder->finalizeFragmentSecondaryColor(fOutputs.back());
}
}
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
index bf8569c..f7d2323 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
@@ -8,8 +8,8 @@
#ifndef GrGLSLFragmentShaderBuilder_DEFINED
#define GrGLSLFragmentShaderBuilder_DEFINED
+#include "GrBlend.h"
#include "GrGLSLShaderBuilder.h"
-
#include "GrProcessor.h"
class GrRenderTarget;
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 7dea0be..9da88de 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -9,6 +9,7 @@
#include "GrPipeline.h"
#include "GrTexturePriv.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLVarying.h"
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.h b/src/gpu/glsl/GrGLSLProgramBuilder.h
index 7276144..6c1eb3b 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.h
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.h
@@ -20,8 +20,9 @@
#include "glsl/GrGLSLXferProcessor.h"
class GrGLSLCaps;
-class GrGLSLShaderVar;
+class GrShaderVar;
class GrGLSLVaryingHandler;
+class GrGLSLExpr4;
typedef SkSTArray<8, GrGLSLFragmentProcessor*, true> GrGLSLFragProcs;
@@ -43,7 +44,7 @@
typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle;
- const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const {
+ const GrShaderVar& samplerVariable(SamplerHandle handle) const {
return this->uniformHandler()->samplerVariable(handle);
}
@@ -79,8 +80,8 @@
// Used for backend customization of the output color and secondary color variables from the
// fragment processor. Only used if the outputs are explicitly declared in the shaders
- virtual void finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) {}
- virtual void finalizeFragmentSecondaryColor(GrGLSLShaderVar& outputColor) {}
+ virtual void finalizeFragmentOutputColor(GrShaderVar& outputColor) {}
+ virtual void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) {}
// number of each input/output type in a single allocation block, used by many builders
static const int kVarsPerBlock;
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index 2e79779..3836d6d 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
+#include "GrShaderVar.h"
#include "GrSwizzle.h"
#include "glsl/GrGLSLShaderBuilder.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
-#include "glsl/GrGLSLShaderVar.h"
#include "glsl/GrGLSLProgramBuilder.h"
GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program)
@@ -29,7 +29,7 @@
this->main() = "void main() {";
}
-void GrGLSLShaderBuilder::declAppend(const GrGLSLShaderVar& var) {
+void GrGLSLShaderBuilder::declAppend(const GrShaderVar& var) {
SkString tempDecl;
var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl);
this->codeAppendf("%s;", tempDecl.c_str());
@@ -44,7 +44,7 @@
void GrGLSLShaderBuilder::emitFunction(GrSLType returnType,
const char* name,
int argCnt,
- const GrGLSLShaderVar* args,
+ const GrShaderVar* args,
const char* body,
SkString* outName) {
this->functions().append(GrGLSLTypeString(returnType));
@@ -73,7 +73,7 @@
const char* coordName,
GrSLType varyingType) const {
const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
- const GrGLSLShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
+ const GrShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
GrSLType samplerType = sampler.getType();
if (samplerType == kTexture2DRectSampler_GrSLType) {
if (varyingType == kVec2f_GrSLType) {
@@ -132,9 +132,9 @@
// Our color is (r, g, b, a), but we want to multiply (r, g, b, 1) by our matrix, then
// re-insert the original alpha. The supplied srcColor is likely to be of the form
// "texture(...)", and we don't want to evaluate that twice, so wrap everything in a function.
- static const GrGLSLShaderVar gColorGamutXformArgs[] = {
- GrGLSLShaderVar("color", kVec4f_GrSLType),
- GrGLSLShaderVar("xform", kMat44f_GrSLType),
+ static const GrShaderVar gColorGamutXformArgs[] = {
+ GrShaderVar("color", kVec4f_GrSLType),
+ GrShaderVar("xform", kMat44f_GrSLType),
};
SkString functionBody;
// Gamut xform, clamp to destination gamut
@@ -162,7 +162,7 @@
void GrGLSLShaderBuilder::appendTexelFetch(SkString* out,
SamplerHandle samplerHandle,
const char* coordExpr) const {
- const GrGLSLShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
+ const GrShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
SkASSERT(GrSLTypeIsCombinedSamplerType(sampler.getType()));
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h
index 2ab0eec..17eb5a6 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.h
@@ -9,8 +9,8 @@
#define GrGLSLShaderBuilder_DEFINED
#include "GrAllocator.h"
+#include "GrShaderVar.h"
#include "glsl/GrGLSLUniformHandler.h"
-#include "glsl/GrGLSLShaderVar.h"
#include "SkTDArray.h"
#include <stdarg.h>
@@ -118,7 +118,7 @@
/**
* Appends a variable declaration to one of the shaders
*/
- void declAppend(const GrGLSLShaderVar& var);
+ void declAppend(const GrShaderVar& var);
/**
* Appends a precision qualifier followed by a space, if relevant for the GLSL version.
@@ -129,7 +129,7 @@
void emitFunction(GrSLType returnType,
const char* name,
int argCnt,
- const GrGLSLShaderVar* args,
+ const GrShaderVar* args,
const char* body,
SkString* outName);
@@ -161,7 +161,7 @@
};
protected:
- typedef GrTAllocator<GrGLSLShaderVar> VarArray;
+ typedef GrTAllocator<GrShaderVar> VarArray;
void appendDecls(const VarArray& vars, SkString* out) const;
/**
diff --git a/src/gpu/glsl/GrGLSLShaderVar.h b/src/gpu/glsl/GrGLSLShaderVar.h
deleted file mode 100644
index 74afed8..0000000
--- a/src/gpu/glsl/GrGLSLShaderVar.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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 GrGLSLShaderVar_DEFINED
-#define GrGLSLShaderVar_DEFINED
-
-#include "GrShaderVar.h"
-#include "../glsl/GrGLSL.h"
-#include "../glsl/GrGLSLCaps.h"
-
-#define USE_UNIFORM_FLOAT_ARRAYS true
-
-/**
- * Represents a variable in a shader
- */
-class GrGLSLShaderVar : public GrShaderVar {
-public:
- /**
- * Defaults to a float with no precision specifier
- */
- GrGLSLShaderVar()
- : GrShaderVar()
- , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
- }
-
- GrGLSLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
- GrSLPrecision precision = kDefault_GrSLPrecision)
- : GrShaderVar(name, type, arrayCount, precision)
- , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
- SkASSERT(kVoid_GrSLType != type);
- fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
- }
-
- GrGLSLShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
- int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
- : GrShaderVar(name, type, typeModifier, arrayCount, precision)
- , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
- SkASSERT(kVoid_GrSLType != type);
- }
-
- GrGLSLShaderVar(const GrShaderVar& var)
- : GrShaderVar(var)
- , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
- SkASSERT(kVoid_GrSLType != var.getType());
- }
-
- GrGLSLShaderVar(const GrGLSLShaderVar& var)
- : GrShaderVar(var.c_str(), var.getType(), var.getTypeModifier(),
- var.getArrayCount(), var.getPrecision())
- , fUseUniformFloatArrays(var.fUseUniformFloatArrays)
- , fLayoutQualifier(var.fLayoutQualifier)
- , fExtraModifiers(var.fExtraModifiers) {
- SkASSERT(kVoid_GrSLType != var.getType());
- }
-
- /**
- * Values for array count that have special meaning. We allow 1-sized arrays.
- */
- enum {
- kNonArray = 0, // not an array
- kUnsizedArray = -1, // an unsized array (declared with [])
- };
-
- /**
- * Sets as a non-array.
- */
- void set(GrSLType type,
- TypeModifier typeModifier,
- const SkString& name,
- GrSLPrecision precision = kDefault_GrSLPrecision,
- const char* layoutQualifier = nullptr,
- const char* extraModifiers = nullptr,
- bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
- SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
- INHERITED::set(type, name, typeModifier, precision);
- fLayoutQualifier = layoutQualifier;
- if (extraModifiers) {
- fExtraModifiers.printf("%s ", extraModifiers);
- }
- fUseUniformFloatArrays = useUniformFloatArrays;
- }
-
- /**
- * Sets as a non-array.
- */
- void set(GrSLType type,
- TypeModifier typeModifier,
- const char* name,
- GrSLPrecision precision = kDefault_GrSLPrecision,
- const char* layoutQualifier = nullptr,
- const char* extraModifiers = nullptr,
- bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
- SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
- INHERITED::set(type, name, typeModifier, precision);
- fLayoutQualifier = layoutQualifier;
- if (extraModifiers) {
- fExtraModifiers.printf("%s ", extraModifiers);
- }
- fUseUniformFloatArrays = useUniformFloatArrays;
- }
-
- /**
- * Set all var options
- */
- void set(GrSLType type,
- TypeModifier typeModifier,
- const SkString& name,
- int count,
- GrSLPrecision precision = kDefault_GrSLPrecision,
- const char* layoutQualifier = nullptr,
- const char* extraModifiers = nullptr,
- bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
- SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
- INHERITED::set(type, name, typeModifier, precision, count);
- fLayoutQualifier = layoutQualifier;
- if (extraModifiers) {
- fExtraModifiers.printf("%s ", extraModifiers);
- }
- fUseUniformFloatArrays = useUniformFloatArrays;
- }
-
- /**
- * Set all var options
- */
- void set(GrSLType type,
- TypeModifier typeModifier,
- const char* name,
- int count,
- GrSLPrecision precision = kDefault_GrSLPrecision,
- const char* layoutQualifier = nullptr,
- const char* extraModifiers = nullptr,
- bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
- SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
- INHERITED::set(type, name, typeModifier, precision, count);
- fLayoutQualifier = layoutQualifier;
- if (extraModifiers) {
- fExtraModifiers.printf("%s ", extraModifiers);
- }
- fUseUniformFloatArrays = useUniformFloatArrays;
- }
-
- /**
- * Set the layout qualifier
- */
- void setLayoutQualifier(const char* layoutQualifier) {
- fLayoutQualifier = layoutQualifier;
- }
-
- void addModifier(const char* modifier) {
- if (modifier) {
- fExtraModifiers.appendf("%s ", modifier);
- }
- }
-
- /**
- * Write a declaration of this variable to out.
- */
- void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
- SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
- if (!fLayoutQualifier.isEmpty()) {
- out->appendf("layout(%s) ", fLayoutQualifier.c_str());
- }
- out->append(fExtraModifiers);
- if (this->getTypeModifier() != kNone_TypeModifier) {
- out->append(TypeModifierString(glslCaps, this->getTypeModifier()));
- out->append(" ");
- }
- GrSLType effectiveType = this->getType();
- if (glslCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) {
- // Desktop GLSL has added precision qualifiers but they don't do anything.
- out->appendf("%s ", GrGLSLPrecisionString(fPrecision));
- }
- if (this->isArray()) {
- if (this->isUnsizedArray()) {
- out->appendf("%s %s[]",
- GrGLSLTypeString(effectiveType),
- this->getName().c_str());
- } else {
- SkASSERT(this->getArrayCount() > 0);
- out->appendf("%s %s[%d]",
- GrGLSLTypeString(effectiveType),
- this->getName().c_str(),
- this->getArrayCount());
- }
- } else {
- out->appendf("%s %s",
- GrGLSLTypeString(effectiveType),
- this->getName().c_str());
- }
- }
-
- void appendArrayAccess(int index, SkString* out) const {
- out->appendf("%s[%d]%s",
- this->getName().c_str(),
- index,
- fUseUniformFloatArrays ? "" : ".x");
- }
-
- void appendArrayAccess(const char* indexName, SkString* out) const {
- out->appendf("%s[%s]%s",
- this->getName().c_str(),
- indexName,
- fUseUniformFloatArrays ? "" : ".x");
- }
-
-private:
- static const char* TypeModifierString(const GrGLSLCaps* glslCaps, TypeModifier t) {
- switch (t) {
- case kNone_TypeModifier:
- return "";
- case kIn_TypeModifier:
- return "in";
- case kInOut_TypeModifier:
- return "inout";
- case kOut_TypeModifier:
- return "out";
- case kUniform_TypeModifier:
- return "uniform";
- }
- SkFAIL("Unknown shader variable type modifier.");
- return ""; // suppress warning
- }
-
- /// Work around driver bugs on some hardware that don't correctly
- /// support uniform float []
- bool fUseUniformFloatArrays;
-
- SkString fLayoutQualifier;
- SkString fExtraModifiers;
-
- typedef GrShaderVar INHERITED;
-};
-
-#endif
diff --git a/src/gpu/glsl/GrGLSLUniformHandler.h b/src/gpu/glsl/GrGLSLUniformHandler.h
index 657be6a..d49fbd4 100644
--- a/src/gpu/glsl/GrGLSLUniformHandler.h
+++ b/src/gpu/glsl/GrGLSLUniformHandler.h
@@ -9,7 +9,8 @@
#define GrGLSLUniformHandler_DEFINED
#include "GrGLSLProgramDataManager.h"
-#include "GrGLSLShaderVar.h"
+#include "GrShaderVar.h"
+#include "GrSwizzle.h"
class GrGLSLProgramBuilder;
@@ -46,7 +47,7 @@
outName);
}
- virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0;
+ virtual const GrShaderVar& getUniformVariable(UniformHandle u) const = 0;
/**
* Shortcut for getUniformVariable(u).c_str()
@@ -60,7 +61,7 @@
GrGLSLProgramBuilder* fProgramBuilder;
private:
- virtual const GrGLSLShaderVar& samplerVariable(SamplerHandle) const = 0;
+ virtual const GrShaderVar& samplerVariable(SamplerHandle) const = 0;
virtual GrSwizzle samplerSwizzle(SamplerHandle) const = 0;
virtual SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
diff --git a/src/gpu/glsl/GrGLSLVarying.cpp b/src/gpu/glsl/GrGLSLVarying.cpp
index 4d9b61f..a3d5053 100644
--- a/src/gpu/glsl/GrGLSLVarying.cpp
+++ b/src/gpu/glsl/GrGLSLVarying.cpp
@@ -6,7 +6,7 @@
*/
#include "glsl/GrGLSLVarying.h"
-
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramBuilder.h"
void GrGLSLVaryingHandler::addPassThroughAttribute(const GrGeometryProcessor::Attribute* input,
@@ -81,7 +81,7 @@
void GrGLSLVaryingHandler::addAttribute(const GrShaderVar& var) {
SkASSERT(GrShaderVar::kIn_TypeModifier == var.getTypeModifier());
for (int j = 0; j < fVertexInputs.count(); ++j) {
- const GrGLSLShaderVar& attr = fVertexInputs[j];
+ const GrShaderVar& attr = fVertexInputs[j];
// if attribute already added, don't add it again
if (attr.getName().equals(var.getName())) {
return;
@@ -111,23 +111,23 @@
const VaryingInfo& v = this->fVaryings[i];
const char* modifier = v.fIsFlat ? "flat" : fDefaultInterpolationModifier;
if (v.fVisibility & kVertex_GrShaderFlag) {
- fVertexOutputs.push_back().set(v.fType, GrShaderVar::kOut_TypeModifier, v.fVsOut,
+ fVertexOutputs.push_back().set(v.fType, v.fVsOut, GrShaderVar::kOut_TypeModifier,
v.fPrecision, nullptr, modifier);
if (v.fVisibility & kGeometry_GrShaderFlag) {
- fGeomInputs.push_back().set(v.fType, GrShaderVar::kIn_TypeModifier, v.fVsOut,
- GrShaderVar::kUnsizedArray, v.fPrecision, nullptr,
+ fGeomInputs.push_back().set(v.fType, v.fVsOut, GrShaderVar::kUnsizedArray,
+ GrShaderVar::kIn_TypeModifier, v.fPrecision, nullptr,
modifier);
}
}
if (v.fVisibility & kFragment_GrShaderFlag) {
const char* fsIn = v.fVsOut.c_str();
if (v.fVisibility & kGeometry_GrShaderFlag) {
- fGeomOutputs.push_back().set(v.fType, GrGLSLShaderVar::kOut_TypeModifier,
- v.fGsOut, v.fPrecision, nullptr, modifier);
+ fGeomOutputs.push_back().set(v.fType, v.fGsOut, GrShaderVar::kOut_TypeModifier,
+ v.fPrecision, nullptr, modifier);
fsIn = v.fGsOut.c_str();
}
- fFragInputs.push_back().set(v.fType, GrShaderVar::kIn_TypeModifier, fsIn,
- v.fPrecision, nullptr, modifier);
+ fFragInputs.push_back().set(v.fType, fsIn, GrShaderVar::kIn_TypeModifier, v.fPrecision,
+ nullptr, modifier);
}
}
this->onFinalize();
diff --git a/src/gpu/glsl/GrGLSLVarying.h b/src/gpu/glsl/GrGLSLVarying.h
index 5867361..e9378a8 100644
--- a/src/gpu/glsl/GrGLSLVarying.h
+++ b/src/gpu/glsl/GrGLSLVarying.h
@@ -10,9 +10,9 @@
#include "GrAllocator.h"
#include "GrGeometryProcessor.h"
+#include "GrShaderVar.h"
#include "GrTypesPriv.h"
#include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLShaderVar.h"
class GrGLSLProgramBuilder;
@@ -152,7 +152,7 @@
};
typedef GrTAllocator<VaryingInfo> VaryingList;
- typedef GrTAllocator<GrGLSLShaderVar> VarArray;
+ typedef GrTAllocator<GrShaderVar> VarArray;
typedef GrGLSLProgramDataManager::VaryingHandle VaryingHandle;
VaryingList fVaryings;
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp
index 0f7a3db..1f6db4c 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -8,6 +8,7 @@
#include "glsl/GrGLSLXferProcessor.h"
#include "GrXferProcessor.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp
index bcf4864..ed38e71 100644
--- a/src/gpu/instanced/InstanceProcessor.cpp
+++ b/src/gpu/instanced/InstanceProcessor.cpp
@@ -11,6 +11,7 @@
#include "GrRenderTargetPriv.h"
#include "GrResourceCache.h"
#include "GrResourceProvider.h"
+#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
@@ -1367,7 +1368,7 @@
}
if (kRect_ShapeFlag != (fBatchInfo.fShapeTypes | fBatchInfo.fInnerShapeTypes)) {
- GrGLSLShaderVar x("x", kVec2f_GrSLType, GrGLSLShaderVar::kNonArray, kHigh_GrSLPrecision);
+ GrShaderVar x("x", kVec2f_GrSLType, GrShaderVar::kNonArray, kHigh_GrSLPrecision);
f->emitFunction(kFloat_GrSLType, "square", 1, &x, "return dot(x, x);", &fSquareFun);
}
diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp
index 6e96822..5e54503 100644
--- a/src/gpu/vk/GrVkCopyManager.cpp
+++ b/src/gpu/vk/GrVkCopyManager.cpp
@@ -21,6 +21,7 @@
#include "GrVkTexture.h"
#include "GrVkUniformBuffer.h"
#include "GrVkVertexBuffer.h"
+#include "glsl/GrGLSLCaps.h"
#include "SkPoint.h"
#include "SkRect.h"
diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp
index 5a783f0..e68159d 100644
--- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp
+++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp
@@ -7,10 +7,12 @@
#include "vk/GrVkPipelineStateBuilder.h"
+#include "glsl/GrGLSLCaps.h"
#include "vk/GrVkDescriptorSetManager.h"
#include "vk/GrVkGpu.h"
#include "vk/GrVkRenderPass.h"
+
GrVkPipelineState* GrVkPipelineStateBuilder::CreatePipelineState(
GrVkGpu* gpu,
const GrPipeline& pipeline,
@@ -51,11 +53,11 @@
return fGpu->vkCaps().glslCaps();
}
-void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) {
+void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrShaderVar& outputColor) {
outputColor.setLayoutQualifier("location = 0, index = 0");
}
-void GrVkPipelineStateBuilder::finalizeFragmentSecondaryColor(GrGLSLShaderVar& outputColor) {
+void GrVkPipelineStateBuilder::finalizeFragmentSecondaryColor(GrShaderVar& outputColor) {
outputColor.setLayoutQualifier("location = 0, index = 1");
}
diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.h b/src/gpu/vk/GrVkPipelineStateBuilder.h
index cf9237a..8e3ede9 100644
--- a/src/gpu/vk/GrVkPipelineStateBuilder.h
+++ b/src/gpu/vk/GrVkPipelineStateBuilder.h
@@ -42,8 +42,8 @@
GrVkGpu* gpu() const { return fGpu; }
- void finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) override;
- void finalizeFragmentSecondaryColor(GrGLSLShaderVar& outputColor) override;
+ void finalizeFragmentOutputColor(GrShaderVar& outputColor) override;
+ void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) override;
private:
GrVkPipelineStateBuilder(GrVkGpu*,
diff --git a/src/gpu/vk/GrVkPipelineStateDataManager.cpp b/src/gpu/vk/GrVkPipelineStateDataManager.cpp
index ef75bd3..88176da 100644
--- a/src/gpu/vk/GrVkPipelineStateDataManager.cpp
+++ b/src/gpu/vk/GrVkPipelineStateDataManager.cpp
@@ -26,7 +26,7 @@
for (int i = 0; i < count; i++) {
Uniform& uniform = fUniforms[i];
const GrVkUniformHandler::UniformInfo uniformInfo = uniforms[i];
- SkASSERT(GrGLSLShaderVar::kNonArray == uniformInfo.fVariable.getArrayCount() ||
+ SkASSERT(GrShaderVar::kNonArray == uniformInfo.fVariable.getArrayCount() ||
uniformInfo.fVariable.getArrayCount() > 0);
SkDEBUGCODE(
uniform.fArrayCount = uniformInfo.fVariable.getArrayCount();
@@ -57,7 +57,7 @@
void GrVkPipelineStateDataManager::set1i(UniformHandle u, int32_t i) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kInt_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
memcpy(buffer, &i, sizeof(int32_t));
}
@@ -69,7 +69,7 @@
SkASSERT(uni.fType == kInt_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
- (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
+ (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(int32_t) == 4);
@@ -83,7 +83,7 @@
void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kFloat_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
memcpy(buffer, &v0, sizeof(float));
@@ -96,7 +96,7 @@
SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
- (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
+ (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -110,7 +110,7 @@
void GrVkPipelineStateDataManager::set2f(UniformHandle u, float v0, float v1) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec2f_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
float v[2] = { v0, v1 };
@@ -124,7 +124,7 @@
SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
- (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
+ (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -138,7 +138,7 @@
void GrVkPipelineStateDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec3f_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
float v[3] = { v0, v1, v2 };
@@ -152,7 +152,7 @@
SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
- (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
+ (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -170,7 +170,7 @@
float v3) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec4f_GrSLType);
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
+ SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
float v[4] = { v0, v1, v2, v3 };
@@ -184,7 +184,7 @@
SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
- (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
+ (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -230,7 +230,7 @@
SkASSERT(uni.fType == kMat22f_GrSLType + (N - 2));
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
- (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
+ (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
void* buffer;
if (GrVkUniformHandler::kVertexBinding == uni.fBinding) {
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index 1da4119..85b6955 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -155,7 +155,7 @@
uni.fVariable.setPrecision(precision);
// When outputing the GLSL, only the outer uniform block will get the Uniform modifier. Thus
// we set the modifier to none for all uniforms declared inside the block.
- uni.fVariable.setTypeModifier(GrGLSLShaderVar::kNone_TypeModifier);
+ uni.fVariable.setTypeModifier(GrShaderVar::kNone_TypeModifier);
uint32_t* currentOffset = kVertex_GrShaderFlag == visibility ? &fCurrentVertexUBOOffset
: &fCurrentFragmentUBOOffset;
@@ -184,7 +184,7 @@
UniformInfo& info = fSamplers.push_back();
SkASSERT(GrSLTypeIsCombinedSamplerType(type));
info.fVariable.setType(type);
- info.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
+ info.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
info.fVariable.setPrecision(precision);
info.fVariable.setName(mangleName);
SkString layoutQualifier;
diff --git a/src/gpu/vk/GrVkUniformHandler.h b/src/gpu/vk/GrVkUniformHandler.h
index 89dc410..e5d4a4c 100644
--- a/src/gpu/vk/GrVkUniformHandler.h
+++ b/src/gpu/vk/GrVkUniformHandler.h
@@ -8,10 +8,9 @@
#ifndef GrVkUniformHandler_DEFINED
#define GrVkUniformHandler_DEFINED
-#include "glsl/GrGLSLUniformHandler.h"
-
#include "GrAllocator.h"
-#include "glsl/GrGLSLShaderVar.h"
+#include "GrShaderVar.h"
+#include "glsl/GrGLSLUniformHandler.h"
class GrVkUniformHandler : public GrGLSLUniformHandler {
public:
@@ -28,13 +27,13 @@
// fUBOffset is only valid if the GrSLType of the fVariable is not a sampler
struct UniformInfo {
- GrGLSLShaderVar fVariable;
+ GrShaderVar fVariable;
uint32_t fVisibility;
uint32_t fUBOffset;
};
typedef GrTAllocator<UniformInfo> UniformInfoArray;
- const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
+ const GrShaderVar& getUniformVariable(UniformHandle u) const override {
return fUniforms[u.toIndex()].fVariable;
}
@@ -67,7 +66,7 @@
const char* name) override;
int numSamplers() const { return fSamplers.count(); }
- const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const override {
+ const GrShaderVar& samplerVariable(SamplerHandle handle) const override {
return fSamplers[handle.toIndex()].fVariable;
}
GrSwizzle samplerSwizzle(SamplerHandle handle) const override {
diff --git a/src/gpu/vk/GrVkVaryingHandler.cpp b/src/gpu/vk/GrVkVaryingHandler.cpp
index 099e096..2b3e975 100644
--- a/src/gpu/vk/GrVkVaryingHandler.cpp
+++ b/src/gpu/vk/GrVkVaryingHandler.cpp
@@ -55,7 +55,7 @@
void finalize_helper(GrVkVaryingHandler::VarArray& vars) {
int locationIndex = 0;
for (int i = 0; i < vars.count(); ++i) {
- GrGLSLShaderVar& var = vars[i];
+ GrShaderVar& var = vars[i];
SkString location;
location.appendf("location = %d", locationIndex);
var.setLayoutQualifier(location.c_str());
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 6301c51..8354a8d 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -12,6 +12,7 @@
#include "gl/GrGLGpu.h"
#include "gl/GrGLUtil.h"
#include "gl/GLTestContext.h"
+#include "glsl/GrGLSLCaps.h"
using sk_gpu_test::GLTestContext;