How to use texelFetch()?

Hi,

I would like to create a texture buffer object containing a series of vec4 values.

In GLSL, should things be declared the following way?

// Fragment shader

#version 150 compatibility
#extension GL_EXT_gpu_shader4 : enable

uniform sampler1D tex;

void main(void)
{
vec4 myValue = texelFetch(tex, 0);
[…]
}

When trying to compile this shader, I get the following error:

error C1115: unable to find compatible overloaded function “texelFetch(sampler2D, int)”

I am confused as to which function I should use: texelFetch, texelFetch1D, texelFetchBuffer?
The data I am dealing with is 1-dimensional.

I’m using a Fermi card with the latest drivers.

Regards,
Fred

Oops, I forgot the last argument… texelFetch(sampler1D, int, int).

Surprisingly, I am still getting a compilation error on AMD/ATI hardware, either texelFetch is not recognized, or it is another mistake of mine.

A buffer texture is not a GL_TEXTURE_1D texture. It is a buffer texture. It has its own special texture type (GL_TEXTURE_BUFFER), so it also has its own sampler type (samplerBuffer).

He was actually talking about the textlFetch() function, not texelFetchBuffer()

He was actually talking about the textlFetch() function, not texelFetchBuffer()

No such thing. OK, there is if you use EXT_gpu_shader4, but why would you want to do that?

In version 1.50 (and 1.40. And 1.30. Basically, the last two+ years), the texture functions no longer redundantly state what sampler they use. There is no “texelFetchBuffer” in core GLSL 1.50. There is only “texelFetch” which can take just about any sampler type.

This was the bit that I was basically missing, that older GLSL with the proper extension enabled the use of texelFetchXXXX() while more recent versions only accept texelFetch().
Not in front of my development computer right now but I believe nvidia drivers still tolerate texelFetchXXXX function names while AMD drivers do not.

As this way the first time I was looking at this, this confused me. AMD’s GLSL compiler has had and still has very serious bugs, so I sometimes question its behavior even when it is correct (and I know it sometimes sticks to the specs more than the nvidia compiler).

Not in front of my development computer right now but I believe nvidia drivers still tolerate texelFetchXXXX function names while AMD drivers do not.

Both of them do when you explicitly enable the extensions that define them. And neither of them should when you don’t enable those extensions.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.