Jump to content
  • Advertisement
Sign in to follow this  
bennimon

GLX 16bit float Pbuffer / copyTexSubImage problem

This topic is 5027 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

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
Advertisement
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!