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

[Linux] Flickering shadows #55

Closed
MaelRL opened this issue Jun 23, 2015 · 11 comments
Closed

[Linux] Flickering shadows #55

MaelRL opened this issue Jun 23, 2015 · 11 comments
Assignees

Comments

@MaelRL
Copy link

MaelRL commented Jun 23, 2015

Hi,

I have the following issue: the shadows flicker (as if the option was being quickly turned on and off randomly). This requires 'Shadows' to be enabled, but it happens regardless of the state of all the other options (could be max or min settings, as long as Shadows is enabled, the problem is there).

It also happens regardless of weather choices, whether I am in full screen / windowed / etc, and on all the maps.

Below are my system's info :

Processor Information:
    Vendor:  GenuineIntel
    CPU Family:  0x6
    CPU Model:  0x3c
    CPU Stepping:  0x3
    CPU Type:  0x0
    Speed:  3700 Mhz
    8 logical processors
    4 physical processors
    HyperThreading:  Supported
    FCMOV:  Supported
    SSE2:  Supported
    SSE3:  Supported
    SSSE3:  Supported
    SSE4a:  Unsupported
    SSE41:  Supported
    SSE42:  Supported

Network Information:
    Network Speed:  

Operating System Version:
    Linux (64 bit)
    Kernel Name:  Linux
    Kernel Version:  4.0.5-300.fc22.x86_64
    X Server Vendor:  Fedora Project
    X Server Release:  11701000
    X Window Manager:  GNOME Shell
    Steam Runtime Version:  steam-runtime-release_2015-01-06

