Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tilemap/draw_rect random flickering with Nvidia drivers #9913

Closed
NullNeska opened this issue Jul 27, 2017 · 192 comments
Closed

Tilemap/draw_rect random flickering with Nvidia drivers #9913

NullNeska opened this issue Jul 27, 2017 · 192 comments

Comments

@NullNeska
Copy link

Operating system or device - Godot version:
Windows 10, godot3.0alpha1

Issue description:
I made a kinematicbody2D and a tilemap, moving the kinematic body around worked as normal however occasionally one of the tiles on the tilemap would vanish faster than any screen recording software could capture. sometimes 2 would vanish, they would get redrawn however

Steps to reproduce:
Make a tilemap, load some tiles in, make a kinematic body
move the body around the game, keep your eyes open, dont blink, watch as some tiles vanish from rendering and quickly come back

@mrcdk
Copy link
Contributor

mrcdk commented Sep 3, 2017

Can confirm this is still happening using Godot 3.0 custom build 29db531

It also happens in the editor:

https://i.imgur.com/3dv3fih.png
https://i.imgur.com/KTAyyqm.png

It should be all grass.

EDIT: It looks like if the Quadrant Size is set to 1 the problem disappears

EDIT 2: The tiles don't disappear but get moved (a transform problem?)

https://i.imgur.com/T0GBaFv.png

EDIT 3: A low quality video. https://streamable.com/6a07b Took me a while to trigger the problem (the editor is set to update always)

@mrcdk
Copy link
Contributor

mrcdk commented Sep 25, 2017

This issue is still happening in latest master 1f46853

It seems the problem isn't a tilemap only related one. I found the same issues with a big text inside a label. I have the feeling it only happens after using the percent_visible and or moving the label. This time I could only notice it while the game was running but I wouldn't discard the same happening in the editor. I've not been able to take a picture or video of it but some characters start to flicker and move to other position with a different transformation (you can see a chunk of letters from the font texture)

@mrcdk
Copy link
Contributor

mrcdk commented Sep 26, 2017

Update: This issue is a core issue. It's also happening to the Editor itself. I couldn't take a screenshot because by the time I notice it and want to take a screenshot the editor has probably updated and the problem goes away. I noticed the problem in two sections of the editor, it's not that it happens in these two sections but the sections I've noticed the problem: In the Output content some letters flickered and one of the tab labels at the bottom of the screen where the Output, Debugger, Audio,... labels are. The D from the Debugger label started to flicker. It's not easy to trigger but it's the same problem.

@mrcdk
Copy link
Contributor

mrcdk commented Sep 26, 2017

I've got the label problem on video (flickering starts about half the video) https://streamable.com/e31xp look closely towards the end of the 4th line and you will see some letters flickering

Sorry, I don't think editing will send notifications and I think this is an important issue

@Remixful
Copy link

Remixful commented Dec 9, 2017

https://i.gyazo.com/1ccc584f1746d0fc342f6de6609d33f0.mp4

I am having the same issue... (around 0:04 you see a tile flicker)
I'm just using a Sprite and my own movement script though

@jonbonazza
Copy link
Contributor

jonbonazza commented Dec 31, 2017

After much testing, I am confident that my issue (#15113) is the same as this one. What's odd is a couple things:

  1. I was originally seeing the exact same issue that @Remixful was seeing with entire squares flickering, but then that went away without changing anything, and instead, I was seeing these weird flickering lines. Then those went away out of nowhere and the original flickering squares returned... O.o
  2. If I just let the scene idle, I don't see any weird artifacts or flickering, but once I start moving my character around (or maybe it's from the camera moving around?) that's when I start to see flickering in some form.
  3. I am able to easily capture the full square flickering on video, but when I try to record the line flickering, despite it definitely occurring during filming, the flickering is nowhere to be found on the video.

@jonbonazza
Copy link
Contributor

Also, FWIW, this did not occur at all in 2.1 with the exact same project.

@akien-mga
Copy link
Member

Would be nice to have an example project that reproduces the issue (I know it should be easy to make based on the given steps to reproduce, but engine dev time is a scarce resource :)).

@jonbonazza
Copy link
Contributor

jonbonazza commented Jan 9, 2018

@akien-mga
flickertest.zip

You may need to run the project a few times before seeing it, but once it's started, just let it sit and you should eventually see it.

@jonbonazza
Copy link
Contributor

I tried multiple things to see if it happened in different scenarios. I could only reproduce it when a Camera2D was a child of a YSort. That might be a clue.

@reduz
Copy link
Member

reduz commented Jan 16, 2018

I've seen this yesterday in the kinematic_char demo :\

@mrcdk
Copy link
Contributor

mrcdk commented Jan 16, 2018

What I've found about this problem is that:

  • It's hard to reproduce and capture in video. Sometimes you'll be seeing it all the time and when trying to record it with OBS or any screen recording software the problem won't happen. Then again, sometimes it will do happen even while recording so I don't know 😅
  • It can happen at any time and anywhere (even in the editor itself, not only in the scene being edited)
  • Seems to only happen with TileMaps with a cell quadrant size > 1 and, sometimes, text. I'm not saying it doesn't happen with other stuff but I've only seen it happen when using those two things.
  • And I can't see anything wrong with the code. Granted I'm not an expert on it or anything. The only thing I can think of is some transform not being set correctly at random... dunno really 😓

