0 Replies
      Latest reply on Jun 21, 2019 9:46 PM by lslboyhh
      lslboyhh Level 1 Level 1 (0 points)


            I developed an Opengles use the Opengles3 on iOS, I had read the OpenGL ES Programming Guide, Many techniques introduced in OpenGL ES Programming Guide are aimed specifically at creating OpenGL apps that exhibit great CPU-GPU parallelism, that meaning the CPU time is almost equal to the GPU time when displaying the OpenGL framebuffer.

           so I create I sample Opengles demo, custom a UIView class to display Opengles content which named NewOpenGLView, in the NewOpenGLView.m I create a CADisplayLink object to display the render content:

          self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkMethod)];
          self.displayLink.preferredFramesPerSecond = 30;
          [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
          [self render];
          glClearColor(0.3, 0.5, 0.8, 1.0);
          glViewport(0, 0, openGLSize.width, openGLSize.height);
          [self setupProjectionMatrixAndModelViewMatrix];
          [self drawFirstCube];
          [self drawSecondCube];
          [self drawThirdCube];
          [self setupTextureProjectionMatrixAndModelViewMatrix];
          [self drawTextrue];
          [_context presentRenderbuffer:_colorBuffer];


        the 'Show the debug navigator' window show the fps is 30 and the CPU time is 0ms and GPU time is about 1ms, it seems my Opengles app performance pretty good, I know that the render method should run on the background thread for the better UI performance,so I create a background thread to run the render method,so I change the displayLinkMethod code:

          dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
          dispatch_async(globalQueue, ^{
          if (testBool == false) {
          [EAGLContext setCurrentContext:_context];
          testBool = true;
          dispatch_semaphore_wait(signal, DISPATCH_TIME_FOREVER);
          [self render];

        after changing the displayLinkMethod code, the Opengles content can show right ar before, but the CPU time increase to 33ms, the GPU time decrease to 0ms, I think the CPU time is not suitable, it makes me confused, what should I do if I want to run the render method in the background thread and decrease the CPU time to suitable value?