# 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 on other sites
I'm not sure how to do it, but in many 3d apis you can enable auto generation of
mipmaps when creating textures.

##### 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 objectglTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16F_ARB, w, h, RGBA, 0, GL_RGBA, GL_FLOAT, NULL);   // define base levelglGenerateMipmapEXT(GL_TEXTURE_2D);  // establish LODsglFramebufferTexture2DEXT(...);  // attach level zero<render into the FBO>glBindFramebuffer(0);  // bind to the windowglGenerateMipmapEXT(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.

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

##### Share on other sites
bpoint    464
Quote:
 Original post by SteveXPBut 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 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?

## Create an account

Register a new account