3 Replies Latest reply on Nov 12, 2015 9:12 AM by deedeeyelverton

    fixing CPU Bound OpenGL Application

    kphillisjr

      I have a program that is getting caught being CPU bound by the glCopyTexImage2D instruction. this instruction is called several times, and each time it leads to huge drops in performance.

       

      /*
       * This is the First major cpu bound call. This is a copy of a 256 pixel by 128 pixel depth image.
       * I did not expect this to take about 3000 Microseconds.
       */
      glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 1072, 256, 128, 0); 
      /*
       * The program ran for a while longer, and I needed to copy the actual
       * Frame-buffer of the program. This time it was an 960px by 1200px image.
       * This call took about 800 microseconds.
       */
      glCopyTexImage2D(GL_TEXTURE_2D, 0, RGBA8, 0, 0, 960, 1200, 0);
      
      /* 
       * Yet another case where I needed a copy of the depth buffer.
       * It took more than 5500 microseconds
       */
      glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, 1920, 1200, 0);
      

      I am wondering if there is any easy fix to clone the frame-buffer components to a texture without making a call to glCopyTexImage2D.

        • Re: fixing CPU Bound OpenGL Application
          cgrant78@netzero.com

          ..and I would have to ask you why are you doing that ? Its a well know fact that glCopyTexImage2D will introduce a CPU-GPU synchronization point as the function cannot return until all the GPU work submitted prior to the call is completed and then the copy can take place. Did you try any more efficient alternative? The performance drop you are seeing is to be expected as the code you have in place will do exactly that. Also, you did the context in which the code is being applied, so without that, my advice would be to think really hard about what you are trying to accomplish and see if there is another way of doing so without using glCopyTexImage2D.

            • Re: fixing CPU Bound OpenGL Application
              kphillisjr

              I do not know of any other more efficient methods to do this. I also know that with how things work I am seeing a lot more latency with depth buffer copies than with standard rgba buffer copies.

               

               

              edit: I forgot to mention that the graphics engine I am using has always had no problems with stability and performance when a system is geared with a newer NVidia Geforce series graphics cards. Also, When I profiled the application on an AMD system the GPU usage was extremely low ( at about 30 percent ).

            • Re: fixing CPU Bound OpenGL Application
              deedeeyelverton

              Hi - I have whitelisted you so you can now post in any of the developer forums, and moved this post into the OpenGL forum.