Update LoopFloat/LoopInt tests to reduce hoisting.

Previously, none of our `runtime` tests relied on the input coordinate
in any way, so all of the logic was hoisted above the main loop in every
test. This CL adds an artificial reliance on the input coordinate so
that we have at least some SkVM tests with real code in the main loop.
This lets us see debug trace instructions interleaved with real code.

The input coordinate is clamped against a known uniform value
(`colorGreen` always contains 0101) so that the final test output
remains consistent in practice.

Additionally, I noticed that this test was only enabled in ES3, but
it doesn't seem to have anything ES3-specific in it, so it's now
enabled across the board.

Change-Id: Ie82f40b1060edb6071e300040ac59fb7d27094b0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/470397
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
John Stiles 2021-11-12 08:45:31 -05:00 committed by SkCQ
parent 7ee4dec0e5
commit 1991780081
7 changed files with 1394 additions and 1180 deletions

View File

@ -4,31 +4,30 @@ uniform half4 colorRed, colorGreen;
// Should return 5
const float kZero = 0;
float return_loop() {
float return_loop(float five) {
for (float i = kZero; i < 10; ++i) {
bool shouldExit = (i == float(colorGreen.g * 5));
if (shouldExit) { return i; }
if (i == five) { return i; }
}
return 0;
}
// Should return 35
const float kTen = kZero + 10;
float continue_loop() {
float continue_loop(float five) {
float sum = 0;
for (float i = 0; i < kTen; ++i) {
if (i < 5) { continue; }
if (i < five) { continue; }
sum += i;
}
return sum;
}
// Should return 15
float break_loop() {
float break_loop(float five) {
float sum = 0;
const float kOne = 1;
for (float i = 0; i < 10; i += kOne) {
if (i > 5) { break; }
if (i > five) { break; }
sum += i;
}
return sum;
@ -113,9 +112,10 @@ bool loop_operator_eq() {
return result == float4(9, 9, 9, 1);
}
half4 main(float2 xy) {
return (return_loop() == 5 && continue_loop() == 35 &&
break_loop() == 15 && abs(float_loop()) < 0.025 &&
half4 main(float2 pos) {
float five = clamp(pos.x, colorGreen.g, colorGreen.a) * 5.0;
return (return_loop(five) == 5 && continue_loop(five) == 35 &&
break_loop(five) == 15 && abs(float_loop()) < 0.025 &&
loop_operator_le() && loop_operator_lt() &&
loop_operator_ge() && loop_operator_gt() &&
loop_operator_eq() && loop_operator_ne()) ? colorGreen : colorRed;

View File

@ -4,31 +4,30 @@ uniform half4 colorRed, colorGreen;
// Should return 5
const int kZero = 0;
int return_loop() {
int return_loop(int five) {
for (int i = kZero; i < 10; ++i) {
bool shouldExit = (i == int(colorGreen.g * 5));
if (shouldExit) { return i; }
if (i == five) { return i; }
}
return 0;
}
// Should return 35
const int kTen = kZero + 10;
int continue_loop() {
int continue_loop(int five) {
int sum = 0;
for (int i = 0; i < kTen; ++i) {
if (i < 5) { continue; }
if (i < five) { continue; }
sum += i;
}
return sum;
}
// Should return 15
int break_loop() {
int break_loop(int five) {
int sum = 0;
const int kOne = 1;
for (int i = 0; i < 10; i += kOne) {
if (i > 5) { break; }
if (i > five) { break; }
sum += i;
}
return sum;
@ -104,8 +103,9 @@ bool loop_operator_eq() {
return result == int4(9, 9, 9, 1);
}
half4 main(float2 xy) {
return (return_loop() == 5 && continue_loop() == 35 && break_loop() == 15 &&
half4 main(float2 pos) {
int five = int(clamp(pos.x, colorGreen.g, colorGreen.a)) * 5;
return (return_loop(five) == 5 && continue_loop(five) == 35 && break_loop(five) == 15 &&
loop_operator_le() && loop_operator_lt() &&
loop_operator_ge() && loop_operator_gt() &&
loop_operator_eq() && loop_operator_ne()) ? colorGreen : colorRed;

View File

@ -279,8 +279,8 @@ SKSL_TEST_ES3(SkSLIntrinsicTranspose, "intrinsics/Transpose.sksl")
SKSL_TEST_ES3(SkSLIntrinsicUintBitsToFloat, "intrinsics/UintBitsToFloat.sksl")
SKSL_TEST_ES3(SkSLArrayNarrowingConversions, "runtime/ArrayNarrowingConversions.rts")
SKSL_TEST_ES3(SkSLLoopFloat, "runtime/LoopFloat.rts")
SKSL_TEST_ES3(SkSLLoopInt, "runtime/LoopInt.rts")
SKSL_TEST(SkSLLoopFloat, "runtime/LoopFloat.rts")
SKSL_TEST(SkSLLoopInt, "runtime/LoopInt.rts")
SKSL_TEST(SkSLQualifierOrder, "runtime/QualifierOrder.rts")
SKSL_TEST(SkSLPrecisionQualifiers, "runtime/PrecisionQualifiers.rts")

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
uniform half4 colorRed;
uniform half4 colorGreen;
const float kZero_0 = 0.0;
float return_loop_0();
float return_loop_0(float five);
const float kTen_0 = 10.0;
float continue_loop_0();
float break_loop_0();
float continue_loop_0(float five);
float break_loop_0(float five);
float float_loop_0();
bool loop_operator_le_0();
bool loop_operator_lt_0();
@ -12,24 +12,23 @@ bool loop_operator_ge_0();
bool loop_operator_gt_0();
bool loop_operator_ne_0();
bool loop_operator_eq_0();
float return_loop_0()
float return_loop_0(float five)
{
for (float i = kZero_0;i < 10.0; ++i)
{
bool shouldExit = i == float(colorGreen.y * 5.0);
if (shouldExit)
if (i == five)
{
return i;
}
}
return 0.0;
}
float continue_loop_0()
float continue_loop_0(float five)
{
float sum = 0.0;
for (float i = 0.0;i < kTen_0; ++i)
{
if (i < 5.0)
if (i < five)
{
continue;
}
@ -37,13 +36,13 @@ float continue_loop_0()
}
return sum;
}
float break_loop_0()
float break_loop_0(float five)
{
float sum = 0.0;
const float kOne = 1.0;
for (float i = 0.0;i < 10.0; i += kOne)
{
if (i > 5.0)
if (i > five)
{
break;
}
@ -124,7 +123,8 @@ bool loop_operator_eq_0()
}
return result == float4(9.0, 9.0, 9.0, 1.0);
}
half4 main(float2 xy)
half4 main(float2 pos)
{
return half4(((((((((return_loop_0() == 5.0 && continue_loop_0() == 35.0) && break_loop_0() == 15.0) && abs(float_loop_0()) < 0.02500000037252903) && loop_operator_le_0()) && loop_operator_lt_0()) && loop_operator_ge_0()) && loop_operator_gt_0()) && loop_operator_eq_0()) && loop_operator_ne_0() ? colorGreen : colorRed);
float five = clamp(_coords.x, float(colorGreen.y), float(colorGreen.w)) * 5.0;
return half4(((((((((return_loop_0(five) == 5.0 && continue_loop_0(five) == 35.0) && break_loop_0(five) == 15.0) && abs(float_loop_0()) < 0.02500000037252903) && loop_operator_le_0()) && loop_operator_lt_0()) && loop_operator_ge_0()) && loop_operator_gt_0()) && loop_operator_eq_0()) && loop_operator_ne_0() ? colorGreen : colorRed);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,33 @@
uniform half4 colorRed;
uniform half4 colorGreen;
const int kZero_0 = 0;
int return_loop_0();
int return_loop_0(int five);
const int kTen_0 = 10;
int continue_loop_0();
int break_loop_0();
int continue_loop_0(int five);
int break_loop_0(int five);
bool loop_operator_le_0();
bool loop_operator_lt_0();
bool loop_operator_ge_0();
bool loop_operator_gt_0();
bool loop_operator_ne_0();
bool loop_operator_eq_0();
int return_loop_0()
int return_loop_0(int five)
{
for (int i = kZero_0;i < 10; ++i)
{
bool shouldExit = i == int(colorGreen.y * 5.0);
if (shouldExit)
if (i == five)
{
return i;
}
}
return 0;
}
int continue_loop_0()
int continue_loop_0(int five)
{
int sum = 0;
for (int i = 0;i < kTen_0; ++i)
{
if (i < 5)
if (i < five)
{
continue;
}
@ -36,13 +35,13 @@ int continue_loop_0()
}
return sum;
}
int break_loop_0()
int break_loop_0(int five)
{
int sum = 0;
const int kOne = 1;
for (int i = 0;i < 10; i += kOne)
{
if (i > 5)
if (i > five)
{
break;
}
@ -114,7 +113,8 @@ bool loop_operator_eq_0()
}
return result == int4(9, 9, 9, 1);
}
half4 main(float2 xy)
half4 main(float2 pos)
{
return half4((((((((return_loop_0() == 5 && continue_loop_0() == 35) && break_loop_0() == 15) && loop_operator_le_0()) && loop_operator_lt_0()) && loop_operator_ge_0()) && loop_operator_gt_0()) && loop_operator_eq_0()) && loop_operator_ne_0() ? colorGreen : colorRed);
int five = int(clamp(_coords.x, float(colorGreen.y), float(colorGreen.w))) * 5;
return half4((((((((return_loop_0(five) == 5 && continue_loop_0(five) == 35) && break_loop_0(five) == 15) && loop_operator_le_0()) && loop_operator_lt_0()) && loop_operator_ge_0()) && loop_operator_gt_0()) && loop_operator_eq_0()) && loop_operator_ne_0() ? colorGreen : colorRed);
}