@akien-mga akien-mga modified the milestones: 3.0, 3.1 Jan 24, 2018
@akien-mga
Copy link
Member

See #16277 for another example project that should reproduce the issue.

@cadamsdev
Copy link

cadamsdev commented Feb 1, 2018

See 16280 for another issue regarding this.

@Archeia
Copy link

Archeia commented Feb 4, 2018

Hello, to add to this and just to clarify, I haven't done anything at all with Godot and I just tried out this project specifically since I was curious:
image

The flickering happens on a test play but not on the editor. Interestingly, the opposite happens if I try 2D Kinematic Character Demo where the editor tiles flicker but not in test play.

@jonbonazza
Copy link
Contributor

jonbonazza commented Feb 4, 2018 via email

@Archeia
Copy link

Archeia commented Feb 5, 2018

@jonbonazza I used the latest stable godot3 and it still happens. My image shows it on upper right corner too T_T)

It seems this bug happens on Nvidia graphic cards that are above GTX 970M?

@Remixful
Copy link

Remixful commented Feb 6, 2018

GeForce GTX 970 here.

@issork
Copy link
Contributor

issork commented Feb 11, 2018

Here are some of my findings and a simple project to reproduce this issue. (a tilemap with 2 different sprites, the godot icon and the godot icon with inverted colors, with labels above the tilemap, scene that was converted to tileset is included)

Flicker.zip

  • also happening to labels in this scene, single characters move randomly (even rotate), just like the tilemaps tiles
  • if you are inside the editor and move your mouse around on the grid while having a tile selected, you can sometimes see this issue in a frozen state until moving your mouse to a different grid section
  • the order of nodes in the scene tree changes the frequency of this (if the tilemap is the last node, it happens more frequently to the tilemap and if the tilemap is the first node, it happens more frequently to the labels)

Edit: Heres a screenshot of the issue. You can see 2 E's of the first line weirdly stretched across one tile section of the tilemap. (red)

bug

The labels stop flickering once the tilemap is removed from the scene.

I hope this is going to help resolving this issue.

@ibrahn
Copy link
Contributor

ibrahn commented Feb 13, 2018

