I am trying to re-implement the bilateral grid example with multi-channel input/output(3 channels image). And try to use the OpenGL/GLSL schedule. Here is the code segments that I wrote.
class BilateralGrid : public Halide::Generator<BilateralGrid> {
public:
GeneratorParam<int> s_sigma{"s_sigma", 8};
ImageParam input{Float(32), 3, "input"};
Param<float> r_sigma{"r_sigma"};
Func build() {
Var x("x"), y("y"), z("z"), c("c"), ch("ch");
...
Func histogram("histogram");
histogram(x, y, ch, z, c) = 0.0f;
histogram(x, y, ch, zi, c) += select(c == 0, val, 1.0f);
...
input.dim(2).set_bounds(0,3);
bilateral_grid.bound(ch, 0 ,3);
bilateral_grid.glsl(x , y, ch);
return bilateral_grid;
}
};
Halide::RegisterGenerator<BilateralGrid> register_me{"bilateral_grid"};
But I've got an error when trying to compile the code.
Error
Allocations inside GLSL kernels must be constant-sized
In my limited experience with halide, I can't find why...
Thanks in advance.