Bug 109212 - DiRT Rally elements blinking constantly
Summary: DiRT Rally elements blinking constantly
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Intel 3D Bugs Mailing List
QA Contact: Intel 3D Bugs Mailing List
Depends on:
Reported: 2019-01-02 21:38 UTC by leozinho29_eu
Modified: 2019-09-25 20:29 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Videos showing the difference between the good and the bad (26.53 MB, application/x-tar)
2019-01-07 23:53 UTC, leozinho29_eu

Description leozinho29_eu 2019-01-02 21:38:03 UTC
In the game DiRT Rally, it's observed that certain elements blink frequently. The most common are the trees, but even the pilot and car can blink on rare cases. This was observed with severity on Mesa Git and Mesa 18.2.3. With Mesa 18.0.5 (from Ubuntu 18.04 repositories) it happens very rarely.

Here is a video I recorded showing this (Mesa git): https://www.youtube.com/watch?v=He3OBNNP6Ro

Another relevant information I observed is how memory usage when using Mesa Git and Mesa 18.2.3 is significantly smaller: they use 22,5% of RAM memory from my computer, while using Mesa 18.0.5 uses 45% of RAM memory.

The game is set to graphic preset Ultralow. The effect was the most noticeable on Greece stages.

I have recorded an Apitrace with Mesa git but it has 5,1 GB compressed and will take hours to upload. When it finishes I'll add its link here. I'll try to bisect to see when the behavior changed in memory usage and blinking elements (I'm not sure if both things are related, but seems suspect).

System specifications:

Processor: Intel Core i3-6100U;
Video: Intel HD Graphics 520;
Architecture: amd64;
RAM memory: 8 GB;
Mesa: 19.0.0-devel (git-8c93ef5de9);
Kernel version: 4.20.0-drm-tip-0811a42b9e8b0fb3aa3ba028ddae292af436b6c2+;
Distribution: Xubuntu 18.04.1 amd64.
Comment 1 leozinho29_eu 2019-01-04 19:49:25 UTC
It seems there are two changes in Mesa that have effect on this, so it seems I'll need to do two bisections. One that seems between Mesa 18.1.0 and 18.1.9 and other between 18.1.9 and 18.2.0.

Here is the apitrace: https://mega.nz/#!5wxw2AoS!0RUdqDYJYxaP30F0SIIvyABib5D1VH3O6zMm2QXVRig

The loading was pretty long when recording the apitrace, so it will take some time to reach the game play.
Comment 2 Mark Janes 2019-01-05 00:08:40 UTC
my debian testing 18.1.9 mesa does not reproduce the blinking, and I see the blinking on mesa master.

I'm starting a bisect.
Comment 3 Mark Janes 2019-01-05 01:25:36 UTC
there may be some issue with uninitialized memory, or another source of intermittent behavior.  After a certain point in my bisection, I could no longer reproduce the flickers, even on commits where I previously saw it occur in a clear manner.
Comment 4 leozinho29_eu 2019-01-05 20:47:44 UTC
After bisecting the memory reduction I got:

4066610ad4956ff6bb0afefb767d7577b72d6081 is the first new commit
commit 4066610ad4956ff6bb0afefb767d7577b72d6081
Author: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Date:   Wed Jul 11 15:29:00 2018 +0300

    i965: Sweep NIR after linking phase to free held memory


The memory reduction seems to be not related with the textures blinking, fortunately.

I am getting consistent blinking issues with Mesa git. No matter how many times I open the game (on this boot it were at least 18 times) it always has significant graphical glitches.

The memory usage of the game is pretty variable too. At the stages, the best case of the newer Mesa the game was using only 18% of memory, which is pretty low. The worst case used 32%. While with the older Mesa I got values as high as 56% of memory.

One way to increase the frequency of the graphical glitches is to use VA-API encoding the same time, as recording the game with OBS Studio or FFmpeg, for example. Even then it is noticeable the difference between Mesa version 18.1.9 and git.
Comment 5 Tapani Pälli 2019-01-07 06:24:15 UTC
FWIW there is very similar blinking observed with 3DMark on Android.
Comment 6 leozinho29_eu 2019-01-07 23:53:47 UTC
Created attachment 143005 [details]
Videos showing the difference between the good and the bad

I found a consistent case to bisect in DiRT Rally: at the stage Ourea Spevsi in Greece, there is one part of the replay where the effect is very visible. That part of the stage has many tress and bushes that blink constantly with the bad commit while with the good commit it's nearly perfect (notice the nearly). Even using Mesa 13.0.3 (what Feral recommends) it is similar to what the good video is.

Now, with a consistent case, the only downside from the bisect seems to be the fact all builds being tested seem to be from before the memory reduction commit. Hopefully I'll be able to get the bisect result in a few hours.

Another downside may be that there is no longer any Mini Cooper or Renault Alpine intact.
Comment 7 leozinho29_eu 2019-01-08 15:22:20 UTC
I finished the bisect. The result I got is:

a363bb2cd0e2a141f2c60be005009703bffcbe4e is the first bad commit
commit a363bb2cd0e2a141f2c60be005009703bffcbe4e
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Tue Apr 10 01:18:25 2018 -0700

    i965: Allocate VMA in userspace for full-PPGTT systems.
    This patch enables soft-pinning of all buffers, allowing us to skip
    relocation processing entirely.  All systems with full PPGTT and > 4GB
    of VMA should gain these benefits.  This should be most Gen8+.
    Unfortunately, this excludes a few systems:
    - Cherryview (only has 32-bit addressing, despite 48-bit pointers)
    - Broadwell with a 32-bit kernel
    - Anybody running pre-4.5 kernel.
    We may enable it for Cherryview in the future, but it would require
    some tweaks to the memory zone.
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

:040000 040000 cd737c2051868581e9c9c7ca58234f5a87ee3536 b52a60e9b8b4e6fe7c329bc1a2bd2045251c1926 M	src

To be sure, I have tested this commit and the previous commit, 74259b98aab010d3062c5903770dc3067665b59e. And they really behave differently.

The entire git bisect log:

$ git bisect log
git bisect start
# good: [f57f37f3baea9cd9ca2b12c2b4eb1f7142ede48e] docs: Add 18.1.9 release notes
git bisect good f57f37f3baea9cd9ca2b12c2b4eb1f7142ede48e
# bad: [7378180e7aa652f3f95e4b953a552dcaf8fb8408] docs: update 18.2.0 release notes
git bisect bad 7378180e7aa652f3f95e4b953a552dcaf8fb8408
# bad: [3fc3798677545610f624c0887065e9cb6fcc6db2] spirv: Record the type of functions
git bisect bad 3fc3798677545610f624c0887065e9cb6fcc6db2
# bad: [e5130012e4b3b276ec80e11e9d79a69a3c3a5a4c] st/nir: Move lower_deref_instrs later
git bisect bad e5130012e4b3b276ec80e11e9d79a69a3c3a5a4c
# bad: [d7d5aab45b4b24a89970df17c82c4e00393400d2] intel,ir3: Disable nir_opt_copy_prop_vars
git bisect bad d7d5aab45b4b24a89970df17c82c4e00393400d2
# bad: [f46ecdc44167b7c6eefac07a02c1e0f1bc41e04e] nir: Consider deref instructions in opt_peephole_select
git bisect bad f46ecdc44167b7c6eefac07a02c1e0f1bc41e04e
# bad: [1e1733aaf06fe2aac62fe4c36d951ce09dc0dfbd] nir: Consider deref instructions in lower_phis_to_scalar
git bisect bad 1e1733aaf06fe2aac62fe4c36d951ce09dc0dfbd
# bad: [775ef1338428d2f48bb606c1a3c06467d5948f36] nir: Support deref instructions in lower_drawpixels
git bisect bad 775ef1338428d2f48bb606c1a3c06467d5948f36
# good: [6754c2e83d79f93b3a4c8c1c55ca4c5e3b965645] autotools: Include new meson files
git bisect good 6754c2e83d79f93b3a4c8c1c55ca4c5e3b965645
# good: [09a6cb7be668a975a49f4c37fbffd58e47629b9f] docs: fix various html tags mistakes
git bisect good 09a6cb7be668a975a49f4c37fbffd58e47629b9f
# bad: [9cc577761ff1165e0b99d3ceaa936b342dea10b1] meson: Remove various completed todos
git bisect bad 9cc577761ff1165e0b99d3ceaa936b342dea10b1
# good: [4ad8e2ac82d6dbc78dd39947d6b2914be169d0d9] doc: update calendar, add news and link release notes for 18.1.1
git bisect good 4ad8e2ac82d6dbc78dd39947d6b2914be169d0d9
# good: [9d5860310d57db9b3aabf0c0e562130fb8dcce99] v3d: Enable the new NIR bitfield operation lowering paths.
git bisect good 9d5860310d57db9b3aabf0c0e562130fb8dcce99
# bad: [37eb56d239986e2e7ca1c87d08fd357378a3a06e] autotools/meson: compile against wayland-egl-*backend*
git bisect bad 37eb56d239986e2e7ca1c87d08fd357378a3a06e
# bad: [eeae4851494c16d2a6591550bfa6ef77d887ebe3] i965/screen: Refactor query_dma_buf_formats
git bisect bad eeae4851494c16d2a6591550bfa6ef77d887ebe3
# bad: [a363bb2cd0e2a141f2c60be005009703bffcbe4e] i965: Allocate VMA in userspace for full-PPGTT systems.
git bisect bad a363bb2cd0e2a141f2c60be005009703bffcbe4e
# good: [44c614843c8785be57af06cc56208ad1497d05bc] intel/blorp: Don't vertex fetch directly from clear values
git bisect good 44c614843c8785be57af06cc56208ad1497d05bc
# good: [1098bc5e854a1253e050fa30d16eda6ca676d4b3] nir: move ends_in_break() helper to nir_loop_analyze.h
git bisect good 1098bc5e854a1253e050fa30d16eda6ca676d4b3
# good: [74259b98aab010d3062c5903770dc3067665b59e] intel/blorp: Emit VF cache invalidates for 48-bit bugs with softpin.
git bisect good 74259b98aab010d3062c5903770dc3067665b59e
# first bad commit: [a363bb2cd0e2a141f2c60be005009703bffcbe4e] i965: Allocate VMA in userspace for full-PPGTT systems.
Comment 8 Danylo 2019-01-08 15:27:22 UTC
There was one recent bug with that commit - https://bugs.freedesktop.org/show_bug.cgi?id=109072 that was fixed with:

commit 31e4c9ce400341df9b0136419b3b3c73b8c9eb7e
Author: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Date:   Thu Jan 3 16:18:48 2019 +0000

    i965: add CS stall on VF invalidation workaround

Have you tested with this commit?
Comment 9 leozinho29_eu 2019-01-08 20:21:06 UTC
I just rebuilt Mesa git which has this commit, tested with it and the same behavior bad commits have was observed: frequent blinking of elements in the game.
Comment 10 Sergii Romantsov 2019-01-10 16:59:38 UTC
As expected workaround observed drirc option: always_flush_batch=true
Comment 11 leozinho29_eu 2019-01-11 19:41:01 UTC
I have set always_flush_batch=true as an environment variable for the game (full command line on Steam: always_flush_batch=true %command%) and it worked well, without the constant blinking elements, thank you.
Comment 12 asimiklit 2019-01-23 09:31:59 UTC
We checked this issue (using provided trace) on few machines:
|                   Name                   |  Video memory |  Reproducible  |
| HD Graphics 630 (Kaby Lake GT2 (0x591b)  |    3072MB     |       No       |
| UHD Graphics 620 (Kabylake GT2) (0x5917) |    3072MB     |       No       |
| HD Graphics 620 (Kaby Lake GT2) (0x5916) |    3072MB     |       Yes      | 
|        GeForce GTX 1060 6GB/PCIe/SSE2    |    6144MB     |       No       | 

All machines had 16GB RAM and OS Ubuntu 18.04.
For all tests, except nvidia case where was used
proprietary driver, was used 
debug configuration of latest Mesa-Git.

One more point about case where we managed out to
reproduce it we noticed that in our case the blinking
frequency was less then on the provided youtube video.

Hope it would help somebody who are going to
find the root cause of this issue.
Comment 13 Lionel Landwerlin 2019-01-23 14:16:16 UTC
Just adding that :

 0x5916 : GT stepping C0
 0x5917 : GT stepping G0
 0x591b : GT stepping F0

Maybe something to dig into, but I can't really spot any required workaround for C0.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.