Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   GLES Performance (https://www.delphipraxis.net/189501-gles-performance.html)

Peter666 19. Jun 2016 18:36

GLES Performance
 
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


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz