Bug 99444 - [radeonsi] The Witcher 3 (GOG/1.31) [Wine] starting menu is distorted
Summary: [radeonsi] The Witcher 3 (GOG/1.31) [Wine] starting menu is distorted
Status: RESOLVED NOTOURBUG
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-18 03:03 UTC by Shmerl
Modified: 2017-02-10 03:55 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Witcher 3 main menu distortion (no CSMT) (334.68 KB, image/jpeg)
2017-01-18 03:03 UTC, Shmerl
Details
R9 Fury / mesa de0b0a3a9c / llvm 292523 (2.64 MB, image/png)
2017-01-20 20:24 UTC, Clément Guérin
Details

Description Shmerl 2017-01-18 03:03:17 UTC
Created attachment 129014 [details]
Witcher 3 main menu distortion (no CSMT)

I'm testing The Witcher 3 with recent Wine staging 2.0rc5 (CSMT disabled), using AMD RX 480 and latest Mesa devel:

    OpenGL renderer string: Gallium 0.4 on AMD POLARIS10 (DRM 3.3.0 / 4.8.0-2-amd64, LLVM 3.9.1)
    OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.0.0-devel (git-aac562f112)

Starting screen has distorted text in the menu (see attached screenshot). For the reference, the game is still unplayable beyond the starting screen and intro with broken graphics, but users of Nvidia blob report that they don't have this issue in the starting menu which appears correct to them, so menu distortion looks radenosi related.
Comment 1 Shmerl 2017-01-18 03:09:58 UTC
For the reference, to run the game in Wine, you need to set:

[HKEY_CURRENT_USER\Software\Wine\Direct3D] 
"DirectDrawRenderer"="opengl" 
"UseGLSL"="enabled" 
"MaxVersionGL"=dword:00040005

And make sure you are using wine-staging 2.0rc5 or later, since older versions crash on startup because of the virtual heap limit.
Comment 2 Shmerl 2017-01-18 08:18:35 UTC
This appears to be Wine related and not caused by Mesa. See https://bugs.winehq.org/show_bug.cgi?id=39180

Closing.
Comment 3 Shmerl 2017-01-19 03:54:44 UTC
Reopening it, since it appears, that this still can be a radeonsi bug. See here:

* https://bugs.winehq.org/show_bug.cgi?id=39180#c51
* https://bugs.winehq.org/show_bug.cgi?id=39180#c55

I replayed the trace which works well for other drivers, and I see distortions with radeonsi (this happens both with Mesa 13.0.2 and Mesa git).

The trace can be found here: https://ufile.io/ed6ac (you can replay it with apitrace).
Comment 4 Clément Guérin 2017-01-20 20:24:34 UTC
Created attachment 129076 [details]
R9 Fury / mesa de0b0a3a9c / llvm 292523
Comment 5 Grazvydas Ignotas 2017-01-21 00:05:12 UTC
The trace works correctly on Intel (Skylake and Haswell).

On radeonsi, I can see the corruption, and there are lots of errors:
118231: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER0_NV)
118231 @0 glActiveTexture(texture = GL_COMBINER0_NV)

