Bug 44647

Summary: [wine regression] Call of Duty 4: Intro videos renders garbage
Product: Mesa Reporter: Sven Arvidsson <sa>
Component: Drivers/Gallium/r600Assignee: Default DRI bug account <dri-devel>
Status: RESOLVED NOTOURBUG QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Screenshot of broken video

Description Sven Arvidsson 2012-01-10 10:13:12 UTC
Created attachment 55392 [details]
Screenshot of broken video

Intro videos in the game Call of Duty 4 (running with Wine) no longer renders correctly, bisecting leads to this:

e8139ebf583acf37150a8b341bcbef6b924a7792 is the first bad commit
commit e8139ebf583acf37150a8b341bcbef6b924a7792
Author: Mathias Fröhlich <Mathias.Froehlich@gmx.net>
Date:   Tue Jul 26 07:05:10 2011 +0200

    r600g: Replace needless flush in texture upload.
    
    Replace pipe->flush() with pipe->texture_barrier() in
    the texture upload path for the staging texture.
    This should be enough to get data out of the gpu
    caches ready to be read for texture fetch.

:040000 040000 b3f16d1a114f54d753ba7845b697888307f6246e faab26149053fdb2fb65d81bb2a777a77e130de2 M	src


Adding the flush back fixes the problem.
Comment 1 Sven Arvidsson 2013-10-11 16:14:56 UTC
Still a problem with Wine 1.7.3 and Mesa 9.2.1.
Comment 2 Jaime Rave 2014-04-21 21:09:15 UTC
Still a problem with Wine 1.7.17 and Mesa 10.1
Comment 3 Sven Arvidsson 2016-04-18 11:30:34 UTC
Also a problem on radeonsi.

Apitrace of the problem:
https://www.dropbox.com/s/ibt9iu15x4mxw9q/cod4.trace?dl=0

I'm getting a lot of errors when replaying the trace, so I guess it's possible the game or Wine is doing something wrong:

100824: message: major api error 1: GL_INVALID_OPERATION in glTexImage3D(bad target for depth texture)
100824 @0 glTexImage3D(target = GL_TEXTURE_3D, level = 0, internalformat = GL_DEPTH32F_STENCIL8, width = 16, height = 16, depth = 16, border = 0, format = GL_DEPTH_STENCIL, type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV, pixels = NULL)
100824: warning: glGetError(glTexImage3D) = GL_INVALID_OPERATION
100830: message: api issue 2: FBO incomplete: color attachment incomplete [0]
100865: message: api issue 2: FBO incomplete: color attachment incomplete [0]
Comment 4 Sven Arvidsson 2016-04-20 15:08:38 UTC
Setting StrictDrawOrdering in Wine to enabled gets working videos again, but at a severe performance cost.
Comment 5 Nicolai Hähnle 2016-04-20 15:56:10 UTC
Hi Sven, thanks for the apitrace. I can confirm that there is garbage in some of the first frames of the apitrace, e.g. Frame 11 @77450. I'm going to look in more detail, though the many error messages do hint at an application bug.
Comment 6 Sven Arvidsson 2016-04-20 16:38:25 UTC
I just tried Wine Staging with the CSMT (Command stream multithreading) patches, and the videos play fine there, so I think it really is a problem with Wine.
Comment 7 Nicolai Hähnle 2016-04-20 17:07:10 UTC
This is an application bug (though I don't know whether the fault lies with Wine or with CoD4): there is insufficient synchronization between different contexts.

If you look e.g. at Frame 5, there is a sequence of glTexSubImage2D calls for textures 64 to 66 running in context 3.

The command sequence switches to context 2 in call 75827, and the textures are used in call 76024, still on context 2 and without any flush or fence command in between to ensure that the TexSubImage commands are actually executed.

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.