开发者

Conjugate Gradients on iPhone/iPad using OpenGL ES 2.0

I wrote this as a question in a comment but I feel it is worth its own question.

I would like to build a conjugate gradients solver on the iPhone/iPad as it would open up a realm of new possibilities for GPGPU programming on these devices such as real time optical flow/real time simulations/real time finite elements.

The very well written chapter from GpuGems explains how it can be done using floating point textures.

The first problem I have encountered is that I havent managed to create a floating point render-to-texture. Perhaps I simply dont have the right parameters for my texture setup. For example this code succeeds on the first line but then fails on the second one with an GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error.

glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, 0);
glFramebufferTexture2D(GL_FRAM开发者_如何学编程EBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureHandle, 0);

So, my question is how can I do render-to-floating-point-texture on iPhone/iPad?

Alternatively is there another way to solve this problem? I thought one messy alternative would be to use floating point textures in a frag shader and then render the resulting 16bit half-float into a regular gl_FragColor in a fragment shader by simply storing its first 8 bits in the R and second 8 bits in the G of gl_FragColor. Then I could read these values back from the FB using glReadPixels and reinterpret them as half floats and transfer that data to a new texture and repeat the process. The obvious problem with this is that it requires a very wasteful round trip from the GPU back to the CPU and then back to the GPU and im pretty sure it wont give any speed improvement.

Does anyone have any ideas?


Look up the Accelerate library, the vDSP functions

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