They range from GL_COMBINER0_NV (0x8550) to 0x857f, so probably the trace was recorded on something supporting more texture units than radeonsi? Was the trace recorded on radeonsi (or AMD hardware at least)?
Comment 6 Shmerl 2017-01-22 03:52:39 UTC
(In reply to Grazvydas Ignotas from comment #5)
> 
> They range from GL_COMBINER0_NV (0x8550) to 0x857f, so probably the trace
> was recorded on something supporting more texture units than radeonsi? Was
> the trace recorded on radeonsi (or AMD hardware at least)?

I didn't record this trace, just reposted it here (I asked the author to clarify where exactly it was recoreded).

Here is a trace on RX 480 and radeonsi: https://uploadfiles.io/caf8c
Comment 7 Samuel Pitoiset 2017-01-23 10:54:10 UTC
Thanks for reporting the issue. I can reproduce it with mesa/llvm git on my rx 480. Needs investigation.
Comment 8 Samuel Pitoiset 2017-01-23 20:30:34 UTC
Well, the trace is broken somehow, and it has been recorded using NVIDIA blob because it relies on NV_register_combiners. That explains the GL_COMBINER0_NV errors while replaying it.

Could you try that game directly using RadeonSI? Presumably, it should work fine except if it still relies on NV_register_combiners. And that would be a game bug.
Comment 9 Shmerl 2017-01-23 20:42:19 UTC
(In reply to Samuel Pitoiset from comment #8)
> Well, the trace is broken somehow, and it has been recorded using NVIDIA
> blob because it relies on NV_register_combiners. That explains the
> GL_COMBINER0_NV errors while replaying it.
> 
> Could you try that game directly using RadeonSI? Presumably, it should work
> fine except if it still relies on NV_register_combiners. And that would be a
> game bug.

The second trace I linked: https://uploadfiles.io/caf8c is recorded on AMD hardware (RX 480) with radeonsi. And the screenshot of the initial report shows how it looks on actual RX 480 as well. That's exactly how I run it (it's from the actual game run in Wine, not from trace).

I'm not sure how the other trace ( https://ufile.io/ed6ac ) was recorded - the author never replied.
Comment 10 Shmerl 2017-01-23 20:44:49 UTC
And since the game isn't using GL natively, if anything is calling GL_NV_register_combiners in some situations, it must be Wine.
Comment 11 Shmerl 2017-01-31 01:38:35 UTC
I just replayed my trace (recorder on radeonsi / RX480), and I see this in the log:

120612: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER0_NV)
120612 @1 glActiveTexture(texture = GL_COMBINER0_NV)
120619: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER1_NV)
120619 @1 glActiveTexture(texture = GL_COMBINER1_NV)
120626: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER2_NV)
120626 @1 glActiveTexture(texture = GL_COMBINER2_NV)
120633: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER3_NV)
120633 @1 glActiveTexture(texture = GL_COMBINER3_NV)
120640: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER4_NV)
120640 @1 glActiveTexture(texture = GL_COMBINER4_NV)
120647: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER5_NV)
120647 @1 glActiveTexture(texture = GL_COMBINER5_NV)
120654: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER6_NV)
120654 @1 glActiveTexture(texture = GL_COMBINER6_NV)
120661: message: major api error 2: GL_INVALID_ENUM in glActiveTexture(texture=GL_COMBINER7_NV)
120661 @1 glActiveTexture(texture = GL_COMBINER7_NV)

I can open a bug in Wine about it.
Comment 12 Samuel Pitoiset 2017-01-31 09:18:01 UTC
Well yeah, it's definitely unrelated to Mesa/RadeonSI. The app should check if NV_register_combiners is supported before using it. I'm going to close the ticket.
Comment 13 Józef Kucia 2017-01-31 09:41:23 UTC
(In reply to Samuel Pitoiset from comment #12)
> Well yeah, it's definitely unrelated to Mesa/RadeonSI. The app should check
> if NV_register_combiners is supported before using it. I'm going to close
> the ticket.

Are you sure that NV_register_combiners are used? I haven't checked the trace myself but I doubt this is a case.

(In reply to Shmerl from comment #11)
> I just replayed my trace (recorder on radeonsi / RX480), and I see this in
> the log:
> 
> 120612: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER0_NV)
> 120612 @1 glActiveTexture(texture = GL_COMBINER0_NV)
> 120619: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER1_NV)
> 120619 @1 glActiveTexture(texture = GL_COMBINER1_NV)
> 120626: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER2_NV)
> 120626 @1 glActiveTexture(texture = GL_COMBINER2_NV)
> 120633: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER3_NV)
> 120633 @1 glActiveTexture(texture = GL_COMBINER3_NV)
> 120640: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER4_NV)
> 120640 @1 glActiveTexture(texture = GL_COMBINER4_NV)
> 120647: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER5_NV)
> 120647 @1 glActiveTexture(texture = GL_COMBINER5_NV)
> 120654: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER6_NV)
> 120654 @1 glActiveTexture(texture = GL_COMBINER6_NV)
> 120661: message: major api error 2: GL_INVALID_ENUM in
> glActiveTexture(texture=GL_COMBINER7_NV)
> 120661 @1 glActiveTexture(texture = GL_COMBINER7_NV)

This has nothing to do with NV_register_combiners. It just displayed like this in apitrace, because GL_COMBINERi_NV = GL_TEXTURE0 + x.
Comment 14 Shmerl 2017-01-31 16:58:16 UTC
Opened Wine bug: https://bugs.winehq.org/show_bug.cgi?id=42347