45ab9cd
exported (release) on Linux to windows (32 and 64 bit)
Flickers on Win 10 with Nvidia GTX 750 Ti (don't have access to this machine to debug)

Could not reproduce on Nvidia GTX 760 with Debian or Win7.

@vinterskog
Copy link

Flickering is present with a GTX 1060 on Win7 for me. I really hope this gets fixed very soon because as it is now, TileMap is simply not usable for production. :(

@paulhocker
Copy link

I think a fix would be needed if there were hundreds of people reporting this problem. I don't think we have that. At least this thread is not suggesting it.

That said, if there are some commercial releases that are suffering from this it might be good to help them out. If I had more experience I would dive in myself, but I would not know where to begin. I have just started exploring the Godot code, which is very well written by the way.

This is where it would be nice to have a voting system for crucial bugs that need to be fixed.

My vote is to wait for 4.x, and have resources focused on that. We know Vulkan already solves this problem.

@Calinou
Copy link
Member

Calinou commented Apr 25, 2020

This is where it would be nice to have a voting system for crucial bugs that need to be fixed.

In my experience, voting is generally not conductive to getting bugs fixed faster. This is true in community-developed projects, but even commercial proprietary software faces the same issue (look at Discord's feature tracker).

@paulhocker
Copy link

True. I am not suggesting it would help get it fixed. It would be more of a gauge on how wide spread the problem is. I suppose the number of people involved in this discussion could be a gauge. At any rate, I am pretty much done with this thread, and will patiently wait for 4.x

@RamiAwar
Copy link

I'm also facing the issue. I never faced it when autotiling normally. If I drew the map by hand ( which I did in another project, using the same tilemaps ) I never came across this issue. But when I came to render a procedurally generated dungeon using tilemap.set_cellv( ... ) I encountered the issue consistently. I all suggestions, and the only one that worked was using GLES2 with the workaround. This is a pretty serious issue though! Most basic tilemap rendering is failing. Why isn't there a workaround for GLES3 btw? I know some OpenGL, I've written a basic game engine that renders textures with shaders but nothing more. Can someone explain what's causing this exactly? Hopefully I can understand. <3

@gcardozo123
Copy link
Contributor

I'm also facing the issue. I never faced it when autotiling normally. If I drew the map by hand ( which I did in another project, using the same tilemaps ) I never came across this issue. But when I came to render a procedurally generated dungeon using tilemap.set_cellv( ... ) I encountered the issue consistently. I all suggestions, and the only one that worked was using GLES2 with the workaround. This is a pretty serious issue though! Most basic tilemap rendering is failing. Why isn't there a workaround for GLES3 btw? I know some OpenGL, I've written a basic game engine that renders textures with shaders but nothing more. Can someone explain what's causing this exactly? Hopefully I can understand. <3

There are already some explanations on this thread. I suppose that at this point there won't be new workarounds or fixes for this issue until the 4.0 (vulkan) release, unless the community comes up with something. IMHO the maintainers are correct in not worrying with a potentially complex fix now that 4.0 is on the horizon.

@lawnjelly
Copy link
Member

Why isn't there a workaround for GLES3 btw?

I hadn't actually noticed that, I might have a go at porting the workaround code to GLES3 tomorrow. It will be slow though if we can get it working.

@lawnjelly
Copy link
Member

I've now got a WIP PR (see above) for the workaround for GLES3. I've also got some ideas for fixing the uniform drawing method, as the shader seems overcomplicated for what is needed. I might need some help testing that if I do a fix, as I can't repeat the flickering on my machine.

@paulhocker
Copy link

I think I can help with that. I should be able to do a custom Windows build on your PR.

@lawnjelly
Copy link
Member

I'm now working on rewriting the fast path shader to prevent flicker. I now have a prototype available for trying in #38628. I would greatly appreciate if someone could try it out who has hardware that exhibits flicker, instructions are in the PR.

@lawnjelly
Copy link
Member

Well update:

  • it seems the GLES3 workaround works fine 🥳 (it should be in the next beta),
  • however the experiments with the fast path shader didn't help 😞 , and after that testing it seems the shader can probably be ruled out as the cause.

So currently I'm thinking in terms of it being some weird situation in terms of binding failing on our side only on nvidia, or a driver bug (maybe not envisaging this method of drawing perhaps, or not testing it?).

Anyway the good news is that

  • with GLES2 with batching, you shouldn't even feel the need to use the fallback method in 99% of games, thus you won't get flicker
  • And with GLES3, the nvidia fallback is confirmed to work to prevent flicker, albeit at a performance cost.

At this stage, I think my time would be more productively spent getting some batching working in GLES3, which would make the performance difference moot. 👍

@mrcdk
Copy link
Contributor

mrcdk commented May 11, 2020

@lawnjelly It's is a driver bug and how it deals with power managment. In this comment you can find my findings.

@lawnjelly
Copy link
Member

@lawnjelly It's is a driver bug and how it deals with power managment. In this comment you can find my findings.

Ahha! 😁

One of the problems is this thread has become so long now! Actually API trace is a very good way of determining this if you get the flicker on your hardware, and I'm in agreement if you get different results each time you replay the trace that does point to a driver bug. 👍

@Shfty
Copy link

Shfty commented Jun 20, 2020

@securas Did you ever confirm that the issue in the video you posted was being caused by this flicker bug?

I'm seeing similar single frames of black background + horizontal white lines in my own project with both the built-in camera drag feature and a custom camera script, and none of the mentioned workarounds (GLES2, NVIDIA flicker fix, disable HDR, various different kinds of viewport allocation) prevent it from happening:

tile-glitch

This is on 3.2.1 stable, Windows 10, GTX 1080.

The scene has four 1400x800 tilemaps stacked on top of eachother for the black far background, zigzag near background, foreground and camera collision.

I'd be much obliged if anyone can offer some insight - writing a robust workaround is going to be a considerable chunk of project time that I'd rather not commit to if it can be avoided.

@securas
Copy link

securas commented Jun 20, 2020

If I remember correctly, it was due to 2d pixel snapping set to off.

@lawnjelly
Copy link
Member

@Shfty That actually looks like it may be a different issue. That would seem to be confirmed if the nvidia workarounds don't fix it. Would you be able to open a new issue, with hardware details and a min reproduction project?

@Shfty
Copy link

Shfty commented Jun 21, 2020

@lawnjelly That sounds about right. I've opened #39720 with a minimal reproduction project based on the scene in the above gif.

I managed to fix the issue by nesting the affected scene inside its own Viewport node, so have included an example setup for that inside the project as well.

@RobertBColton
Copy link
Contributor

That gif looks to me like vertical synchronization/screen tearing in a way.

@akien-mga akien-mga modified the milestones: 4.0, 3.3 Apr 8, 2021
@akien-mga
Copy link
Member

So, things have been improved significantly with the upcoming Godot 3.3, so this can likely be closed as fixed. Godot 4.0 will likely not suffer from this issue as it's OpenGL specific and so far the 4.0 branch uses only Vulkan (if some form of this issue comes up again after OpenGL 3.3 support is re-implemented, it will likely be best to track it in a dedicated issue anyway as the code will be quite different).

In 3.3, there is now batching enabled by default for GLES2 and GLES3, which fixes this issue.

The issue can still happen with some non-default configuration:

  • Using batching with single_rect_fallback enabled. This is a debug option which will likely be phased out.
  • Disabling batching (goes back to the legacy rendering method which had this issue). You can then mitigate the issue with the rendering/2d/options/use_nvidia_rect_flicker_workaround option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests