Sign in to follow this  
bennimon

GLX 16bit float Pbuffer / copyTexSubImage problem

Recommended Posts

Hi everyone, i'm trying to do float precision blending on a 6800, and i'm experiencing a problem i cannot understand. What i'm doing is a) render to a and blending in a 16-bit pbuffer b) copy the final image to a texture c) render a screen sized quad with that texture applied Everything works fine, the resulting image seems to be completely correct, only the speed breaks down. From 400 to 0.5 FPS... The thing that's giving me headaches is that if i use glReadPixels instead of glCopyTexSubImage2d, it's actually FASTER. If i leave out step (b), speed drops a little compared to standard 8bit framebuffer blending, but that's just what i would expect when using float precision blending. I suspected that somehow a necessary format conversion during copying was part of the problem, but ist that still possible when readPixels works at it's expected speed? All help will be very appreciated ;) Here's my code: Texture setup: glGenTextures(1, &color_tex); glBindTexture(GL_TEXTURE_RECTANGLE_NV, color_tex); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP); glCopyTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA16_NV, 0, 0, vp_size[0], vp_size[1], 0); Copy from PBuffer to texture: glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, vp_size[0], vp_size[1]); Faster (?) alternative: GLfloat u[]; glReadPixels(0,0,vp_size[0],vp_size[1],GL_RGBA,GL_FLOAT,&u[0]); glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA16_NV, vp_size[0], vp_size[1], 0, GL_RGBA, GL_FLOAT, &u[0]); PBuffer setup (is called with viewport size and 16 bit precision): PBuffer::PBuffer(int _w, int _h, int _bits) { sbAttrib_.clear(); sbAttrib_.push_back(GLX_DOUBLEBUFFER); sbAttrib_.push_back(true); sbAttrib_.push_back(GLX_RED_SIZE); sbAttrib_.push_back(_bits); sbAttrib_.push_back(GLX_GREEN_SIZE); sbAttrib_.push_back(_bits); sbAttrib_.push_back(GLX_BLUE_SIZE); sbAttrib_.push_back(_bits); sbAttrib_.push_back(GLX_ALPHA_SIZE); sbAttrib_.push_back(_bits); sbAttrib_.push_back(GLX_DEPTH_SIZE); sbAttrib_.push_back(24); sbAttrib_.push_back(GLX_RENDER_TYPE); sbAttrib_.push_back(GLX_RGBA_BIT); sbAttrib_.push_back(GLX_DRAWABLE_TYPE); sbAttrib_.push_back(GLX_PBUFFER_BIT); sbAttrib_.push_back(GLX_FLOAT_COMPONENTS_NV); sbAttrib_.push_back(true); sbAttrib_.push_back(None); pbAttrib_.clear(); pbAttrib_.push_back(GLX_PBUFFER_WIDTH); pbAttrib_.push_back(_w); pbAttrib_.push_back(GLX_PBUFFER_HEIGHT); pbAttrib_.push_back(_h); pbAttrib_.push_back(GLX_PRESERVED_CONTENTS); pbAttrib_.push_back(true); pbAttrib_.push_back(None); // Create the pbuffer dpy_ = glXGetCurrentDisplay(); currctx_ = glXGetCurrentContext(); currdraw_ = glXGetCurrentDrawable(); fbc_ = glXChooseFBConfig(dpy_, DefaultScreen(dpy_), &sbAttrib_[0], &n); if (!fbc_) { std::cerr << "glXChooseFBConfig failed.\n"; } pbuf_ = glXCreatePbuffer(dpy_, fbc_[0], &pbAttrib_[0]); if (!pbuf_) { std::cerr << "glXCreatePbuffer failed.\n"; } pbufctx_ = glXCreateNewContext(dpy_, fbc_[0], GLX_RGBA_TYPE, currctx_, true); if (!pbufctx_) { std::cerr << "glXCreateNewContextWithConfigSGIX failed.\n"; } std::cout << "Pbuffer created.\n";

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