Test that the inliner uses a temp var for return statements.
We have a handful of tests that demonstrate this behavior indirectly, but lacked a focused test. Change-Id: I895cc4e3bebf30721ed649244e42bf170cc6ec06 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346497 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
47726a1cff
commit
f2ce4e91a2
@ -391,6 +391,9 @@ sksl_inliner_tests = [
|
|||||||
"$_tests/sksl/inliner/IfWithReturnsCanBeInlined.sksl",
|
"$_tests/sksl/inliner/IfWithReturnsCanBeInlined.sksl",
|
||||||
"$_tests/sksl/inliner/InlineKeywordOverridesThreshold.sksl",
|
"$_tests/sksl/inliner/InlineKeywordOverridesThreshold.sksl",
|
||||||
"$_tests/sksl/inliner/InlineThreshold.sksl",
|
"$_tests/sksl/inliner/InlineThreshold.sksl",
|
||||||
|
"$_tests/sksl/inliner/InlinerUsesTempVarForMultipleReturns.sksl",
|
||||||
|
"$_tests/sksl/inliner/InlinerUsesTempVarForReturnsInsideBlock.sksl",
|
||||||
|
"$_tests/sksl/inliner/InlinerUsesTempVarForReturnsInsideBlockWithVar.sksl",
|
||||||
"$_tests/sksl/inliner/InlineWithInoutArgument.sksl",
|
"$_tests/sksl/inliner/InlineWithInoutArgument.sksl",
|
||||||
"$_tests/sksl/inliner/InlineWithModifiedArgument.sksl",
|
"$_tests/sksl/inliner/InlineWithModifiedArgument.sksl",
|
||||||
"$_tests/sksl/inliner/InlineWithNestedBigCalls.sksl",
|
"$_tests/sksl/inliner/InlineWithNestedBigCalls.sksl",
|
||||||
|
15
tests/sksl/inliner/InlinerUsesTempVarForMultipleReturns.sksl
Normal file
15
tests/sksl/inliner/InlinerUsesTempVarForMultipleReturns.sksl
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*#pragma settings Default*/
|
||||||
|
|
||||||
|
uniform half4 color;
|
||||||
|
|
||||||
|
inline half4 MakeTempVar(half4 c) {
|
||||||
|
if (c.x < c.y) {
|
||||||
|
return c.xxxx;
|
||||||
|
} else {
|
||||||
|
return c.yyyy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
sk_FragColor = MakeTempVar(color);
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
/*#pragma settings Default*/
|
||||||
|
|
||||||
|
uniform half4 color;
|
||||||
|
|
||||||
|
inline half4 MakeTempVar(half4 c) {
|
||||||
|
{
|
||||||
|
return c.xxxx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
sk_FragColor = MakeTempVar(color);
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
/*#pragma settings Default*/
|
||||||
|
|
||||||
|
uniform half4 color;
|
||||||
|
|
||||||
|
inline half4 MakeTempVar(half4 c) {
|
||||||
|
{
|
||||||
|
half4 d = c * 0.75;
|
||||||
|
return d.xxxx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
sk_FragColor = MakeTempVar(color);
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
#version 400
|
||||||
|
out vec4 sk_FragColor;
|
||||||
|
uniform vec4 color;
|
||||||
|
void main() {
|
||||||
|
vec4 _0_MakeTempVar;
|
||||||
|
if (color.x < color.y) {
|
||||||
|
_0_MakeTempVar = color.xxxx;
|
||||||
|
} else {
|
||||||
|
_0_MakeTempVar = color.yyyy;
|
||||||
|
}
|
||||||
|
sk_FragColor = _0_MakeTempVar;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
#version 400
|
||||||
|
out vec4 sk_FragColor;
|
||||||
|
uniform vec4 color;
|
||||||
|
void main() {
|
||||||
|
vec4 _0_MakeTempVar;
|
||||||
|
{
|
||||||
|
_0_MakeTempVar = color.xxxx;
|
||||||
|
}
|
||||||
|
sk_FragColor = _0_MakeTempVar;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
#version 400
|
||||||
|
out vec4 sk_FragColor;
|
||||||
|
uniform vec4 color;
|
||||||
|
void main() {
|
||||||
|
vec4 _0_MakeTempVar;
|
||||||
|
{
|
||||||
|
vec4 _1_d = color * 0.75;
|
||||||
|
_0_MakeTempVar = _1_d.xxxx;
|
||||||
|
}
|
||||||
|
sk_FragColor = _0_MakeTempVar;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user