1

I'm writing an application that uses a GLSL fragment shader to do some color conversion to RGB. This application uses GL_TEXTURE_RECTANGLE_ARB because I need to support NPOT textures.

The problem happens when a 1280x720 image is rendered to a smaller surface, say 640x480.

Apparently, my ATI Technologies Inc RV610 video device [Radeon HD 2400 PRO] has problems performing minification filtering with GL_LINEAR:

glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

The red rectangle in the image below shows the exact location of the problem. Green-ish lines (4 or 5 pixels of height) are being rendered at the top of the video (black borders around the image are not part of the rendering, ok?!). Depending on the image being rendered, the color of lines change as well:

enter image description here

With zoom:

enter image description here

The problem doesn't happens with:

glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

I've tested this application on another PC with an Intel card, and it also happens with an Intel Corporation 4 Series Chipset Integrated Graphics Controller (rev 03), regardless of the filtering mode being set. Coincidence?

Am I forgetting to do something in the code, could this be a driver issue? I have several machines with the same Intel card and the problem occurs in all of them. It's important to state that this issue doesn't happen on a NVIDIA GeForce 7300.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • I also tried setting `GL_TEXTURE_WRAP_S` and `GL_TEXTURE_WRAP_T` to different modes, like `GL_CLAMP`, `GL_CLAMP_TO_BORDER`, and `GL_CLAMP_TO_EDGE` and it doesn't make a difference. – karlphillip Feb 03 '12 at 13:01
  • I have a suspicion what could be going on. But having some source code, both client side drawing commands and server side GLSL would help. – datenwolf Feb 03 '12 at 13:21
  • [The entire source code is available in this question](http://stackoverflow.com/questions/9011108/image-scaling-keepaspectratiobyexpanding-through-opengl). The only thing that needs to change on that code is the call to set `GL_TEXTURE_MIN_FILTER` as `GL_LINEAR`. – karlphillip Feb 03 '12 at 13:27
  • We could also go to a chat session and I could follow your instructions to perform the tests if it's easier for you. – karlphillip Feb 03 '12 at 13:35

1 Answers1

2

Looking at the sourcecode I see the following in the shader:

     float CbY = ImgHeight + floor(t.y / 4.0);
     float CrY = ImgHeight + chromaHeight_Half + floor(t.y / 4.0);

I have no idea, why you add ImgHeight to the texture coordinates, because all it'd do was wrap around if that's the texture height. Then you're packing the different color components into a single texture. So you must take extra care to correctly calculate offsets. That one pixel high line colored off is a indication, that your texture coordinates are wrong. GL_NEAREST coerces to integers, but with GL_LINEAR they must match. I suggest replacing floor with round.

datenwolf
  • 159,371
  • 13
  • 185
  • 298