Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: So Mär 07, 2021 09:17

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: PBuffers
BeitragVerfasst: Sa Okt 29, 2011 22:46 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
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.

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: PBuffers
BeitragVerfasst: So Okt 30, 2011 10:15 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
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 ;)

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: PBuffers
BeitragVerfasst: Di Nov 01, 2011 20:49 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
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.

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.026s | 17 Queries | GZIP : On ]