Video Card:
    Driver:  Intel Open Source Technology Center Mesa DRI Intel(R) Haswell Mobile 

    Driver Version:  3.0 Mesa 10.5.4
    OpenGL Version: 3.0
    Desktop Color Depth: 24 bits per pixel
    Monitor Refresh Rate: 60 Hz
    VendorID:  0x10de
    DeviceID:  0xff6
    Number of Monitors:  2
    Number of Logical Video Cards:  2
    Primary Display Resolution:  1920 x 1080
    Desktop Resolution: 3840 x 1080
    Primary Display Size: 20.08" x 11.30"  (23.03" diag)
                                            51.0cm x 28.7cm  (58.5cm diag)
    Primary VRAM Not Detected

Sound card:
    Audio device: Intel Haswell HDMI

Memory:
    RAM:  15953 Mb

Miscellaneous:
    UI Language:  English
    LANG:  en_GB.UTF-8
    Microphone:  Not set
    Total Hard Disk Space Available:  442810 Mb
    Largest Free Hard Disk Block:  365462 Mb

Installed software:

Recent Failure Reports:
    Tue Jun 23 21:04:42 2015 GMT: file ''/tmp/dumps/crash_20150623230238_1.dmp'', upload yes: ''CrashID=bp-5a080ba2-1520-469b-b117-4d0cb2150623''
    Tue Jun 23 21:05:55 2015 GMT: file ''/tmp/dumps/crash_20150623225851_1.dmp'', upload yes: ''CrashID=bp-8d191226-ba83-4054-829a-471512150623''
@danginsburg
Copy link

I have seen this across multiple revisions of mesa (10.3.2, 10.5.8 at least) on Haswell with Intel Iris Pro. I suspect a mesa driver bug, but am not entirely sure yet. I believe it is this mesa bug which has been there for a long time: https://bugs.freedesktop.org/show_bug.cgi?id=80500

@z0mbieprocess
Copy link

same here... HD3000

@danginsburg
Copy link

@imirkin I am seeing this on Haswell Iris Pro (Intel(R) Core(TM) i7-4770R CPU @ 3.20GHz) on Ubuntu 14.10 x86_64 with both mesa 10.3.2 and 10.5.8. Are you able to repro the issue? Any thoughts from the mesa side? It appears that certain objects are not getting rendered into the shadowmap (you can view the shadowmap with r_dota_shadows_debug 1 from the console and when the flickering happens you will see those objects missing from the shadow map). I haven't had a chance yet to fully investigate this, but I haven't seen the behavior on any other driver/GPU. If you have any insights, please let me know.

@imirkin
Copy link

imirkin commented Jun 24, 2015

@danginsburg sorry, I just do nouveau (and dabble in core every so often). However if you provide an apitrace of the issue to the intel folk (and file a bug), I suspect they'll be quite happy to investigate. I do know that depth and stencil come with various problems on various intel GPU's (i.e. the driver has to jump through hoops.. diff ones for diff gpu's), so I wouldn't be overly surprised if something went wrong. Alternatively if you provide detailed instructions on how to repro, they may also be able to do it, I suspect they have access to all the Valve games; but don't assume they've ever actually played Dota2 before :)

@danginsburg
Copy link

This appears to be a bug in mesa. The below patch fixed the issue for me on Haswell. If you are able to rebuild mesa please give this patch a try and report back if it fixes the issue. I'm working with LunarG to figure out how to get the fix into mesa.

From 1e7d8f2daa60869d33c262d85cb791e40f5236ed Mon Sep 17 00:00:00 2001
From: Mike Stroyan <mike@LunarG.com>
Date: Mon, 5 Jan 2015 16:01:11 -0700
Subject: [PATCH] call gen7_upload_sf_clip_viewport for new fs data

---
 src/mesa/drivers/dri/i965/gen7_viewport_state.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/gen7_viewport_state.c b/src/mesa/drivers/dri/i965/gen7_viewport_state.c
index b655205..9ad04b0 100644
--- a/src/mesa/drivers/dri/i965/gen7_viewport_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_viewport_state.c
@@ -96,7 +96,8 @@ const struct brw_tracked_state gen7_sf_clip_viewport = {
    .dirty = {
       .mesa = _NEW_BUFFERS |
               _NEW_VIEWPORT,
-      .brw = BRW_NEW_BATCH,
+      .brw = BRW_NEW_BATCH |
+             BRW_NEW_FS_PROG_DATA,
    },
    .emit = gen7_upload_sf_clip_viewport,
 };
-- 
2.1.0

@z0mbieprocess
Copy link

still flickering for me with this patch (HD3000 - mesa 10.6)
somehow the flickering seems differently...

@danginsburg
Copy link

HD3000 is gen6 so it would require a different fix (the above fix is for gen7). Please try this one for gen6 and see if it works:

From 164210383edcaedbd7c8b9e9d05ea93fa94073b0 Mon Sep 17 00:00:00 2001
From: Mike Stroyan <mike@LunarG.com>
Date: Wed, 24 Jun 2015 13:04:54 -0600
Subject: [PATCH] Call gen6_upload_clip_vp for new FS data

---
 src/mesa/drivers/dri/i965/gen6_viewport_state.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_viewport_state.c b/src/mesa/drivers/dri/i965/gen6_viewport_state.c
index 7c8d884..3496d81 100644
--- a/src/mesa/drivers/dri/i965/gen6_viewport_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_viewport_state.c
@@ -73,7 +73,8 @@ gen6_upload_clip_vp(struct brw_context *brw)
 const struct brw_tracked_state gen6_clip_vp = {
    .dirty = {
       .mesa = _NEW_VIEWPORT,
-      .brw = BRW_NEW_BATCH,
+      .brw = BRW_NEW_BATCH |
+             BRW_NEW_FS_PROG_DATA,
    },
    .emit = gen6_upload_clip_vp,
 };
-- 
2.1.0

@z0mbieprocess
Copy link

with this patch only the small bushes in the main map are flickering now, all the trees from the demo map are still flickering

@MaelRL
Copy link
Author

MaelRL commented Jun 25, 2015

I haven't tried the patch yet, but I've upgraded mesa to 10.6 and the flickering of trees is gone consistently on all the maps (including demo).

However, there's still flickering for towers / bushes / flag poles / etc.

@stroyan
Copy link

stroyan commented Jul 1, 2015

Here is a proper fix for the flickering shadows. The previous patches that made more gen6_upload_clip_vp calls were actually just propping up a bad implementation of gen6_upload_blend_state. This change produces the correct rendering for the correct reason.

From 2165cfa2b70dab5c333bcbc5c1eb3a3465ba94f9 Mon Sep 17 00:00:00 2001
From: Mike Stroyan <mike@LunarG.com>
Date: Wed, 1 Jul 2015 10:02:37 -0600
Subject: [PATCH] i965: allocate at least 1 BLEND_STATE element

When there are no color buffer render targets, gen6 and gen7 still
use the first BLEND_STATE element to determine alpha test.
gen6_upload_blend_state was allocating zero elements when
ctx->Color.AlphaEnabled was false.
That left _3DSTATE_CC_STATE_POINTERS or _3DSTATE_BLEND_STATE_POINTERS
pointing to random data from some previous brw_state_batch().
That sometimes suppressed depth rendering when those bits
happened to mean COMPAREFUNC_NEVER.
This produced flickering shadows for dota2 reborn.
--- 
 src/mesa/drivers/dri/i965/gen6_cc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_cc.c b/src/mesa/drivers/dri/i965/gen6_cc.c
index 2bfa271..2b76e24 100644
--- a/src/mesa/drivers/dri/i965/gen6_cc.c
+++ b/src/mesa/drivers/dri/i965/gen6_cc.c
@@ -51,7 +51,7 @@ gen6_upload_blend_state(struct brw_context *brw)
     * with render target 0, which will reference BLEND_STATE[0] for 
     * alpha test enable.
     */  
-   if (nr_draw_buffers == 0 && ctx->Color.AlphaEnabled)
+   if (nr_draw_buffers == 0)
       nr_draw_buffers = 1;

    size = sizeof(*blend) * nr_draw_buffers;
--  
2.1.0

@danginsburg
Copy link

Thank you @stroyan! I can confirm that this patch fixes the issue. @stroyan has committed this patch to mesa master so you can either build latest mesa from master or apply this patch to your build and it will fix the shadow issues. Official patch is here:

http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe2b748a39ff676949fcefccf739aff967fc38c5

Closing.

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

6 participants