View Full Version : Can shader programs return values?
01-13-2011, 04:58 AM
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
01-13-2011, 06:21 AM
or use another lib like opencl or cuda.
01-13-2011, 04:46 PM
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:
01-14-2011, 05:26 AM
i should have said that i'm using WebGL and so there is no CUDA or something, just OpenGL2 ;)
01-14-2011, 10:05 AM
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.
01-18-2011, 08:48 AM
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
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.