Support for opengl render buffers?

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
Gucci
Gnoblar
Posts: 6
Joined: Mon Nov 24, 2014 7:07 pm

Support for opengl render buffers?

Post by Gucci »

Hi everyone,

Does anyone know if Ogre supports using render buffers as attachments to FBO's instead of textures?

I've been trying to get opencl to work with Ogre rendering to texture for about a week now, and I can make it work with render to texture via PBuffers but there seems to be some kind of incompatibility with FBO textures. I've probed the source code quite a bit in the debugger to find out if it was some kind of mistake on my side but couldn't come up with anything. The Render to texture works fine with FBOs inside ogre (say if I render that texture on a rectangle), but the resulting texture I get in opencl is wrong.

Funnily enough I tried blitting the resulting texture (rtt with FBO) to another "normal" texture (e.g TU_DYNAMIC), and that works fine. However, the blitting is super slow as it goes through the CPU. Looking into the source code I saw this in the blit implementation:

Code: Select all

void GLTextureBuffer::blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox)
{
    GLTextureBuffer *srct = static_cast<GLTextureBuffer *>(src.getPointer());
    /// Check for FBO support first
    /// Destination texture must be 1D, 2D, 3D, or Cube
    /// Source texture must be 1D, 2D or 3D
	
	// This does not seem to work for RTTs after the first update
	// I have no idea why! For the moment, disable 
    if(GLEW_EXT_framebuffer_object && (src->getUsage() & TU_RENDERTARGET) == 0 &&
        (srct->mTarget==GL_TEXTURE_1D||srct->mTarget==GL_TEXTURE_2D
         ||srct->mTarget==GL_TEXTURE_3D)&&mTarget!=GL_TEXTURE_2D_ARRAY_EXT)
    {
        blitFromTexture(srct, srcBox, dstBox);
    }
    else
    {
        GLHardwarePixelBuffer::blit(src, srcBox, dstBox);
    }
}
And this is still present in the latest version of Ogre!! (2.0 branch pulled 12th Dec 2014). And if I manually force the call to blitFromTexture I get an unusable texture in opencl. This is why I want to try a render buffer attachment with FBO. Else I will just have to stick with old PBuffers :(

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4211
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 802
Contact:

Re: Support for opengl render buffers?

Post by dark_sylinc »

To the best of my knowledge, no.

There is a GL3PlusRenderBuffer/GLRenderBuffer class; but it's written mainly to deal with depth and stencil buffers.

Gucci
Gnoblar
Posts: 6
Joined: Mon Nov 24, 2014 7:07 pm

Re: Support for opengl render buffers?

Post by Gucci »

Thanks for the answer. I haven't updated this thread in a while so here's a quick response for anyone encountering the same problem. In the end I could not find a workaround in Linux (my main dev platform), however I tried the same code in Windows 8.1 with OpenGL and the FBO's there seem to be compatible with OpenCL. Not sure where the issue is, but I would guess it is driver related.

Post Reply