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