[PATCH] WineD3D: Properly set the fog frag coord according to =

Stefan Doesinger stefan at codeweavers.com
Sat Jan 10 02:29:39 CST 2009


the FOGTABLEMODE=0A=
=0A=
This also fixes the test that an earlier patch broke, so the todo_wine =
can be=0A=
removed again=0A=
---=0A=
 dlls/d3d9/tests/visual.c          |   12 +++---------=0A=
 dlls/wined3d/arb_program_shader.c |   11 +++++++++--=0A=
 dlls/wined3d/glsl_shader.c        |   11 +++++++++--=0A=
 3 files changed, 21 insertions(+), 13 deletions(-)=0A=
=0A=
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c=0A=
index 2af17ac..ab43f2d 100644=0A=
--- a/dlls/d3d9/tests/visual.c=0A=
+++ b/dlls/d3d9/tests/visual.c=0A=
@@ -1536,15 +1536,9 @@ static void fog_with_shader_test(IDirect3DDevice9 =
*device)=0A=
 =0A=
             /* As the red and green component are the result of =
blending use 5% tolerance on the expected value */=0A=
             color =3D getPixelColor(device, 128, 240);=0A=
-            if(test_data[i].vshader =3D=3D 1 && test_data[i].tfog =
=3D=3D 0 && color !=3D test_data[i].color[j]) {=0A=
-                todo_wine ok(color_match(color, test_data[i].color[j], =
13),=0A=
-                             "fog vs%i ps%i fvm%i ftm%i %d: got color =
%08x, expected %08x +-5%%(todo)\n",=0A=
-                             test_data[i].vshader, =
test_data[i].pshader, test_data[i].vfog, test_data[i].tfog, j, color, =
test_data[i].color[j]);=0A=
-            } else {=0A=
-                ok(color_match(color, test_data[i].color[j], 13),=0A=
-                   "fog vs%i ps%i fvm%i ftm%i %d: got color %08x, =
expected %08x +-5%%\n",=0A=
-                   test_data[i].vshader, test_data[i].pshader, =
test_data[i].vfog, test_data[i].tfog, j, color, test_data[i].color[j]);=0A=
-            }=0A=
+            ok(color_match(color, test_data[i].color[j], 13),=0A=
+                "fog vs%i ps%i fvm%i ftm%i %d: got color %08x, expected =
%08x +-5%%\n",=0A=
+                test_data[i].vshader, test_data[i].pshader, =
test_data[i].vfog, test_data[i].tfog, j, color, test_data[i].color[j]);=0A=
         }=0A=
     }=0A=
 =0A=
diff --git a/dlls/wined3d/arb_program_shader.c =
b/dlls/wined3d/arb_program_shader.c=0A=
index 898f2cb..f671de1 100644=0A=
--- a/dlls/wined3d/arb_program_shader.c=0A=
+++ b/dlls/wined3d/arb_program_shader.c=0A=
@@ -2066,9 +2066,16 @@ static GLuint =
shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BU=0A=
     /* Base Shader Body */=0A=
     shader_generate_main( (IWineD3DBaseShader*) This, buffer, reg_maps, =
function);=0A=
 =0A=
-    /* If this shader doesn't use fog copy the z coord to the fog coord =
so that we can use table fog */=0A=
-    if (!reg_maps->fog)=0A=
+    /* The D3DRS_FOGTABLEMODE render state defines if the =
shader-generated fog coord is used=0A=
+     * or if the fragment depth is used. If the fragment depth is =
used(FOGTABLEMODE !=3D NONE),=0A=
+     * the fog frag coord is thrown away. If the fog frag coord is =
used, but not written by=0A=
+     * the shader, it is set to 0.0(fully fogged, since start =3D 1.0, =
end =3D 0.0)=0A=
+     */=0A=
+    if(args->fog_src =3D=3D VS_FOG_Z) {=0A=
         shader_addline(buffer, "MOV result.fogcoord, TMP_OUT.z;\n");=0A=
+    } else if (!reg_maps->fog) {=0A=
+        shader_addline(buffer, "MOV result.fogcoord, 0.0;\n");=0A=
+    }=0A=
 =0A=
     /* Write the final position.=0A=
      *=0A=
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c=0A=
index 5b5827d..199e2ae 100644=0A=
--- a/dlls/wined3d/glsl_shader.c=0A=
+++ b/dlls/wined3d/glsl_shader.c=0A=
@@ -3910,9 +3910,16 @@ static GLuint =
shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_B=0A=
     if (reg_maps->shader_version >=3D WINED3DVS_VERSION(3,0)) =
shader_addline(buffer, "order_ps_input(OUT);\n");=0A=
     else shader_addline(buffer, "order_ps_input();\n");=0A=
 =0A=
-    /* If this shader doesn't use fog copy the z coord to the fog coord =
so that we can use table fog */=0A=
-    if (!reg_maps->fog)=0A=
+    /* The D3DRS_FOGTABLEMODE render state defines if the =
shader-generated fog coord is used=0A=
+     * or if the fragment depth is used. If the fragment depth is =
used(FOGTABLEMODE !=3D NONE),=0A=
+     * the fog frag coord is thrown away. If the fog frag coord is =
used, but not written by=0A=
+     * the shader, it is set to 0.0(fully fogged, since start =3D 1.0, =
end =3D 0.0)=0A=
+     */=0A=
+    if(args->fog_src =3D=3D VS_FOG_Z) {=0A=
         shader_addline(buffer, "gl_FogFragCoord =3D gl_Position.z;\n");=0A=
+    } else if (!reg_maps->fog) {=0A=
+        shader_addline(buffer, "gl_FogFragCoord =3D 0.0;\n");=0A=
+    }=0A=
 =0A=
     /* Write the final position.=0A=
      *=0A=
-- =0A=
1.6.0.6=0A=
=0A=

------=_NextPart_000_00FC_01C97A2B.ECCE5F60--




More information about the wine-patches mailing list