I hope between Mesa and Wine, it will be possible to figure out what's going wrong.
Comment 15 Samuel Pitoiset 2017-02-02 09:42:16 UTC
(In reply to Józef Kucia from comment #13)
> (In reply to Samuel Pitoiset from comment #12)
> > Well yeah, it's definitely unrelated to Mesa/RadeonSI. The app should check
> > if NV_register_combiners is supported before using it. I'm going to close
> > the ticket.
> 
> Are you sure that NV_register_combiners are used? I haven't checked the
> trace myself but I doubt this is a case.
> 
> (In reply to Shmerl from comment #11)
> > I just replayed my trace (recorder on radeonsi / RX480), and I see this in
> > the log:
> > 
> > 120612: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER0_NV)
> > 120612 @1 glActiveTexture(texture = GL_COMBINER0_NV)
> > 120619: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER1_NV)
> > 120619 @1 glActiveTexture(texture = GL_COMBINER1_NV)
> > 120626: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER2_NV)
> > 120626 @1 glActiveTexture(texture = GL_COMBINER2_NV)
> > 120633: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER3_NV)
> > 120633 @1 glActiveTexture(texture = GL_COMBINER3_NV)
> > 120640: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER4_NV)
> > 120640 @1 glActiveTexture(texture = GL_COMBINER4_NV)
> > 120647: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER5_NV)
> > 120647 @1 glActiveTexture(texture = GL_COMBINER5_NV)
> > 120654: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER6_NV)
> > 120654 @1 glActiveTexture(texture = GL_COMBINER6_NV)
> > 120661: message: major api error 2: GL_INVALID_ENUM in
> > glActiveTexture(texture=GL_COMBINER7_NV)
> > 120661 @1 glActiveTexture(texture = GL_COMBINER7_NV)
> 
> This has nothing to do with NV_register_combiners. It just displayed like
> this in apitrace, because GL_COMBINERi_NV = GL_TEXTURE0 + x.

You are right.

The game wants 192 texture units but RadeonSI only exposes 144 (24 per stages), that explains at least, the glActiveTexture() errors in the trace.

But according to the GL spec, the minimum number of texture units is 80.
Comment 16 Samuel Pitoiset 2017-02-03 09:57:38 UTC
Does the following patch help?

https://cgit.freedesktop.org/mesa/mesa/commit/?id=dfe111368d11aaffae7f8738c858c335cdec1e9d

It actually fixes the glActiveTexture() errors but I still get rendering issues on my side using the trace.

Can you confirm by running the game directly?
Thanks!
Comment 17 Józef Kucia 2017-02-03 10:05:52 UTC
(In reply to Samuel Pitoiset from comment #16)
> Does the following patch help?
> 
> https://cgit.freedesktop.org/mesa/mesa/commit/
> ?id=dfe111368d11aaffae7f8738c858c335cdec1e9d
> 
> It actually fixes the glActiveTexture() errors but I still get rendering
> issues on my side using the trace.

I think that the glActiveTexture() errors are unrelated to any rendering issues. These are generated by GL context initialization in Wine. It's not clear to me if they appear when the game is run directly. We bind dummy textures to GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB units, so we shouldn't exceed the limit reported by the driver.
Comment 18 Samuel Pitoiset 2017-02-03 10:45:03 UTC
(In reply to Józef Kucia from comment #17)
> (In reply to Samuel Pitoiset from comment #16)
> > Does the following patch help?
> > 
> > https://cgit.freedesktop.org/mesa/mesa/commit/
> > ?id=dfe111368d11aaffae7f8738c858c335cdec1e9d
> > 
> > It actually fixes the glActiveTexture() errors but I still get rendering
> > issues on my side using the trace.
> 
> I think that the glActiveTexture() errors are unrelated to any rendering
> issues. These are generated by GL context initialization in Wine. It's not
> clear to me if they appear when the game is run directly. We bind dummy
> textures to GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB units, so we shouldn't
> exceed the limit reported by the driver.

Yes, but according to the trace, 192 texture units were used and the limit was 144 before that commit. As I said, I still have rendering issues (other issue?). Anyway, it seems reasonable to expose 32 texture units per stage.
Comment 19 Shmerl 2017-02-08 02:21:50 UTC
(In reply to Samuel Pitoiset from comment #16)
> Does the following patch help?
> 
> https://cgit.freedesktop.org/mesa/mesa/commit/
> ?id=dfe111368d11aaffae7f8738c858c335cdec1e9d
> 
> It actually fixes the glActiveTexture() errors but I still get rendering
> issues on my side using the trace.
> 
> Can you confirm by running the game directly?
> Thanks!

I built Mesa from source after that commit, and rendering issues in the menu are still present when game is run in Wine.
Comment 20 Shmerl 2017-02-10 03:55:54 UTC
FYI: I just tested it with wine-staging 2.1 with CSMT enabled (that version allows using it with DX11 already), and corruption in the start menu is gone.


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.