Einzelnen Beitrag anzeigen

Peter666

Registriert seit: 11. Aug 2007
357 Beiträge
 
#1

GLES Performance

  Alt 19. Jun 2016, 18:36
Hi,

ich hab hier ein Performance bzw. Verständnis Problem. Unter iOS ist TViewport3D ziemlich langsam, wenn man häufig die Darstellung aktualisiert. Im Vergleich zu TForm3D ist das bis zu 50% langsamer. Der Grund ist das der Context in einem Framebuffer gerendert wird und dann als Bitmap gespeichert wird. Knackpunkt ist folgende Routine:

Delphi-Quellcode:
procedure TCustomContextOpenGL.DoCopyToBitmap(const Dest: TBitmap; const ARect: TRect);
var
  OldTexture, OldFBO: GLuint;
  DestContext: TCustomContextOpenGL;
  CopyRect: TRect;
begin
  if Valid then
  begin
    if (TCanvasStyle.NeedGPUSurface in Dest.CanvasClass.GetCanvasStyle) and (Texture <> nil) then
    begin
      DestContext := TCustomContextOpenGL(TCustomCanvasGpu(Dest.Canvas).Context);
      glGetIntegerv(GL_FRAMEBUFFER_BINDING, @OldFBO);
      glGetIntegerv(GL_TEXTURE_BINDING_2D, @OldTexture);

      glBindFramebuffer(GL_FRAMEBUFFER, DestContext.FFrameBuf);
      Clear(0);

      glBindTexture(GL_TEXTURE_2D, DestContext.Texture.Handle);
      glBindFramebuffer(GL_FRAMEBUFFER, FFrameBuf);

      CopyRect := TRect.Intersect(ARect, TRect.Create(0, 0, Width, Height));

      if (TTextureStyle.RenderTarget in Texture.Style) and (TContextStyle.RenderTargetFlipped in Style) then
        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, ARect.Left, DestContext.Height - CopyRect.Bottom, CopyRect.Left, Height - CopyRect.Bottom, CopyRect.Width, CopyRect.Height)
      else
        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, ARect.Left, ARect.Top, CopyRect.Left, CopyRect.Top, CopyRect.Width, CopyRect.Height);

      glBindFramebuffer(GL_FRAMEBUFFER, OldFBO);
      glBindTexture(GL_TEXTURE_2D, OldTexture);

      if (GLHasAnyErrors()) then
        RaiseContextExceptionFmt(@SErrorInContextMethod, ['DoCopyToBitmap']);
    end else begin
      inherited DoCopyToBitmap(Dest, ARect);
    end;
  end;
end;
Alleine 15% verbrät die Clear(0) Routine und ich sehe nicht den Grund warum das so langsam ist. Da wird DoClear aufgerufen und der Buffer mit 0 beschrieben. glCopyTexSubImage2D ist schon ziemlich alt und da gabs doch arge Performanceprobleme? Hat jemand eine Idee wie man das mit glBlitFramebuffer oder so beschleunigen kann?

Peter
  Mit Zitat antworten Zitat