Note that there are some explanatory texts on larger screens.

plurals
  1. PO512x512 Texture causing huge GPU stress on iPhone, despite tiling
    text
    copied!<p>I'm testing my simple OpenGL ES implementation (a 2D game) on the iPhone and <strong>I notice a high render utilization</strong> while using the profiler. These are the facts:</p> <ul> <li>I'm displaying <strong>only one preloaded large texture</strong> (<strong>512x512 pixels</strong>) at 60fps and the render utilization is around 40%.</li> <li>My texture is blended using <code>GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA</code>, <strong>the only GL function I'm using</strong>.</li> <li>I've tried to make the texture <strong>smaller and tiling</strong> it, which <strong>made no difference</strong>.</li> <li>I'm using a PNG texture atlas of 1024x1024 pixels</li> </ul> <p>I find it very strange that this <strong>one texture is causing such an intense GPU usage.</strong></p> <p><strong>Is this to be expected?</strong> What am I doing wrong?</p> <p><strong>EDIT:</strong> My code:</p> <pre><code>// OpenGL setup is identical to OpenGL ES template // initState is called to setup // timer is initialized, drawView is called by the timer - (void) initState { //usual init declarations have been omitted here glEnable(GL_BLEND); glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer (2,GL_FLOAT,sizeof(Vertex),&amp;allVertices[0].x); glEnableClientState (GL_TEXTURE_COORD_ARRAY); glTexCoordPointer (2,GL_FLOAT,sizeof(Vertex),&amp;allVertices[0].tx); glEnableClientState (GL_COLOR_ARRAY); glColorPointer (4,GL_UNSIGNED_BYTE,sizeof(Vertex),&amp;allVertices[0].r); } - (void) drawView { [EAGLContext setCurrentContext:context]; glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glMatrixMode(GL_PROJECTION); glLoadIdentity(); GLfloat width = backingWidth /2.f; GLfloat height = backingHeight/2.f; glOrthof(-width, width, -height, height, -1.f, 1.f); glMatrixMode(GL_MODELVIEW); glClearColor(0.f, 0.f, 0.f, 1.f); glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; [self checkGLError]; } </code></pre> <p><strong>EDIT:</strong> I've made a couple of improvements, but none managed to lower the render utilization. I've divided the texture in parts of 32x32, changed the type of the coordinates and texture coordinates from GLfloat to GLshort and added extra vertices for degenerative triangles.</p> <p>The updates are: </p> <p><strong>initState:</strong> (vertex and texture pointer are now GL_SHORT)</p> <pre><code>glMatrixMode(GL_TEXTURE); glScalef(1.f / 1024.f, 1.f / 1024.f, 1.f / 1024.f); glMatrixMode(GL_MODELVIEW); glScalef(1.f / 16.f, 1.f/ 16.f, 1.f/ 16.f); </code></pre> <p><strong>drawView:</strong></p> <pre><code>glDrawArrays(GL_TRIANGLE_STRIP, 0, 1536); //(16*16 parts * 6 vertices) </code></pre>
 

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