Hi,
I am using Glew 1.7.0, GLSL 120 and FBO with floating point textures to do general purpose GPU computing. My algorithm works perfectly on NVidia hardware (GeForce GT220) but it will not on AMD (ATI Radeon HD 5800).
I did make sure GL_ARB_texture_float is supported. All Glew functions got an address. I tried many floating point texture formats Luminance / RGBA 32 or 16 floats or half floats. They will all clamp to 1.0 on the AMD hardware.
I called these lines to have it working but it didn’t :
glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);
glClampColorARB(GL_CLAMP_READ_COLOR_ARB, GL_FALSE);
glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FALSE);
I create my texture this way :
glGenTextures(1, &m_gluintTextureID);
glBindTexture(GL_TEXTURE_2D, m_gluintTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE32F_ARB, m_uiTextureSizeWidth, m_uiTextureSizeHeight, 0, GL_LUMINANCE, GL_FLOAT, NULL );
Then I will create and link to the framebuffer :
glGenFramebuffersEXT(1, &m_uiFramebufferID);
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_uiFramebufferID );
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pTexture->getID(), 0);
Then I check the status which is successful ( GL_FRAMEBUFFER_COMPLETE_EXT ) :
GLenum statusEXT = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
Meanwhile I unbind the FBO :
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
When it comes to drawing I do this :
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_uiFramebufferID );
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pTexture->getID(), 0);
// Bind the GLSL shader calling cwc::glShader::begin
// Activate source texture and draw a fullscreen quad
// Unbind everything such as cwc::glShader::end and
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
A GLSL fragment shader program used to test the floating point texture could look like this ( I use gl_FragData instead of gl_FragColor because I often have many color attachments ) :
// FRAGMENT SHADER
#version 120
void main (void)
{
gl_FragData[0] = vec4(1.5, 0.0, 0.0, 0.0);
}
Then I will read the result (before unbinding the FBO) :
GLfloat* pkfDebug = new GLfloat[iColSize * iRowSize];
glReadBuffer( GL_COLOR_ATTACHMENT0_EXT );
glReadPixels(0, 0, iRowSize, iColSize, GL_LUMINANCE, GL_FLOAT, pkfDebug);
And see that on NVidia I get 1.5 and on AMD I get 1.0.
I use the latest Catalyst drivers : 11.10 for Windows 7 64 bits. If you can give me hints of what to do to have the floating point textures not to clamp, I would be very happy.
Thanks
Laurent