Jump to content
  • Advertisement
Sign in to follow this  
glJack

EXT_PIXEL_BUFFER_OBJECT for Render to Texture

This topic is 4739 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this way PBO can be used for render-to-texture implementation:
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, m_iBuffer);
glReadPixels(0,0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, 0);

glBindTexture(GL_TEXTURE_2D, m_iTexture);
	
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, m_iBuffer);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
it works, but it is only 3% faster(GeForce2 GTS) than the following:
char buff[512][512][3];
glReadPixels(0,0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, buff);
glBindTexture(GL_TEXTURE_2D, m_iTexture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, buff);
what's wrong? Why doesn't PBO accelerate the process of data transmission within the videocard? Well, maybe the PBO main intent is to parallelize data excange between app and gfx card, but in this case it should also increase performance, I think.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by glJack

char buff[512][512][3];
glReadPixels(0,0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, buff);
glBindTexture(GL_TEXTURE_2D, m_iTexture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, buff);


If this is all you need, glCopyTexImage2D(...) will be a lot faster. Allthough it's supposed to be better on newer hardware, glReadPixels() is still dreadfully slow. You won't be able to modify or access the texture in your app, though (because it copies within GPU memory).

Tom

Share this post


Link to post
Share on other sites
Quote:

If this is all you need, glCopyTexImage2D(...) will be a lot faster.

I tried it, and it is 2 times faster. Yes, it is faster and I'd use it.

But I just want to compare performance of 1st and 2nd cases. I think that in the first case data copying has be faster than in the second case, because in 1st case all copying operations happen within gfx card/driver memory, and in 2nd case data is copied to system memory, and read back from it.

The first piece of code uses PBO, has to be nearly as fast as glCopyTexImage2D(...) is.

Why there is no difference in performance between these 2 approaches?
Maybe this is because I test them on GeForce 2 GTS card. Maybe GeForce 2 GTS doesn't have hardware support for this extension, and all PBO memory allocations/operations happen within system memory?

Share this post


Link to post
Share on other sites
Quote:
Original post by glJack
But I just want to compare performance of 1st and 2nd cases. I think that in the first case data copying has be faster than in the second case, because in 1st case all copying operations happen within gfx card/driver memory, and in 2nd case data is copied to system memory, and read back from it.

The first piece of code uses PBO, has to be nearly as fast as glCopyTexImage2D(...) is.


Do you have any evidence to support this claim?

Tom

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by dimebolt
Do you have any evidence to support this claim?

Tom


He thinks that it should be faster. If he is wrong just explain him why. Why is it that everybody has to show evidences for everything these days? This is not a politic show.

Share this post


Link to post
Share on other sites
Quote:

He thinks that it should be faster. If he is wrong just explain him why. Why is it that everybody has to show evidences for everything these days? This is not a politic show.


If I knew why, I would tell him why. I do not know the mechanics behind GL_PIXEL_PACK_BUFFER_EXT (and I'm sure, I'm not alone in that). From the posts from glJack, I get the impression he is aware of these mechanics. All I meant was to ask for a link or pointer to a document that explained why it should work as he claims it should work. English not being my first language, I probably used the incorrect phrasing to convey this message.

Tom

Share this post


Link to post
Share on other sites
Quote:

Do you have any evidence to support this claim?


No, I don't. If I did, I would post it here. As I allready said
I think that it should be faster, because all data transfer operations happen wihting gfx card memory, as in the case with glCopyTexImage2D, so the speed has to be comparable with that.

Maybe the PBO approach speed doesn't have to be as glCopyTexImage2D but it has to be more than just 3% faster than pure
glReadPixels(0,0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, buff);

The fact that speed difference is minimal made me think that GeForce 2 GTS
implements PBO ext in software, and keeps all PBO data in system memory...

Quote:

He thinks that it should be faster. If he is wrong just explain him why. Why is it that everybody has to show evidences for everything these days? This is not
a politic show.

I really just think it should be faster, I don't claim that.

Anonymous poster
Thanx :)

Share this post


Link to post
Share on other sites
Quote:
Original post by glJack
The fact that speed difference is minimal made me think that GeForce 2 GTS
implements PBO ext in software, and keeps all PBO data in system memory...


I don't know enough about GL_PIXEL_PACK_BUFFER_EXT to answer your question. Could you post the entire code? I can try it later today, on my Geforce6 at home. That one should definately support the extension. Then we'll at least know if the problem is caused by your geforce2. It is quite likely that the problem lies there, because the GL_PIXEL_PACK_BUFFER_EXT extension is more recent than the Geforce2.

Tom

Share this post


Link to post
Share on other sites
dimebolt
the source and binaries are here: www.glplanet3d.newmail.ru/pbo/pbo.html

The demo will work for 30 seconds and generate "out.txt" file.
thank you for assistance!

btw, which tag is used to post a link ?

[Edited by - glJack on July 5, 2005 11:30:57 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by glJack
dimebolt
the source and binaries are here: www.glplanet3d.newmail.ru/pbo/pbo.html

The demo will work for 30 seconds and generate "out.txt" file.
thank you for assistance!

btw, which tag is used to post a link ?


Sorry, but I was already offline when you posted. Did you take it down again? Because the link is dead now... You can use normal html to post links ("a href") tags to post links.

Tom

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!