PDA

View Full Version : Memory issue in offscreen rendering



ramya987
03-15-2011, 02:53 AM
Hi

I face a problem with texture rendering in offscreen rendering mode. I have a huge set of vertices (formed by accumulation) rendered onto an FBO. The vertex structure includes actual vertices, texture vertices and the color data. When the total number of indices exceeds a certain limit the frame is not drawn. Neither does it throw any glError. It is not the number of indices drawn at one stretch, but the total number of indices for the entire frame when exceeds a certain limit gives the problem. I do delete the vbo-s created as and when it is rendered. Can someone tell me what might be the cause of this problem. Is there something that I am missing out.

The same code works properly when rendered directly onto the surface instead of FBO. Also the problem occurs only in Motorola Milestone and works properly with Samsung Galaxy Tab.



glEnable( GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);

glVertexPointer(3, GL_FLOAT, 0, vertexArray);
glTexCoordPointer(2, GL_FLOAT, 0, texArray);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorArray);

glBindTexture(GL_TEXTURE_2D, *m_OuterTexture);
glDrawElements(GL_TRIANGLES, iNumIndices, GL_UNSIGNED_SHORT, pauiNewIndices);
checkGlError("draw tess 1");

if( bFillInner )
{
glBindTexture(GL_TEXTURE_2D, *m_InnerTexture);
glDrawElements(GL_TRIANGLES, iNumLines * 18, GL_UNSIGNED_SHORT, pauiNewIndices);
checkGlError("draw tess 2");
}

glDisable( GL_TEXTURE_2D);

SteveBaker
03-17-2011, 12:02 PM
I think your problem must lie elsewhere. The system should allow you to render an unlimited number of vertices per frame. The problem doesn't even make sense...I mean, once the system has rendered a bunch of vertices, they have turned into pixels in the frame buffer. There is no place in the system that "remembers" things you already drew.

So my bet is that you have some other bug and it's just crashing the thing at this point by chance.

ramya987
03-17-2011, 10:45 PM
But as I told you, the same code works on Galaxy tab which has a better configuration. So I thought the problem might lie with memory. And could it be possible that the gl calls got accumulated and were not pushed to GPU till then. Because somewhere I read that PowerVR does an internal optimization by accumulating all gl calls and pushes it right before the buffer gets swapped. Does that have anything to do with this?

But I also tried giving a glFinish call at the end of each glDrawElement. It dint work out.

Also, if I just comment out the binding and drawing of second texture the limit on number of indices is relaxed a bit. Say previously the frame got rendered only for X indices. Now it renders for some X+Y. But not beyond that.

SteveBaker
03-18-2011, 06:46 AM
I suppose that's possible - and if so, a bug in their driver could certainly cause a bug like this.

Perhaps sticking a gl.flush(); into your code every few thousand draw calls would help?

But if this is the problem, it's definitely a driver bug - WebGL/OpenGL/Direct3D don't limit the number of triangles you can draw when they are implemented correctly.

-- Steve