Can anyone explain why glDrawArrays() causes high CPU utilization?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can anyone explain why glDrawArrays() causes high CPU utilization?

1,086 Views
dominicwalkes
Contributor I

We have noticed high utilization of the main CPU while glDrawArrays() is executing. Our expectation is that glDrawArrays() should primarily cause high GPU utilization with minimal impact on the main CPU.

Circumstance:

Our environment is linux/Qt. We are rendering the screen on a timer at 20fps. We have 60+ VBOs in GPU RAM. The VBOs are GL_TRIANGLE type. We are not using VAOs or index buffers. Each VBO contains 2000 triangles/6000 vertices. Each frame we invoke glDrawArrays() for each VBO. All calls use the same shader programs:

    QString vertexShader =
        "uniform float useUniformColor;"
        "uniform highp vec4 uniformColor;"
        "uniform highp mat4 ortho;"
 
        "attribute highp vec3 a_position;"
        "attribute highp vec4 a_color;"
 
        "varying highp vec4 v_color;"
 
        "void main()\
        {\
           gl_Position = vec4(a_position,1) * ortho;\
           if(useUniformColor != 0.0)\
               v_color = uniformColor;\
           else\
               v_color = a_color;\
        }";
 
 
 
 
    QString fragmentShader =
 
        "varying highp vec4 v_color;"
 
        ""
 
        "void main()"
 
        "{"
 
        "    gl_FragColor = v_color;"
 
        "}";
 
0 Kudos
4 Replies

853 Views
dominicwalkes
Contributor I

Thanks for the response. 

Measurements were simply taken with top from the command line.  I have attached the source code used for a simple example (tdSimpleTestWidget.zip).

0 Kudos

853 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi

Could you share your perfomance measurements data, and how are you getting those numbers? Looks like you are using purely software libraries instead of using hfp libraries or the GPU driver for your OpenCL testing.

Regards

0 Kudos

853 Views
colonelpanic
Contributor I

@bio,

In our initial implementation, we generate several VBOs with 6000 vertices each (about 360k vertices).  The resulting CPU load was in the 60% range.  We were able to move this to a single VBO and we implemented an index buffer (now using glDrawElements)  and brought the CPU utilization down to about 35%, but this still seems high. 

Thanks,

Ben Beckwith

0 Kudos

853 Views
colonelpanic
Contributor I

Furthermore, the results of glGetString(GL_VERSION) and glGetString(GL_SHADING_LANGUAGE_VERSION) is:

     GL Version:  "OpenGL ES 3.0 V5.0.11.p4.25762"  GL Shader Version:  "OpenGL ES GLSL ES 3.00"

I'm assuming this implies Hardware acceleration.

Thanks,
Ben Beckwith

0 Kudos