Sign in to follow this  
SteveXP

Supersampling on GPU?

Recommended Posts

SteveXP    142
Hi guys, i need to do many small offscreen renderings (64x64 pix) and load them back to the CPU. To get a better quality i'm currently supersampling, by doing the offscreen rendering in 128x128, and then downsample it to 64x64 on CPU. It should be much fastert when supersampling would be performed on GPU. What do you think is the best way to do this?

Share this post


Link to post
Share on other sites
SteveXP    142
Ok, to generate mipmaps i'd bind my FBO to a texture, like this:


glBindTexture(GL_TEXTURE_2D, ...); // new texture object
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16F_ARB, w, h, RGBA, 0, GL_RGBA, GL_FLOAT, NULL); // define base level
glGenerateMipmapEXT(GL_TEXTURE_2D); // establish LODs
glFramebufferTexture2DEXT(...); // attach level zero

<render into the FBO>

glBindFramebuffer(0); // bind to the window
glGenerateMipmapEXT(GL_TEXTURE_2D); // gendata for LODs



(the code is related to this: FBO-status-2005)

But how can i read back the first halved mipmap level to the CPU?

And what about Speed? I only need the first mipmap level but there are always generated all Levels.
(also see Thread: "FBO questions")

[Edited by - SteveXP on May 29, 2006 7:58:22 AM]

Share this post


Link to post
Share on other sites
bpoint    464
Quote:
Original post by SteveXP
But how can i read back the first halved mipmap level to the CPU?

Take a look at glGetTexImage. You can specify the desired miplevel with the second parameter.

Quote:
And what about Speed? I only need the first mipmap level but there are always generated all Levels.

OpenGL requires all miplevels if you use mipmapping. Sorry, but I can't help you with any speed estimations as I'm sure all drivers implement their generation methods differently...

Share this post


Link to post
Share on other sites
SteveXP    142
Thx bpoint,
that was exactly what i was looking for!!

Meanwhile, i found, that you can Limit the usuable Mipmap Levels with
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_level); // normally '0'
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_level); // something > base_level

(base_level=0) and (max_level=1) would be sufficient for me, but i can't find any docs, mentioning that it limits also the >generation< of mipmap-levels ... so i don't think it does...?

-> But unfortunately the mipmap Generation from FBO, and download of the first halved texture (1/4th of data), seams to be slower than downloading the fullscale image with glReadPixels(..) and resizeing it on CPU.

Does someone know whether the "glGenerateMipmapEXT(textureType);" performs the MipMap-Generation on the CPU or GPU?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this