Unexplained spritebatch behaviour: flickering and stretched quads

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
syagrius
Prole
Posts: 1
Joined: Mon May 15, 2023 8:57 am

Unexplained spritebatch behaviour: flickering and stretched quads

Post by syagrius »

I have run into an odd issue a couple of times now and each time I made some changes, it apparently went away, only to return again a while later. A spritebatch that I am drawing sometimes shows some quads flickering on the screen, sometimes they are stretched in a long diagonal line from the origin (0,0) to the tile location (almost like the square was starting to be drawn at the top 0,0 but then the x2 and y2 of the square were at the real tile's location). The glitch does not affect all quads, usually only a small number, say 10, 20, 50, even 100. The game usually has between 12,000 and 30,000 sprites (60fps no issues). The issue seems to be most commonly occurring on quads that drawn over other quads (overdraw). There is no sign of a memory leak and at all times when the issue occurs the game is running at 60fps with no other issues.

I cannot reproduce the glitch. I have tried drastically increasing the number of sprites in the batch to try and force the issue to appear - it didn't, only the FPS dropped. I have tried to recreate the exact conditions of the last time the glitch appeared but to no avail. In short, I have attempted to isolate every possible cause from my code and I cannot find anything. However, the glitch reappears every now and again - it is the same behvaiour (of distorted, flickering or flashing quads in spritebatches).

I need help identifying what the source of this issue could be. I do not have knowledge about how openGl works under the hood. I attached a simple love file that shows how the code works in my game with placeholder assets. I work on and test my game nearly every day (for the past 1.5 years) and everything I can think of in the code base that could be causing the issue has been ruled out. Please let me know if you have any ideas about the cause and what I could try to resolve this issue.
Attachments
spritebatch_glitch.love
(10.26 KiB) Downloaded 74 times
Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests