gpujs / gpu.js

GPU Accelerated JavaScript
https://gpu.rocks
MIT License
15.08k stars 650 forks source link

[Feature Request] Kernel loop per-iteration data reading/fetching size/type settings #453

Open Somebi opened 5 years ago

Somebi commented 5 years ago

As i understand correctly, you can tell attribute to read more data per iteration/loop-cycle. This way we could tell to pick 9 numbers as example, it's a 3x3 matrix make calculations on them and return 9 calculated numbers back.

It would give more freedom to many non-stateless calculations. For example a Gauss Elimination could be accomplished due to pivoting.

Can this be accomplished? What do you think?

Somebi commented 5 years ago

gl.vertexAttribPointer(positionAttributeLocation, size, type, normalize, stride, offset) size - size of data to pick per iteration type - can provide the type of data stride - the step to perform, to pick next data from the buffer size * sizeof(type)

Providing the user option/setting to configure step size. As i understand loop continue until buffer is depleted or pointer reached the end of the buffer. So increasing the size of step, will reduce the amount of iterations and pass more data into the kernel, per iteration.

I'm wrong?

Somebi commented 5 years ago

Oh kernel iterations count actually can be defined here:

var count = 3;
gl.drawArrays(primitiveType, offset, count);