http://bugs.winehq.org/show_bug.cgi?id=27194
Summary: The Witcher 2: White/coloured screen with UseGLSL=enabled Product: Wine Version: 1.3.20 Platform: x86-64 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3d AssignedTo: wine-bugs@winehq.org ReportedBy: dredgingthelake@gmail.com
Created an attachment (id=34742) --> (http://bugs.winehq.org/attachment.cgi?id=34742) Witcher 2 - GLSL enabled - 01
As summary, during gameplay screen is white and/or coloured in a glitchy way. Screenshots will be uploaded to show this more clearly. The main error seems to be this:
err:d3d_shader:shader_glsl_select >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from glUseProgramObjectARB @ /var/tmp/portage/app-emulation/wine-1.3.20/work/wine-1.3.20/dlls/wined3d/glsl_shader.c / 4625
Additionally, setting "UseGLSL = disabled" works around the issue.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #1 from DL dredgingthelake@gmail.com 2011-05-17 05:35:53 CDT --- Created an attachment (id=34743) --> (http://bugs.winehq.org/attachment.cgi?id=34743) Witcher 2 - GLSL enabled - 02
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #2 from DL dredgingthelake@gmail.com 2011-05-17 05:44:38 CDT --- Created an attachment (id=34744) --> (http://bugs.winehq.org/attachment.cgi?id=34744) Witcher 2 - GLSL disabled
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #3 from DL dredgingthelake@gmail.com 2011-05-17 05:48:05 CDT --- Created an attachment (id=34745) --> (http://bugs.winehq.org/attachment.cgi?id=34745) Terminal output with GLSL enabled
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #4 from DL dredgingthelake@gmail.com 2011-05-17 05:50:57 CDT --- Additional information:
Using a Nvidia GTX275 card with 270.41.06 drivers
http://bugs.winehq.org/show_bug.cgi?id=27194
Alex Bradbury asb@asbradbury.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |asb@asbradbury.org
http://bugs.winehq.org/show_bug.cgi?id=27194
rmlipman@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1
--- Comment #5 from rmlipman@gmail.com 2011-05-17 15:05:40 CDT --- *** This bug has been confirmed by popular vote. ***
http://bugs.winehq.org/show_bug.cgi?id=27194
Sebastian Mikulec sirdilznik@optonline.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sirdilznik@optonline.net
http://bugs.winehq.org/show_bug.cgi?id=27194
Silver number048@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |number048@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #6 from Silver number048@gmail.com 2011-07-04 08:16:02 CDT --- I can shed some additional light on the problem.
The GL_INVALID_OPERATION from the original description is actually not the real problem. Instead it's just the cause of a failed shader compile. The reason why the shader fails is because it contains illegal code. Looking at shader object 8 from the attached log it's apparent that the generated shader code uses sampler variables which hasn't been declared.
For example the error on line 94 corresponds to the line "R5.xyzw = (texture2D(Psampler5, R1.zw).xyzw);". Only Psampler[0-3] are defined!
Disabling GLSL isn't a real fix either because ironically the generated ARB shader also contains errors. (It's possible that nvidia is able to cope with these errors more graciously than AMD).
Because the error originates from the generation of the OpenGL shader, this is clearly a wine bug and totally unrelated to any hardware driver.
A short description of the bug could be: "Error during conversion from DirectX shader to OpenGL shader".
I tried to locate the bug in the wine source code. But even though I know in which files to search for the problem, I'm not familiar enough with the source code to be able to pinpoint the relevant locations.
Currently the latest git version is still effected by this bug.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #7 from Henri Verbeet hverbeet@gmail.com 2011-07-04 08:27:29 CDT --- +d3d_shader might be useful.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #8 from Silver number048@gmail.com 2011-07-04 08:51:10 CDT --- Created an attachment (id=35427) --> (http://bugs.winehq.org/attachment.cgi?id=35427) Output from WINEDEUB=+d3d_shader
I've added line numbers to the GLSL output and I exit the program as soon as shaders has been dumped. The OpenGL compiler errors are generated from a slightly outdated version of the fglrx driver.
http://bugs.winehq.org/show_bug.cgi?id=27194
Silver number048@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #35427|Output from |Output from description|WINEDEUB=+d3d_shader |WINEDEBUG=+d3d_shader
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #9 from Henri Verbeet hverbeet@gmail.com 2011-07-04 09:21:40 CDT --- (In reply to comment #8)
trace:d3d_shader:wined3d_shader_create_vs device 0x10eb0ec8, byte_code 0x90b9000, output_signature (nil), parent 0x10ce3288, parent_ops 0x7e40ad0c, shader 0x10ce3290. ... trace:d3d_shader:shader_trace_init ps_3_0
The game seems to be creating a pixel shader through IDirect3DDevice9::CreateVertexShader(). Surprisingly, this almost works, but the shader then runs into the vertex shader sampler limit of 4. To confirm, could you create a new log, with WINEDEBUG="+d3d9,+d3dx,+d3d,+d3d_shader"?
http://bugs.winehq.org/show_bug.cgi?id=27194
Silver number048@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #35427|0 |1 is obsolete| |
--- Comment #10 from Silver number048@gmail.com 2011-07-04 09:28:25 CDT --- Created an attachment (id=35431) --> (http://bugs.winehq.org/attachment.cgi?id=35431) WINEDEBUG="+d3d9,+d3dx,+d3d,+d3d_shader"
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #11 from Henri Verbeet hverbeet@gmail.com 2011-07-04 09:38:08 CDT --- (In reply to comment #10)
trace:d3d9:IDirect3DDevice9Impl_CreateVertexShader Created vertex shader 0x10cb8c58. ... trace:d3d9:IDirect3DDevice9Impl_SetPixelShader iface 0x10eab940, shader 0x10cb8c58.
Looks like it really does create the pixel shader as vertex shader. It may take a while to fix this. As a quick hack you could perhaps try raising the sampler limit ("shader->limits.sampler = 4;") in vertexshader_set_limits().
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #12 from Silver number048@gmail.com 2011-07-04 10:04:59 CDT --- (In reply to comment #11)
(In reply to comment #10)
trace:d3d9:IDirect3DDevice9Impl_CreateVertexShader Created vertex shader 0x10cb8c58. ... trace:d3d9:IDirect3DDevice9Impl_SetPixelShader iface 0x10eab940, shader 0x10cb8c58.
Looks like it really does create the pixel shader as vertex shader. It may take a while to fix this. As a quick hack you could perhaps try raising the sampler limit ("shader->limits.sampler = 4;") in vertexshader_set_limits().
Spot on. Increasing the limit to 8 bypasses the problem.
I didn't test anything excepts the starting menu and the intro logos and so far everything is much much smoother than before. Before it was lagging a bit and the sound was interrupted. Now it's all smooth. Fixing this bug might actually fix all known bugs for this game so far.
Is this a wine bug or is the game doing things wrongly. Maybe it would be worth it to send a notification to the developer.
Anyway, great work finding the cause and providing a temporal fix. I'm much obliged. :)
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #13 from DL dredgingthelake@gmail.com 2011-07-04 10:54:11 CDT --- I just tried raising the vertex shader sampler limit to 8 (and also 16) but although it does reduce the severity of the glitches, they are still there (once you get in game). Screenshot and log will be uploaded shortly.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #14 from Silver number048@gmail.com 2011-07-04 17:21:37 CDT --- I've now done some additional testing. Without the hack I'm not able to start a new game. With the hack the games start but it look really ugly. I also did a test on a different machine with similar results.
Finally I did a test with the open source radeon driver and noticed something peculiar. The same shader (object #8) fails to compile even with the hack. The error message it generates are the following
error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
The generated shader is compiled as a fragment shader and as such according to the specification can't use any of the Lod functions. After taking a closer look at the shader I found that the shader also uses gl_FragCoord which is a strictly fragment shader variable.
The generated shader code therefore contains restricted elements of both a fragment shader and a vertex shader. Strictly speaking, it should be impossible to compile it on any compiler.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #15 from Henri Verbeet hverbeet@gmail.com 2011-07-04 17:30:06 CDT --- (In reply to comment #14)
Finally I did a test with the open source radeon driver and noticed something peculiar. The same shader (object #8) fails to compile even with the hack. The error message it generates are the following
error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
The generated shader is compiled as a fragment shader and as such according to the specification can't use any of the Lod functions.
Yes, but ARB_shader_texture_lod lifts that restriction. Which driver is that exactly? Current versions of r300g and r600g should support this.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #16 from Silver number048@gmail.com 2011-07-04 17:41:24 CDT --- (In reply to comment #15)
(In reply to comment #14)
Finally I did a test with the open source radeon driver and noticed something peculiar. The same shader (object #8) fails to compile even with the hack. The error message it generates are the following
error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
The generated shader is compiled as a fragment shader and as such according to the specification can't use any of the Lod functions.
Yes, but ARB_shader_texture_lod lifts that restriction. Which driver is that exactly? Current versions of r300g and r600g should support this.
r600g. Maybe my version is outdated. I haven't been able to compile a 32 bit version of mesa since r300 started to depend on the LLVM. Things would have been much easier if wine had been using the 64 bit version of the driver.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #17 from DL dredgingthelake@gmail.com 2011-07-04 18:50:04 CDT --- Created an attachment (id=35442) --> (http://bugs.winehq.org/attachment.cgi?id=35442) Vertex sampler limit = 8 with GLSL enabled
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #18 from Silver number048@gmail.com 2011-07-05 05:41:45 CDT --- (In reply to comment #16)
r600g. Maybe my version is outdated. I haven't been able to compile a 32 bit version of mesa since r300 started to depend on the LLVM. Things would have been much easier if wine had been using the 64 bit version of the driver.
As it turned out, when I updated to the latest Ubuntu version I forgot to re-insert some environment variables and was therefore still using parts of the default version.
Now I've updated my build procedure and removed some deprecated variables and was able to build an updated 32 bit version of mesa. The bad part is that I'm no longer able to test the shader compiler since the new git version almost immediately crashes my computer when I start this game.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #19 from DL dredgingthelake@gmail.com 2011-07-07 04:25:17 CDT --- Probably not related to this bug, but with the current GIT version, Witcher 2 fails to load with a black screen and this message:
shader.c:312: unsafe_impl_from_IDirect3DPixelShader9: Assertion `iface->lpVtbl == &d3d9_pixelshader_vtbl' failed.
I'll run a regression test and open a new bug report if it's unrelated.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #20 from DL dredgingthelake@gmail.com 2011-07-07 06:05:08 CDT --- (In reply to comment #19)
Probably not related to this bug, but with the current GIT version, Witcher 2 fails to load with a black screen and this message:
shader.c:312: unsafe_impl_from_IDirect3DPixelShader9: Assertion `iface->lpVtbl == &d3d9_pixelshader_vtbl' failed.
I'll run a regression test and open a new bug report if it's unrelated.
704f0efe0c931c12b0a6827467b949cac52b752c is the first bad commit commit 704f0efe0c931c12b0a6827467b949cac52b752c Author: Michael Stefaniuc mstefani@redhat.de Date: Tue Jul 5 12:03:20 2011 +0200
d3d9: Use unsafe_impl_from_IDirect3DPixelShader9 for an app provided iface.
:040000 040000 669e848c2d146d7c6718c079ba491ea1f5b6a80b b63020ed2098650c039c79db6c35d6e0810dfc19 M dlls
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #21 from Alex Bradbury asb@asbradbury.org 2011-07-07 06:10:42 CDT --- (In reply to comment #20)
I'll run a regression test and open a new bug report if it's unrelated.
704f0efe0c931c12b0a6827467b949cac52b752c is the first bad commit commit 704f0efe0c931c12b0a6827467b949cac52b752c Author: Michael Stefaniuc mstefani@redhat.de Date: Tue Jul 5 12:03:20 2011 +0200
d3d9: Use unsafe_impl_from_IDirect3DPixelShader9 for an app provided iface.
:040000 040000 669e848c2d146d7c6718c079ba491ea1f5b6a80b b63020ed2098650c039c79db6c35d6e0810dfc19 M dlls
Please open a new bug for this.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #22 from Henri Verbeet hverbeet@gmail.com 2011-07-07 06:30:39 CDT --- (In reply to comment #21)
Please open a new bug for this.
No, this is the same issue. The application creates a vertex shader, then tries to use it as pixel shader. It's just caught earlier now.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #23 from DL dredgingthelake@gmail.com 2011-07-07 06:32:12 CDT --- (In reply to comment #22)
(In reply to comment #21)
Please open a new bug for this.
No, this is the same issue. The application creates a vertex shader, then tries to use it as pixel shader. It's just caught earlier now.
Too late, already opened a new bug. Should have waited a bit longer.
Here it is so it can be closed: http://bugs.winehq.org/show_bug.cgi?id=27712
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #24 from Henri Verbeet hverbeet@gmail.com 2011-07-07 06:32:30 CDT --- *** Bug 27712 has been marked as a duplicate of this bug. ***
http://bugs.winehq.org/show_bug.cgi?id=27194
Marcel Unbehaun frostworks@gmx.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |frostworks@gmx.de
http://bugs.winehq.org/show_bug.cgi?id=27194
Jonathan Strander mblackwell1024@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mblackwell1024@gmail.com
--- Comment #25 from Jonathan Strander mblackwell1024@gmail.com 2011-07-19 20:40:16 CDT --- Unfortunately now because of the above commit the game no longer functions even with GLSL = disabled.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #26 from Jonathan Strander mblackwell1024@gmail.com 2011-07-20 18:22:41 CDT --- Still true in current git.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #27 from Jonathan Strander mblackwell1024@gmail.com 2011-07-31 11:19:38 CDT --- (In reply to comment #26)
Still true in current git.
Looking at dlls/d3d9/shader.c:
In "IDirect3DPixelShader9Impl *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface)" line 312 is:
assert(iface->lpVtbl == &d3d9_pixelshader_vtbl);
simply commenting out this line will allow you to run The Witcher 2 as before with GLSL disabled. Not a real fix, but I'm not familiar enough with Wine code to do much else. I was just tired of not being able to test the game at all with newer Wine builds.
http://bugs.winehq.org/show_bug.cgi?id=27194
Bully Bull bully@mailinator.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bully@mailinator.com
--- Comment #28 from Bully Bull bully@mailinator.com 2011-08-02 11:28:01 CDT --- @ Jonathan Strander
Your solution worked for me!
Thank you for your tip.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #29 from Matteo Bruni matteo.mystral@gmail.com 2011-08-30 10:11:13 CDT --- Created an attachment (id=36161) --> (http://bugs.winehq.org/attachment.cgi?id=36161) Refuse to create a vs from a ps source (and the other way around)
Some testing seems to show that the bad CreateVertexShader call should simply fail (presumably the game expects that). Can someone try this patch and report if it helps or not?
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #30 from Marcel Unbehaun frostworks@gmx.de 2011-08-30 11:05:05 CDT --- just built current master (wine-1.3.27-60-g49dc157) with your patch applied and witcher 2 is much faster than before (i.e. seems to be playable at least with medium details). thanks a lot for the patch! --- GeForce GTX 460 nvidia-drivers 275.09.07 gentoo ~x86 ---
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #31 from Jonathan Strander mblackwell1024@gmail.com 2011-08-30 19:55:28 CDT --- (In reply to comment #30)
just built current master (wine-1.3.27-60-g49dc157) with your patch applied and witcher 2 is much faster than before (i.e. seems to be playable at least with medium details). thanks a lot for the patch!
GeForce GTX 460 nvidia-drivers 275.09.07 gentoo ~x86
As far as speed:
http://bugs.winehq.org/show_bug.cgi?id=27298
I'm not using the above patch (just my hack above) and performance was improved with 1.3.27. Currently able to play at stock Ultra minus UberSampling (and Cinematic DOF since that caused a draw issue before and I wasn't testing it for this purpose) using 1600x1200 (when my new monitor arrives I'll try 1920x1200). Framerate is smooth/high to playable even in situations where it would previously be ridiculously slow no matter the setting.
Hardware is similar. Q9550@3.09ghz, EVGA GTX 460 768MB SuperClocked, and 4gig of ram.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #32 from Jonathan Strander mblackwell1024@gmail.com 2011-08-31 22:53:06 CDT ---
(In reply to comment #29)
Created an attachment (id=36161)
--> (http://bugs.winehq.org/attachment.cgi?id=36161) [details]
Refuse to create a vs from a ps source (and the other way around)
Some testing seems to show that the bad CreateVertexShader call should simply fail (presumably the game expects that). Can someone try this patch and report if it helps or not?
Tested this with GLSL enabled and had the same result as disabled. Nice work.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #33 from Silver number048@gmail.com 2011-09-03 12:08:14 CDT --- (In reply to comment #29)
Created an attachment (id=36161)
--> (http://bugs.winehq.org/attachment.cgi?id=36161) [details]
Refuse to create a vs from a ps source (and the other way around)
Some testing seems to show that the bad CreateVertexShader call should simply fail (presumably the game expects that). Can someone try this patch and report if it helps or not?
It helps!
The patch works for me although it seems like some other part of wine has regressed since last time I tried. The starting menu have weird names and the game no longer shows the dialogues.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #34 from Jonathan Strander mblackwell1024@gmail.com 2011-09-03 16:54:49 CDT --- (In reply to comment #33)
(In reply to comment #29)
Created an attachment (id=36161)
--> (http://bugs.winehq.org/attachment.cgi?id=36161) [details] [details]
Refuse to create a vs from a ps source (and the other way around)
Some testing seems to show that the bad CreateVertexShader call should simply fail (presumably the game expects that). Can someone try this patch and report if it helps or not?
It helps!
The patch works for me although it seems like some other part of wine has regressed since last time I tried. The starting menu have weird names and the game no longer shows the dialogues.
I tested against git yesterday and saw nothing of the sort... Everything was as-normal.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #35 from Silver number048@gmail.com 2011-09-03 18:41:56 CDT --- (In reply to comment #34)
(In reply to comment #33)
(In reply to comment #29)
Created an attachment (id=36161)
--> (http://bugs.winehq.org/attachment.cgi?id=36161) [details] [details] [details]
Refuse to create a vs from a ps source (and the other way around)
Some testing seems to show that the bad CreateVertexShader call should simply fail (presumably the game expects that). Can someone try this patch and report if it helps or not?
It helps!
The patch works for me although it seems like some other part of wine has regressed since last time I tried. The starting menu have weird names and the game no longer shows the dialogues.
I tested against git yesterday and saw nothing of the sort... Everything was as-normal.
I reinstalled the game, just in case, and now it works again.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #36 from Henri Verbeet hverbeet@gmail.com 2011-10-01 08:21:22 CDT --- Should be fixed by 2a146448f40686ff75f808557b15e95ff646601a.
http://bugs.winehq.org/show_bug.cgi?id=27194
--- Comment #37 from Jonathan Strander mblackwell1024@gmail.com 2011-10-02 22:07:36 CDT --- I say this is fixed as of latest git. There's a slight performance difference with Enabled vs Disabled but that has no bearing on the fact that graphically it's virtually flawless either way.
http://bugs.winehq.org/show_bug.cgi?id=27194
NickNill dmbohdan@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dmbohdan@gmail.com
--- Comment #38 from NickNill dmbohdan@gmail.com 2011-10-27 03:38:47 CDT --- Yes, it's work fine in last wine.
http://bugs.winehq.org/show_bug.cgi?id=27194
Jacek Caban jacek@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |2a146448f40686ff75f808557b1 | |5e95ff646601a Status|NEW |RESOLVED CC| |jacek@codeweavers.com Resolution| |FIXED
--- Comment #39 from Jacek Caban jacek@codeweavers.com 2011-10-27 05:52:53 CDT --- Reported fixed
http://bugs.winehq.org/show_bug.cgi?id=27194
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #40 from Alexandre Julliard julliard@winehq.org 2011-11-04 14:14:46 CDT --- Closing bugs fixed in 1.3.32.
http://bugs.winehq.org/show_bug.cgi?id=27194
Rico kgbricola@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |torbruvold@gmail.com
--- Comment #41 from Rico kgbricola@web.de 2012-08-10 05:36:19 CDT --- *** Bug 28527 has been marked as a duplicate of this bug. ***