Fix decl of gl_FragCoord in GLSL versions <= 1.20.
We we're saying "in" instead of "varying". Review URL: https://codereview.appspot.com/6779043 git-svn-id: http://skia.googlecode.com/svn/trunk@6104 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
831c726f83
commit
5fa2107842
@ -289,7 +289,11 @@ const char* GrGLShaderBuilder::fragmentPosition() {
|
||||
if (fContext.caps().fragCoordConventionsSupport()) {
|
||||
if (!fSetupFragPosition) {
|
||||
fFSHeader.append("#extension GL_ARB_fragment_coord_conventions: require\n");
|
||||
fFSHeader.append("layout(origin_upper_left) in vec4 gl_FragCoord;\n");
|
||||
fFSInputs.push_back().set(kVec4f_GrSLType,
|
||||
GrGLShaderVar::kIn_TypeModifier,
|
||||
"gl_FragCoord",
|
||||
GrGLShaderVar::kDefault_Precision,
|
||||
GrGLShaderVar::kUpperLeft_Origin);
|
||||
fSetupFragPosition = true;
|
||||
}
|
||||
return "gl_FragCoord";
|
||||
|
@ -44,6 +44,14 @@ public:
|
||||
// Otherwise, highp.
|
||||
};
|
||||
|
||||
/**
|
||||
* See GL_ARB_fragment_coord_conventions.
|
||||
*/
|
||||
enum Origin {
|
||||
kDefault_Origin, // when set to kDefault the origin field is ignored.
|
||||
kUpperLeft_Origin, // only used to declare vec4 in gl_FragCoord.
|
||||
};
|
||||
|
||||
/**
|
||||
* Defaults to a float with no precision specifier
|
||||
*/
|
||||
@ -52,6 +60,7 @@ public:
|
||||
fTypeModifier = kNone_TypeModifier;
|
||||
fCount = kNonArray;
|
||||
fPrecision = kDefault_Precision;
|
||||
fOrigin = kDefault_Origin;
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
}
|
||||
|
||||
@ -61,6 +70,7 @@ public:
|
||||
fTypeModifier = kNone_TypeModifier;
|
||||
fCount = arrayCount;
|
||||
fPrecision = kDefault_Precision;
|
||||
fOrigin = kDefault_Origin;
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
fName = name;
|
||||
}
|
||||
@ -71,6 +81,7 @@ public:
|
||||
, fName(var.fName)
|
||||
, fCount(var.fCount)
|
||||
, fPrecision(var.fPrecision)
|
||||
, fOrigin(fOrigin)
|
||||
, fUseUniformFloatArrays(var.fUseUniformFloatArrays) {
|
||||
GrAssert(kVoid_GrSLType != var.fType);
|
||||
}
|
||||
@ -90,6 +101,7 @@ public:
|
||||
TypeModifier typeModifier,
|
||||
const SkString& name,
|
||||
Precision precision = kDefault_Precision,
|
||||
Origin origin = kDefault_Origin,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
GrAssert(kVoid_GrSLType != type);
|
||||
fType = type;
|
||||
@ -97,6 +109,7 @@ public:
|
||||
fName = name;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
@ -107,6 +120,7 @@ public:
|
||||
TypeModifier typeModifier,
|
||||
const char* name,
|
||||
Precision precision = kDefault_Precision,
|
||||
Origin origin = kDefault_Origin,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
GrAssert(kVoid_GrSLType != type);
|
||||
fType = type;
|
||||
@ -114,6 +128,7 @@ public:
|
||||
fName = name;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
@ -125,6 +140,7 @@ public:
|
||||
const SkString& name,
|
||||
int count,
|
||||
Precision precision = kDefault_Precision,
|
||||
Origin origin = kDefault_Origin,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
GrAssert(kVoid_GrSLType != type);
|
||||
fType = type;
|
||||
@ -132,6 +148,7 @@ public:
|
||||
fName = name;
|
||||
fCount = count;
|
||||
fPrecision = precision;
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
@ -143,6 +160,7 @@ public:
|
||||
const char* name,
|
||||
int count,
|
||||
Precision precision = kDefault_Precision,
|
||||
Origin origin = kDefault_Origin,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
GrAssert(kVoid_GrSLType != type);
|
||||
fType = type;
|
||||
@ -150,6 +168,7 @@ public:
|
||||
fName = name;
|
||||
fCount = count;
|
||||
fPrecision = precision;
|
||||
fOrigin = origin;
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
@ -220,10 +239,25 @@ public:
|
||||
*/
|
||||
void setPrecision(Precision p) { fPrecision = p; }
|
||||
|
||||
/**
|
||||
* Get the origin of the var
|
||||
*/
|
||||
Origin getOrigin() const { return fOrigin; }
|
||||
|
||||
/**
|
||||
* Set the origin of the var
|
||||
*/
|
||||
void setOrigin(Origin origin) { fOrigin = origin; }
|
||||
|
||||
/**
|
||||
* Write a declaration of this variable to out.
|
||||
*/
|
||||
void appendDecl(const GrGLContextInfo& gl, SkString* out) const {
|
||||
if (kUpperLeft_Origin == fOrigin) {
|
||||
// this is the only place where we specify a layout modifier. If we use other layout
|
||||
// modifiers in the future then they should be placed in a list.
|
||||
out->append("layout(origin_upper_left) ");
|
||||
}
|
||||
if (this->getTypeModifier() != kNone_TypeModifier) {
|
||||
out->append(TypeModifierString(this->getTypeModifier(),
|
||||
gl.glslGeneration()));
|
||||
@ -331,6 +365,7 @@ private:
|
||||
SkString fName;
|
||||
int fCount;
|
||||
Precision fPrecision;
|
||||
Origin fOrigin;
|
||||
/// Work around driver bugs on some hardware that don't correctly
|
||||
/// support uniform float []
|
||||
bool fUseUniformFloatArrays;
|
||||
|
Loading…
Reference in New Issue
Block a user