Hello Guest

Flickering visual artifacts on some machines

  • 8 Replies
  • 940 Views
*

Offline Danjb

  • *
  • 18
Flickering visual artifacts on some machines
« on: January 22, 2020, 08:08:01 »
Hi,

I see some strange flickering visual artifacts on some machines, regardless of the resolution / fullscreen / vsync settings.

Is this likely due to the graphics driver not supporting vsync, or could it be that my rendering code is running too slowly to keep up with the refresh rate, and needs optimising?

Is there a way around this problem for graphics drivers that do not support vsync?

Thanks,
Dan

Re: Flickering visual artifacts on some machines
« Reply #1 on: February 26, 2020, 07:47:54 »
Could you post some kind of screenshots / examples of what you're talking about?

It could be anything, really. Z-fighting, for example. Without seeing it, I can''t even tell what you're talking about.

Re: Flickering visual artifacts on some machines
« Reply #2 on: February 27, 2020, 03:31:00 »
hmm.. It looks as if the previous frame is not cleared. Or that there's some garbage data remaining in your GPU.
Do you call glClear() before rendering?

I assume you're rendering text by picking letters from a texture. when you call those renders, are you sure you aren't occasionally sending some garbage to the GPU?

*

Offline Danjb

  • *
  • 18
Re: Flickering visual artifacts on some machines
« Reply #3 on: February 27, 2020, 19:00:24 »
I agree, that's what it looks like, but I can't figure out why. I always call glClear(GL_COLOR_BUFFER_BIT) at the start of each frame. And as far as I can tell, my rendering code is deterministic, so I don't see how it could produce such sporadic flickering - and only on certain systems.

The only thing that makes sense to me is if it's related to vsync, i.e. it's trying to render before it's ready, so there is some garbage in the buffers. But then, other people don't seem to have this problem, which makes me wonder if my rendering is too slow.

Screenshots for reference (for some reason I wasn't able to post before):
https://www.dropbox.com/s/4yottixach32e93/java%202020-02-26%2008-02-48-540.jpg?dl=0
https://www.dropbox.com/s/smqaiqpqo7shhrx/java%202020-02-26%2008-05-31-865.jpg?dl=0
https://www.dropbox.com/s/dhvf1gkbi82n7rr/java%202020-02-26%2008-05-32-432.jpg?dl=0
https://www.dropbox.com/s/939p0d0rg4ff9ju/java%202020-02-26%2008-05-33-229.jpg?dl=0

You're right about the text - I populate a vertex array with all the characters and their shadows, taken from a font texture, and render it to the screen using glDrawArrays().

Re: Flickering visual artifacts on some machines
« Reply #4 on: February 28, 2020, 03:40:51 »
Quote
The only thing that makes sense to me is if it's related to vsync, i.e. it's trying to render before it's ready
I don't think that's it. Generally speaking, vsync or not should make no reason. Also rendering process goes in lines (or rather doubles of lines) AFAIK. So if your artifacts appear - the rest of the lines they appear in should be equally screwed, which is not the case.

To me it looks as if some data isn't cleared from the array before it's sent to the videocard to render. Notice how your artifacts are triangular, i.e. it's acutally some polygon/triangle is being rendered with a texture of a symbol or a letter. As if when you prepare your data before render call, it accidentally slips in. I would review this part of your code if I were you.

Unfortunately, without seeing the code I won't be able to help you further, I don't think I can help you any further.

*

Offline Danjb

  • *
  • 18
Re: Flickering visual artifacts on some machines
« Reply #5 on: February 28, 2020, 10:01:41 »
Ok, I will investigate further. That's helpful if only just to rule out it being a vsync issue.

Thanks,
Dan

Re: Flickering visual artifacts on some machines
« Reply #6 on: February 28, 2020, 10:47:29 »
To be fair, you can't actually rule out anything. It's just that what vsync does is it basically waits for the entire frame buffer to be completely filled before it swaps. Artifacts, especially triangular-shaped, means something has gone wrong during rendering itself, not the buffer swap.

That's how I understand it. The thing is - I don't claim to be OpenGL expert, I'm still very much new to it myself.

Try also looking into how you're handling creation / update / destruction of VBO's. Because that's what's basically is getting rendered, I think - some triangle with a texture in a VBO where it souldn't be.

Perhaps another VBO stays active while you add in a new one when you change text, and it somehow gets bound and rendered? I'm shooting blindly here, but perhaps it gives ideas.

*

Offline Danjb

  • *
  • 18
Re: Flickering visual artifacts on some machines
« Reply #7 on: February 29, 2020, 08:38:51 »
To be fair, you can't actually rule out anything. It's just that what vsync does is it basically waits for the entire frame buffer to be completely filled before it swaps. Artifacts, especially triangular-shaped, means something has gone wrong during rendering itself, not the buffer swap.

That's how I understand it. The thing is - I don't claim to be OpenGL expert, I'm still very much new to it myself.

Try also looking into how you're handling creation / update / destruction of VBO's. Because that's what's basically is getting rendered, I think - some triangle with a texture in a VBO where it souldn't be.

Perhaps another VBO stays active while you add in a new one when you change text, and it somehow gets bound and rendered? I'm shooting blindly here, but perhaps it gives ideas.

I have just found a definite bug in my text renderer:

When determining the number of vertices in the array, I count the number of characters in the string, including spaces. However, when building the vertex array, I don't actually add any vertices for spaces, as there is nothing to render.

Thank you so much for pointing me in the right direction. I haven't tested on one of the affected systems yet, but I'm fairly confident this will fix the problem. I'll actually be very glad if this was just programmer error and not something more complicated!

Re: Flickering visual artifacts on some machines
« Reply #8 on: March 02, 2020, 04:15:23 »
I mean it should be. And because you basically tell GPU that there're more vertices that there actually is, it can pick up some garbage from previous render calls and try to render it. Sometimes, it may hold an actual symbol.

it's really hard to imagine that rendering of odd textured triangles is something deeper than a coding error.

No problem, I hope you get it fixed.