Consider this example where each pixel needs to undergo two tests. The final value of the pixel must be determined by the minimum value of the two tests.
Var x, y;
Func f;
int32_t width = 100;
int32_t height = 100;
Buffer<uint8_t> output(width, height);
Buffer<double> minBuffer(width, height);
minBuffer.fill(1e10);
f(x, y) = cast<uint8_t>(0);
std::vector<double> zs = {0, 1};
for (const double& z : zs)
{
Expr zTest = Expr(z) < minBuffer(x, y);
f(x, y) = select(zTest, cast<uint8_t>(Expr(z) * Expr(255)), f(x, y));
minBuffer(x, y) = select(zTest, Expr(z), minBuffer(x, y));
}
f.realize(output);
In this case, the final value of the pixel must be 0 black image since the minimum z = 0. However, I'm getting back a white image, suggesting that the update definition to minBuffer is being evaluated before the zTest has taken place.
NOT A CONTRIBUTION
Consider this example where each pixel needs to undergo two tests. The final value of the pixel must be determined by the minimum value of the two tests.
In this case, the final value of the pixel must be
0black image since the minimumz = 0. However, I'm getting back a white image, suggesting that the update definition tominBufferis being evaluated before thezTesthas taken place.NOT A CONTRIBUTION