skia2/tests/sksl/inliner/InlineWithInoutArgument.glsl
John Stiles 05c41162fb Allow inlining of functions with unassigned out-params.
Our inliner would ignore any functions with `inout` parameters, because
inlining them properly was more complex than just leaving the function
call. However, real-world code can sometimes contain helper functions
that have `inout` params that are never used at all (e.g. an uber-shader
with some features turned off).

We now read the ProgramUsage and check to see whether or not the
`inout`-qualified parameter is actually modified. If it's never changed,
the function now remains a candidate for inlining.

Change-Id: I92e494f94cc070801cb9aa28bd13faa689b806b6
Bug: skia:12636
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/470299
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-11-11 19:33:06 +00:00

27 lines
554 B
GLSL

out vec4 sk_FragColor;
uniform vec4 colorGreen;
void outParameterWrite_vh4(out vec4 x) {
x = colorGreen;
}
void outParameterWriteIndirect_vh4(out vec4 c) {
outParameterWrite_vh4(c);
}
void inoutParameterWrite_vh4(inout vec4 x) {
x *= x;
}
void inoutParameterWriteIndirect_vh4(inout vec4 x) {
inoutParameterWrite_vh4(x);
}
vec4 main() {
vec4 c;
outParameterWrite_vh4(c);
outParameterWriteIndirect_vh4(c);
inoutParameterWrite_vh4(c);
inoutParameterWriteIndirect_vh4(c);
false;
false;
false;
return c;
}