DGL
https://delphigl.com/forum/

PBuffers
https://delphigl.com/forum/viewtopic.php?f=19&t=10141
Seite 1 von 1

Autor:  Stucuk [ Sa Okt 29, 2011 22:46 ]
Betreff des Beitrags:  PBuffers

Is it only with OpenGL ES where PBuffers are faster at updating a texture than without one?(From what iv read in OpenGL ES you can "upload" faster with PBuffers than just using glTexSubImage2D alone. At least thats the method people are recommending.)

//PBuffer
Code:
  1. constructor TSPBuffer.Create(var Texture : TOGL_Texture; const Width, Height : Integer);
  2. const
  3.   fAttributes    : array [0..1]  of Single  = (0,0);
  4.   iAttributes    : array [0..19] of Integer = (WGL_SUPPORT_OPENGL_ARB,1,WGL_DRAW_TO_PBUFFER_ARB,1,WGL_DOUBLE_BUFFER_ARB,0,WGL_RED_BITS_ARB,5,WGL_GREEN_BITS_ARB,6,WGL_BLUE_BITS_ARB,5,WGL_DEPTH_BITS_ARB,0,WGL_ALPHA_BITS_ARB,0,WGL_STENCIL_BITS_ARB,0,0,0);
  5.   PBufferAttribs : array [0..5]  of Integer = (WGL_TEXTURE_FORMAT_ARB,WGL_TEXTURE_RGB_ARB,WGL_TEXTURE_TARGET_ARB,WGL_TEXTURE_2D_ARB,0,0);
  6. var
  7.  Format,
  8.  NumFormats : Integer;
  9. begin
  10.  FHandle := 0;
  11.  
  12.  if Texture = Nil then
  13.  begin
  14.   Texture := TextureSystem.CreateTexture('PBuffer',True);
  15.  end;
  16.  
  17.  FTexture := Texture;
  18.  
  19.  if not wglChoosePixelFormatARB(OriginalWar.Renderer.OGL.DC, @iAttributes, @fAttributes, 1, @Format, @NumFormats) then
  20.  begin
  21.   OriginalWar.ErrorLog.Error('No Pixel Formats for a PBuffer',etCritical);
  22.   Exit;
  23.  end;
  24.  
  25.  FHandle := wglCreatePBufferARB(OriginalWar.Renderer.OGL.DC,Format,Width,Height,@PBufferAttribs);
  26.  if FHandle < 1 then
  27.  begin
  28.   OriginalWar.ErrorLog.Error('wglCreatePBufferARB Failed',etCritical);
  29.   Exit;
  30.  end;
  31.  
  32.  FDC := wglGetPBufferDCARB(FHandle);
  33.  if FDC < 1 then
  34.  begin
  35.   OriginalWar.ErrorLog.Error('wglGetPBufferDCARB Failed',etCritical);
  36.   Exit;
  37.  end;
  38. end;
  39.  
  40.  
  41. procedure TSPBuffer.BeginPBuffer;
  42. begin
  43.  FTexture.BindTexture;
  44.  wglBindTexImageARB(FHandle, WGL_FRONT_LEFT_ARB);
  45. end;
  46.  
  47. procedure TSPBuffer.EndPBuffer;
  48. begin
  49.  wglReleaseTexImageARB(FHandle, WGL_FRONT_LEFT_ARB);
  50. end;


//Test Code
Code:
  1. var
  2.  TestTex  : TOGL_Texture = Nil;
  3.  TestData : Pointer = Nil;
  4.  FPS      : Integer;
  5.  PBuffer  : TSPBuffer = Nil;
  6.  
  7. procedure Test;
  8. const
  9.  Size = 2048;
  10. begin
  11.  OptimisedTextures := True;
  12.  
  13.  if not Assigned(TestTex) then
  14.  begin
  15.   TestTex := TextureSystem.CreateTexture('TestTex',True);
  16.   TestTex.UseNearest := True;
  17.   GetMem(TestData,Size*Size*2);
  18.   TestTex.UpdateTexture(Size,Size,2,GL_RGB,GL_RGB,TestData,GL_TEXTURE_2D,GL_UNSIGNED_SHORT_5_6_5);
  19.   PBuffer := TSPBuffer.Create(TestTex,Size,Size);
  20.  end;
  21.  
  22.  TestTex.UseNearest := True;
  23.  
  24.  PBuffer.BeginPBuffer;
  25.  FillChar(TestData^,Size*Size*2,Random(256));
  26.  TestTex.UpdateTexture(Size,Size,2,GL_RGB,GL_RGB,TestData,GL_TEXTURE_2D,GL_UNSIGNED_SHORT_5_6_5);
  27.  PBuffer.EndPBuffer;
  28.  
  29.  FPS := SystemTimer.GetFPS;
  30. end;


With the PBuffer sections commented out i get about 25FPS, with them kept in i get 21FPS.

Autor:  Coolcat [ So Okt 30, 2011 10:15 ]
Betreff des Beitrags:  Re: PBuffers

I have never heard of that, but I'm not using OpenGL ES much. This might be something hardware/driver specific. I don't think that you can say something like that in general for OpenGL ES. If PBuffers are faster, than a good driver implementation would use PBuffers internally and you would get at least the same speed ;)

Autor:  Stucuk [ Di Nov 01, 2011 20:49 ]
Betreff des Beitrags:  Re: PBuffers

Coolcat hat geschrieben:
If PBuffers are faster, than a good driver implementation would use PBuffers internally and you would get at least the same speed ;)

No. PBuffers are "Supposedly" faster when it comes to uploading the texture data to the graphics card, not faster at rendering. Basically as far as i understand with a PBuffer it doesn't apply the same algarithums which would be used normally to speed up rendering(If im correct ones to turn the data into whatever format the graphics card likes internally). So uploading is meant to be faster but rendering is meant to be slower, so they couldn't use PBuffers in the drivers for normal textures because applications would run slower.

Im only going by what iv read. Never used OpenGL ES.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/