Fix performance regresion on Mali, while preserving sk_FragCoord.w
Bug: skia: Change-Id: I9269288bbb861cd02efa7b5dfe2c9434ec39064e Reviewed-on: https://skia-review.googlesource.com/c/174309 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
b17f5fd618
commit
a34e6eac3c
@ -756,9 +756,15 @@ void GLSLCodeGenerator::writeFragCoord() {
|
||||
this->write("gl_FragCoord");
|
||||
} else {
|
||||
if (!fSetupFragPositionLocal) {
|
||||
// Accessing the components of gl_FragCoord cause pretty noticeable performance hits on
|
||||
// the Mali400. Reading from the z component of gl_FragCoord or _sktmpCoord, flipping
|
||||
// the y value after assigning to sk_FragCoord, or not using a temp variable are not as
|
||||
// optimal.
|
||||
fFunctionHeader += usesPrecisionModifiers() ? "highp " : "";
|
||||
fFunctionHeader += " vec4 sk_FragCoord = vec4(gl_FragCoord.x, " SKSL_RTHEIGHT_NAME
|
||||
" - gl_FragCoord.y, gl_FragCoord.z, gl_FragCoord.w);\n";
|
||||
fFunctionHeader += " vec4 _sktmpCoord = gl_FragCoord;\n";
|
||||
fFunctionHeader += usesPrecisionModifiers() ? "highp " : "";
|
||||
fFunctionHeader += " vec4 sk_FragCoord = vec4(_sktmpCoord.x, " SKSL_RTHEIGHT_NAME
|
||||
" - _sktmpCoord.y, 0.0, _sktmpCoord.w);\n";
|
||||
fSetupFragPositionLocal = true;
|
||||
}
|
||||
this->write("sk_FragCoord");
|
||||
|
@ -1147,8 +1147,9 @@ DEF_TEST(SkSLFragCoord, r) {
|
||||
"uniform float u_skRTHeight;\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" vec4 sk_FragCoord = vec4(gl_FragCoord.x, u_skRTHeight - gl_FragCoord.y, "
|
||||
"gl_FragCoord.z, gl_FragCoord.w);\n"
|
||||
" vec4 _sktmpCoord = gl_FragCoord;\n"
|
||||
" vec4 sk_FragCoord = vec4(_sktmpCoord.x, u_skRTHeight - _sktmpCoord.y, "
|
||||
"0.0, _sktmpCoord.w);\n"
|
||||
" sk_FragColor.xy = sk_FragCoord.xy;\n"
|
||||
"}\n",
|
||||
&inputs);
|
||||
|
Loading…
Reference in New Issue
Block a user