i want to perform some matrix multiplications on the GPU with no relation to graphics rendering.
I know i can pass data to the shader with glBindBuffer and glBufferData and manipulate it there… but is it somehow possible to get data back to my program?
I thought of calling a function like “glGetBufferData” after running the shaderprogram… but i couldn’t find something like this.
Is there a way to do this?
Thank you for your effort
or use another lib like opencl or cuda.
In addition to those, can render to a float texture or renderbuffer and read that back.
Are your matrices of large size? Are they sparse or dense?
It’d be worth thinking carefully about the multiply technique you use to minimize memory bandwidth. Often these kind of algs can use shared memory on the GPU to great advantage. To do so you’ll need to use OpenCL or CUDA. And there’s already matrix multiply code in these (CUDA at least) that you can just pick up and use.
I’d start here:
i should have said that i’m using WebGL and so there is no CUDA or something, just OpenGL2
There’s no OpenGL 2 there either. There is OpenGL ES 2.0, but that’s different from OpenGL 2.0.
Unless you are doing lots of matrix multiplications (like, tens of thousands per frame), you don’t want to do this.
Yes i think the overhead for few matrix multiplications is too big…
But another use case would be to change an objects vertex model (for example with displacement mapping + height maps) and return the transformed object vertex buffer to the program