Stop referencing gl_FragCoord z and w components.
This fixes an Adreno driver bug where GL programs fail to link if the FS refers to these components of gl_FragCoord. R=jvanverth@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/345083002
This commit is contained in:
parent
6b8f1ba1ef
commit
160a52ba21
@ -1015,7 +1015,7 @@ void GrGLRRectBlurEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
// warp the fragment position to the appropriate part of the 9patch blur texture
|
||||
|
||||
builder->fsCodeAppendf("\t\tvec2 rectCenter = (%s.xy + %s.zw)/2.0;\n", rectName, rectName);
|
||||
builder->fsCodeAppendf("\t\tvec2 translatedFragPos = %s.xy - %s.xy;\n", fragmentPos, rectName);
|
||||
builder->fsCodeAppendf("\t\tvec2 translatedFragPos = %s - %s.xy;\n", fragmentPos, rectName);
|
||||
builder->fsCodeAppendf("\t\tfloat threshold = %s + 2.0*%s;\n", cornerRadiusName, blurRadiusName );
|
||||
builder->fsCodeAppendf("\t\tvec2 middle = %s.zw - %s.xy - 2.0*threshold;\n", rectName, rectName );
|
||||
|
||||
|
@ -200,7 +200,7 @@ public:
|
||||
builder->fsCodeAppend("\tfloat scaleH = min(1.0, 2.0*insetH/spanH);\n");
|
||||
|
||||
// Compute the coverage for the rect's width
|
||||
builder->fsCodeAppendf("\tvec2 offset = %s.xy - %s.xy;\n",
|
||||
builder->fsCodeAppendf("\tvec2 offset = %s - %s.xy;\n",
|
||||
builder->fragmentPosition(), fsRectEdgeName);
|
||||
builder->fsCodeAppendf("\tfloat perpDot = abs(offset.x * %s.w - offset.y * %s.z);\n",
|
||||
fsRectEdgeName, fsRectEdgeName);
|
||||
|
@ -102,7 +102,7 @@ void GLDitherEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
// For each channel c, add the random offset to the pixel to either bump
|
||||
// it up or let it remain constant during quantization.
|
||||
builder->fsCodeAppendf("\t\tfloat r = "
|
||||
"fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758.5453);\n",
|
||||
"fract(sin(dot(%s ,vec2(12.9898,78.233))) * 43758.5453);\n",
|
||||
builder->fragmentPosition());
|
||||
builder->fsCodeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n",
|
||||
outputColor, GrGLSLExpr4(inputColor).c_str());
|
||||
|
@ -147,10 +147,10 @@ void GLCircleEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
|
||||
SkASSERT(kHairlineAA_GrEffectEdgeType != ce.getEdgeType());
|
||||
if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) {
|
||||
builder->fsCodeAppendf("\t\tfloat d = length(%s.xy - %s.xy) - %s.z;\n",
|
||||
builder->fsCodeAppendf("\t\tfloat d = length(%s.xy - %s) - %s.z;\n",
|
||||
circleName, fragmentPos, circleName);
|
||||
} else {
|
||||
builder->fsCodeAppendf("\t\tfloat d = %s.z - length(%s.xy - %s.xy);\n",
|
||||
builder->fsCodeAppendf("\t\tfloat d = %s.z - length(%s - %s.xy);\n",
|
||||
circleName, fragmentPos, circleName);
|
||||
}
|
||||
if (GrEffectEdgeTypeIsAA(ce.getEdgeType())) {
|
||||
@ -318,7 +318,7 @@ void GLEllipseEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
const char* fragmentPos = builder->fragmentPosition();
|
||||
|
||||
// d is the offset to the ellipse center
|
||||
builder->fsCodeAppendf("\t\tvec2 d = %s.xy - %s.xy;\n", fragmentPos, ellipseName);
|
||||
builder->fsCodeAppendf("\t\tvec2 d = %s - %s.xy;\n", fragmentPos, ellipseName);
|
||||
builder->fsCodeAppendf("\t\tvec2 Z = d * %s.zw;\n", ellipseName);
|
||||
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
|
||||
builder->fsCodeAppend("\t\tfloat implicit = dot(Z, d) - 1.0;\n");
|
||||
|
@ -199,8 +199,8 @@ void GLCircularRRectEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
// alphas together.
|
||||
switch (crre.getCircularCornerFlags()) {
|
||||
case CircularRRectEffect::kAll_CornerFlags:
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos);
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rectName);
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s;\n", rectName, fragmentPos);
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy1 = %s - %s.zw;\n", fragmentPos, rectName);
|
||||
builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n");
|
||||
builder->fsCodeAppendf("\t\tfloat alpha = clamp(%s - length(dxy), 0.0, 1.0);\n",
|
||||
radiusPlusHalfName);
|
||||
@ -537,8 +537,8 @@ void GLEllipticalRRectEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
// The code below is a simplified version of the above that performs maxs on the vector
|
||||
// components before computing distances and alpha values so that only one distance computation
|
||||
// need be computed to determine the min alpha.
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos);
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rectName);
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s;\n", rectName, fragmentPos);
|
||||
builder->fsCodeAppendf("\t\tvec2 dxy1 = %s - %s.zw;\n", fragmentPos, rectName);
|
||||
switch (erre.getRRect().getType()) {
|
||||
case SkRRect::kSimple_Type: {
|
||||
const char *invRadiiXYSqdName;
|
||||
|
@ -499,7 +499,7 @@ const char* GrGLShaderBuilder::fragmentPosition() {
|
||||
// declaration varies in earlier GLSL specs. So it is simpler to omit it.
|
||||
if (fTopLeftFragPosRead) {
|
||||
fSetupFragPosition = true;
|
||||
return "gl_FragCoord";
|
||||
return "(gl_FragCoord.xy)";
|
||||
} else if (fGpu->glCaps().fragCoordConventionsSupport()) {
|
||||
if (!fSetupFragPosition) {
|
||||
SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSLPrivateFeature));
|
||||
@ -510,7 +510,7 @@ const char* GrGLShaderBuilder::fragmentPosition() {
|
||||
GrGLShaderVar::kUpperLeft_Origin);
|
||||
fSetupFragPosition = true;
|
||||
}
|
||||
return "gl_FragCoord";
|
||||
return "(gl_FragCoord.xy)";
|
||||
} else {
|
||||
static const char* kCoordName = "fragCoordYDown";
|
||||
if (!fSetupFragPosition) {
|
||||
@ -523,7 +523,7 @@ const char* GrGLShaderBuilder::fragmentPosition() {
|
||||
fOutput.fUniformHandles.fRTHeightUni =
|
||||
this->addUniform(kFragment_Visibility, kFloat_GrSLType, "RTHeight", &rtHeightName);
|
||||
|
||||
this->fFSCode.prependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_FragCoord.y, gl_FragCoord.zw);\n",
|
||||
this->fFSCode.prependf("\tvec2 %s = vec2(gl_FragCoord.x, %s - gl_FragCoord.y);\n",
|
||||
kCoordName, rtHeightName);
|
||||
fSetupFragPosition = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user