## OpenGL Trace

OpenGL and OpenGL ES APIs can be traced to assist in the analysis of CPU and GPU interactions.

A few usage examples are:

1. Visualize how long `eglSwapBuffers` (or similar) is taking.

2. API trace can easily show correlations between thread state and graphics driver's behavior, uncovering where the CPU may be waiting on the GPU.

3. Spot bubbles of opportunity on the GPU, where more GPU workload could be created.

4. Use `KHR_debug` extension to trace GL events on both the CPU and GPU.

OpenGL trace feature in Nsight Systems consists of two different activities:

- CPU trace: interception of API calls that an application does to APIs (such as OpenGL, OpenGL ES, EGL, GLX, WGL, etc.).

- GPU trace (or workload trace): trace of GPU workload (activity) triggered by use of OpenGL or OpenGL ES.

To collect GPU trace, the `glQueryCounter()` function is used to measure how much time batches of GPU workload take to complete.

### OpenGL Trace Using Command Line

For general information on using the target CLI, see Profiling Applications on Linux from the Command Line. For the x86_64 target CLI, the functions that are traced are set to the following list:

>     glWaitSync
>     glReadPixels
>     glReadnPixelsKHR
>     glReadnPixelsEXT
>     glReadnPixelsARB
>     glReadnPixels
>     glFlush
>     glFinishFenceNV
>     glFinish
>     glClientWaitSync
>     glClearTexSubImage
>     glClearTexImage
>     glClearStencil
>     glClearNamedFramebufferuiv
>     glClearNamedFramebufferiv
>     glClearNamedFramebufferfv
>     glClearNamedFramebufferfi
>     glClearNamedBufferSubDataEXT
>     glClearNamedBufferSubData
>     glClearNamedBufferDataEXT
>     glClearNamedBufferData
>     glClearIndex
>     glClearDepthx
>     glClearDepthf
>     glClearDepthdNV
>     glClearDepth
>     glClearColorx
>     glClearColorIuiEXT
>     glClearColorIiEXT
>     glClearColor
>     glClearBufferuiv
>     glClearBufferSubData
>     glClearBufferiv
>     glClearBufferfv
>     glClearBufferfi
>     glClearBufferData
>     glClearAccum
>     glClear
>     glDispatchComputeIndirect
>     glDispatchComputeGroupSizeARB
>     glDispatchCompute
>     glComputeStreamNV
>     glNamedFramebufferDrawBuffers
>     glNamedFramebufferDrawBuffer
>     glMultiDrawElementsIndirectEXT
>     glMultiDrawElementsIndirectCountARB
>     glMultiDrawElementsIndirectBindlessNV
>     glMultiDrawElementsIndirectBindlessCountNV
>     glMultiDrawElementsIndirectAMD
>     glMultiDrawElementsIndirect
>     glMultiDrawElementsEXT
>     glMultiDrawElementsBaseVertex
>     glMultiDrawElements
>     glMultiDrawArraysIndirectEXT
>     glMultiDrawArraysIndirectCountARB
>     glMultiDrawArraysIndirectBindlessNV
>     glMultiDrawArraysIndirectBindlessCountNV
>     glMultiDrawArraysIndirectAMD
>     glMultiDrawArraysIndirect
>     glMultiDrawArraysEXT
>     glMultiDrawArrays
>     glListDrawCommandsStatesClientNV
>     glFramebufferDrawBuffersEXT
>     glFramebufferDrawBufferEXT
>     glDrawTransformFeedbackStreamInstanced
>     glDrawTransformFeedbackStream
>     glDrawTransformFeedbackNV
>     glDrawTransformFeedbackInstancedEXT
>     glDrawTransformFeedbackInstanced
>     glDrawTransformFeedbackEXT
>     glDrawTransformFeedback
>     glDrawTexxvOES
>     glDrawTexxOES
>     glDrawTextureNV
>     glDrawTexsvOES
>     glDrawTexsOES
>     glDrawTexivOES
>     glDrawTexiOES
>     glDrawTexfvOES
>     glDrawTexfOES
>     glDrawRangeElementsEXT
>     glDrawRangeElementsBaseVertexOES
>     glDrawRangeElementsBaseVertexEXT
>     glDrawRangeElementsBaseVertex
>     glDrawRangeElements
>     glDrawPixels
>     glDrawElementsInstancedNV
>     glDrawElementsInstancedEXT
>     glDrawElementsInstancedBaseVertexOES
>     glDrawElementsInstancedBaseVertexEXT
>     glDrawElementsInstancedBaseVertexBaseInstanceEXT
>     glDrawElementsInstancedBaseVertexBaseInstance
>     glDrawElementsInstancedBaseVertex
>     glDrawElementsInstancedBaseInstanceEXT
>     glDrawElementsInstancedBaseInstance
>     glDrawElementsInstancedARB
>     glDrawElementsInstanced
>     glDrawElementsIndirect
>     glDrawElementsBaseVertexOES
>     glDrawElementsBaseVertexEXT
>     glDrawElementsBaseVertex
>     glDrawElements
>     glDrawCommandsStatesNV
>     glDrawCommandsStatesAddressNV
>     glDrawCommandsNV
>     glDrawCommandsAddressNV
>     glDrawBuffersNV
>     glDrawBuffersATI
>     glDrawBuffersARB
>     glDrawBuffers
>     glDrawBuffer
>     glDrawArraysInstancedNV
>     glDrawArraysInstancedEXT
>     glDrawArraysInstancedBaseInstanceEXT
>     glDrawArraysInstancedBaseInstance
>     glDrawArraysInstancedARB
>     glDrawArraysInstanced
>     glDrawArraysIndirect
>     glDrawArraysEXT
>     glDrawArrays
>     eglSwapBuffersWithDamageKHR
>     eglSwapBuffers
>     glXSwapBuffers
>     glXQueryDrawable
>     glXGetCurrentReadDrawable
>     glXGetCurrentDrawable
>     glGetQueryObjectuivEXT
>     glGetQueryObjectuivARB
>     glGetQueryObjectuiv
>     glGetQueryObjectivARB
>     glGetQueryObjectiv

Copyright (c) 2012-2020, NVIDIA Corporation. All rights reserved.