PDA

View Full Version : Larges FBOs



BlaX
01-20-2007, 04:28 AM
Hi,

I have quite the same problem than HanWu several days ago: I need to make a "printable" version of my scene, with a resolution around 300dpi, which means that I need a large view (3444x2400 for instance). That is quite larger than my window, I need an offscreen rendering solution => I use a FBO.

The glTexImage does not produce any error (GL_MAX_TEXTURE returns 4096, so it is ok) but the glCheckFramebufferStatusEXT does not return GL_FRAMEBUFFER_COMPLETE_EXT at the end.

If the resolution is lower, the FBO has no problem.

Do you know this problem and is there another solution than tiling?

jide
01-20-2007, 04:35 AM
I don't really remember, check the specs on this site for more information. Did you also checked GL_MAX_RENDERBUFFER_SIZE_EXT ?

BlaX
01-20-2007, 06:37 AM
glGetIntegerv with GL_MAX_RENDERBUFFER_SIZE_EXT returns 4096.
Moreover, the glRenderbufferStorageEXT returns no GL error.
This is my source code (m_gl_target can be GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE):

void GLWidget::update_tex (void)
{
if (!m_fbo_init)
{
int value;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
qDebug("GL_MAX_TEXTURE_SIZE = %d", value); // GL_MAX_TEXTURE_SIZE = 4096
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &value);
qDebug("GL_MAX_RENDERBUFFER_SIZE_EXT = %d", value); // GL_MAX_RENDERBUFFER_SIZE_EXT = 4096

// Creating objects
glGenTextures (1, &m_fbo_color_buffer);
glGenRenderbuffersEXT (1, &m_fbo_depth_buffer);
glGenFramebuffersEXT (1, &m_fbo_frame_buffer);
}

// Binding objects
glBindTexture (m_gl_target, m_fbo_color_buffer);
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, m_fbo_depth_buffer);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, m_fbo_frame_buffer);

if (!m_fbo_init)
{
// +------------------------------------+
// | |
// | There is the problem: |
// | 1024x1024 is ok |
// | 2048x2048 fails on the next assert |
// | |
// +------------------------------------+
m_fbo_wtex=2048;
m_fbo_htex=2048;

// Initialization of the texture
glTexParameteri (m_gl_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (m_gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (m_gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (m_gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D (m_gl_target, 0, GL_RGBA, m_fbo_wtex, m_fbo_htex, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );

// Initialize the Depth Render Buffer
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, m_fbo_wtex, m_fbo_htex);

// Attach texture to FrameBuffer
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, m_gl_target, m_fbo_color_buffer, 0);

// Attach the Render Buffer to the Frame Buffer
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_fbo_depth_buffer);

// Checking the status
// +------------------------+
// | this is where it fails |
// +------------------------+
assert (GL_FRAMEBUFFER_COMPLETE_EXT==glCheckFramebufferSt atusEXT (GL_FRAMEBUFFER_EXT));

m_fbo_init=true;
}

// Drawing
// ...

// Unbinding
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, 0);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
glBindTexture (m_gl_target, 0);
}

jide
01-20-2007, 07:57 AM
So you say it works well with a resolution of 1024 but not 2048. It looks strange. Try to see what is the real error returned by CheckFramebufferStatus. It might help. Also try to check if the renderbuffer is really a renderbuffer (glIsRenderBufferEXT).

I don't see any bad things in your code.

What is your graphic card ? What driver ?

k_szczech
01-20-2007, 02:27 PM
I'm using 2048x1024 on GeForce 6, GeForce 7 and Radeon X. Works fine with RGBA8 and RGB16F (on GeForce).

Try placing
glBindTexture (m_gl_target, 0);
just after
glTexImage2D(...);

This is from specs:

Special precautions need to be taken to avoid attaching a texture image to the currently bound framebuffer while the texture object is currently bound and enabled for texturing.It's obvious that you can't use a texture in rendering if it's current render target. But it should be ok during framebuffer creation. Perhaps driver gets confused.

BlaX
01-21-2007, 02:37 PM
@jide:
IsRenderbuffer returns GL_TRUE.
CheckFramebufferStatus returns FRAMEBUFFER_UNSUPPORTED_EXT
I made a lot of glGetError and it always returns GL_NO_ERROR.
I have a NV QuadroFX 540 with 9629 drivers (under linux).

@k_szczech:
With 2048x1024 it works fine. I tried many resolutions to find the limit. I obtained the following: 2048x1635 always works, 2048x1636 always fails.
Unbinding the texture didn't change anything.

jide
01-22-2007, 06:07 AM
To my point of view you whether are under the limits of your graphic card or whether you are under a 'bug' in the driver.

Read the nvidia readme file providen with the driver. It might help. AFAIK there had issues with such cards.

I have a geforce fx with 8774 drivers under linux and this works well.

So maybe you can try to report it to nvidia directly.

thinks
02-26-2008, 10:37 AM
I can confirm similar behaviour, i.e. limited resolutions before FRAMEBUFFER_UNSUPPORTED_EXT, on nVidia Quadro FX 550, ForceWare 162.65, Win XP.

Quite annoying...