http://bugs.winehq.org/show_bug.cgi?id=15786
Summary: FEAR 1.08: GL errors in D3D8 mode Product: Wine Version: 1.1.7 Platform: PC-x86-64 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3d AssignedTo: wine-bugs@winehq.org ReportedBy: liquid.acid@gmx.net CC: hverbeet@gmail.com
Hardware: NV35 Driver: nvidia-drivers-173.14.12-r1
The game is set up to use DX8 shaders.
The issue: Lots of GL errors on the console:. fixme:d3d_shader:shader_glsl_select >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from glUseProgramObjectARB @ glsl_shader.c / 3501
I can confirm that INVALID_OPERATION is really produced by glUseProgramObjectARB and not by some GL call before it.
The reason why the call fails is this error that appears earlier: fixme:d3d_shader:print_glsl_info_log Error received from GLSL shader #184: "(21) : error C7011: implicit cast from "vec4" to "vec3"\n"
I extracted the GLSL shader source of the faulty program: #version 120 #extension GL_ARB_texture_rectangle : enable uniform vec4 PC[8]; uniform sampler2D Psampler0; uniform sampler2D Psampler1; uniform sampler2D Psampler2; uniform samplerCube Psampler3; vec4 T0 = gl_TexCoord[0]; vec4 T1 = gl_TexCoord[1]; vec4 T2 = gl_TexCoord[2]; vec4 T3 = gl_TexCoord[3]; vec4 R0; vec4 R1; vec4 tmp0; vec4 tmp1; uniform vec4 PLC1; void main() { T0.xyzw = (texture2D(Psampler0, T0.xy).xyzw); T1.xyzw = (texture2D(Psampler1, T1.xy).xyzw); T2.xyzw = (texture2DProj(Psampler2, T2.xyw).xyzw); T3.xyzw = (textureCube(Psampler3, T3.xyzw).xyzw); R0.xyzw = (vec4(dot((2.0 * (T1.xyz - 0.5)), (2.0 * (T3.xyz - 0.5))))); R0.xyzw = clamp(R0.xyzw, 0.0, 1.0); R0.w = (R0.w * R0.w); R0.w = (R0.w * R0.w); R1.xyz = (T2.www * PC[0].xyz); R0.w = (R0.w * R0.w); R1.xyz = (T0.xyz * R1.xyz); R0.xyz = (R0.www * R1.xyz); R0.w = (PLC1.w); gl_FragColor = R0; float Fog = clamp(gl_FogFragCoord * gl_Fog.start + gl_Fog.end, 0.0, 1.0); gl_FragColor.xyz = mix(gl_Fog.color.xyz, gl_FragColor.xyz, Fog); } ----------------------------------------------------------------------------
Like the GLSL compiler already reports, the issue is in line 21: T3.xyzw = (textureCube(Psampler3, T3.xyzw).xyzw);
textureCube expects a vec3 type as second parameter.
The problem seems to originate from pshader_glsl_tex (in glsl_shader.c) where the GLSL source is constructed.
Checking the content of mask before mask |= sample_function.coord_mask; reveals that the shader compilation only fails when mask is non-zero (at least in my case). So if it fails it always has a hex value of 80000.
shader_glsl_get_sample_function works correctly.
The WINED3DSP_WRITEMASK_3 mask is set in the "hex_version < WINED3DPS_VERSION(1,4)" if-branch, through the WINED3DTTFF_DISABLE case.
With the help of Roderick I found the original D3D asm: ps_1_1 //CTAB def c1 = 0.000000, 0.000000, 0.000000, 1.000000 tex t0 tex t1 tex t2 tex t3 dp3_sat r0, t1_bx2, t3_bx2 mul r0.a, r0.a, r0.a mul r0.a, r0.a, r0.a +mul r1.rgb, t2.a, c0 mul r0.a, r0.a, r0.a +mul r1.rgb, t0, r1 mul r0.rgb, r0.a, r1 +mov r0.a, c1.a ----------------------------------------------------------------------------
He suspects that the issue originates from dp3_sat.
Adding a "if (sampler_type == WINED3DSTT_CUBE) maks=0;" before "mask |= sample_function.coord_mask;" fixes the compilation error and also the GL errors for me.
Adding Henri Verbeet to CC since he designed this part of the code (according to Stefan Dösinger).
Greets, Tobias
http://bugs.winehq.org/show_bug.cgi?id=15786
--- Comment #1 from Tobias Jakobi liquid.acid@gmx.net 2008-10-26 11:33:46 --- Created an attachment (id=16903) --> (http://bugs.winehq.org/attachment.cgi?id=16903) [wined3d] hack to remove GLSL compilation errors for FEAR DX8 shaders
also adds some debugging code to dump GLSL shaders, nothing spectacular...
http://bugs.winehq.org/show_bug.cgi?id=15786
--- Comment #2 from Tobias Jakobi liquid.acid@gmx.net 2008-10-26 11:34:31 --- @Austin: Again, this is no patch BUT a dirty dirty hack, so no keyword please :)
http://bugs.winehq.org/show_bug.cgi?id=15786
--- Comment #3 from H. Verbeet hverbeet@gmail.com 2008-10-26 17:16:57 --- Created an attachment (id=16910) --> (http://bugs.winehq.org/attachment.cgi?id=16910) patch
How does this work? Your hack is essentially correct, in that it doesn't make sense to project cube textures. Dividing by the 4th coordinate would make no difference, since the coordinates are divided by the major axis value before being used.
http://bugs.winehq.org/show_bug.cgi?id=15786
H. Verbeet hverbeet@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC|hverbeet@gmail.com |
http://bugs.winehq.org/show_bug.cgi?id=15786
--- Comment #4 from Austin English austinenglish@gmail.com 2008-10-26 20:50:27 --- (In reply to comment #2)
@Austin: Again, this is no patch BUT a dirty dirty hack, so no keyword please :)
I would disagree. It may be a hack, but it at least gives the direction of where a proper fix should be. But since you think it's THAT dirty, I won't ;-).
http://bugs.winehq.org/show_bug.cgi?id=15786
Tobias Jakobi liquid.acid@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch
--- Comment #5 from Tobias Jakobi liquid.acid@gmx.net 2008-10-27 05:06:06 --- (In reply to comment #4)
I would disagree. It may be a hack, but it at least gives the direction of where a proper fix should be. But since you think it's THAT dirty, I won't ;-).
Nah, I'm still learning this whole shader thing. I wouldn't consider any of my code a patch... :)
@Henri: Yep, it works. Fixes compilation in GLSL mode. Also checked ARB but the issue doesn't seem to exist there.
Adding patch to keywords since we got the 'real' thing now :)
http://bugs.winehq.org/show_bug.cgi?id=15786
Jan Buecken jb.faq@gmx.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jb.faq@gmx.de
http://bugs.winehq.org/show_bug.cgi?id=15786
Tobias Jakobi liquid.acid@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED
--- Comment #6 from Tobias Jakobi liquid.acid@gmx.net 2008-10-30 17:43:02 --- Henri's patch is now in git master.
Rechecked with a fresh compile and the GL errors are gone. Resolving to FIXED.
http://bugs.winehq.org/show_bug.cgi?id=15786
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #7 from Alexandre Julliard julliard@winehq.org 2008-11-07 10:47:08 --- Closing bugs fixed in 1.1.8.