986c7fb8ca
The Metal return type from main() diverges from the SkSL source, so we patch it in the Metal code generator. This CL improves the patching process in multiple ways: - A `return` statement from a fragment processor main() is rewritten to: return *_out; - A `return` statement from a vertex processor main() is rewritten to: return (_out->sk_Position.y = -_out->sk_Position.y, *_out); - We avoid emitting a duplicate `return *_out;` statement if we can determine that main() already ends in a return statement. This is harmless either way so it doesn't necessarily catch everything. (e.g. it doesn't detect an if/else which returns at the end of both blocks.) Also added a unit test which returns from the middle of a vertex shader, since we didn't test this anywhere and we need to verify that sk_Position.y will be negated. (This didn't work properly before.) Change-Id: I14cf18375894fc712fa6c6466df3888ebaeba7c8 Bug: skia:10903 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339636 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
13 lines
356 B
Plaintext
13 lines
356 B
Plaintext
void main() {
|
|
if (sqrt(2) > 5) { sk_FragColor = half4(0.75); } else { discard; }
|
|
int i = 0;
|
|
while (i < 10) { sk_FragColor *= 0.5; i++; }
|
|
do { sk_FragColor += 0.25; } while (sk_FragColor.x < 0.75);
|
|
for (int i = 0; i < 10; i++) {
|
|
if (i % 2 == 1) break;
|
|
else if (i > 100) return;
|
|
else continue;
|
|
}
|
|
return;
|
|
}
|