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.
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 should have said that i’m using WebGL and so there is no CUDA or something, just OpenGL2
i just want to shift some matrix multiplications from javascript to the shaders
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