Note that there are some explanatory texts on larger screens.

plurals
  1. POConjugate Gradients on iPhone/iPad using OpenGL ES 2.0
    primarykey
    data
    text
    <p>I wrote this as a question in a comment but I feel it is worth its own question.</p> <p>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.</p> <p>The very well written chapter from <a href="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter44.html" rel="nofollow">GpuGems</a> explains how it can be done using floating point textures.</p> <p>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.</p> <pre><code>glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureHandle, 0); </code></pre> <p>So, my question is how can I do render-to-floating-point-texture on iPhone/iPad?</p> <p>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.</p> <p>Does anyone have any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COAlthough half-float textures (and especially render-targets) are more likely to be supprted by iGPUs, they won't buy you anything in the context of a CG solver, I think, as I doubt that the precision of a half is sufficient for practical problems (where single precision might already be too less). I suppose you will need a really good preconditioner and everything beyond a Jacobi-preconditioner is much more tricky on the GPU than a matrix-vector product (at least if you want to beat CPU mode), especially when using fragment shaders, which are much more limited than CUDA/OpenCL.
      singulars
    2. COLuckily we will be using a Jacobi-preconditioner. I am going to try and use the method described here: http://msdn.microsoft.com/en-us/library/ee416413(v=vs.85).aspx. It looks like the best way to emulate a float. Obviously the penalty for doing the encode and decode will be heavy but it might still be worth it. And finally if that doesnt work I will use Neon primitives which will give a guaranteed 3x to 8x. But thats the most Il get from NEON.
      singulars
    3. COIf you mean this RGBE shared exponent format, this is even worse. You only got around 9 bits of precision, and this only if the exponents are all the same, which they surely won't. With such extremely reduced precision formats (which might work for colors), you will surely run into problems when trying to solve real linear equation systems, especially when using a simple Jacobi preconditioner.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload