wined3d: Properly set the fog frag coord according to the FOGTABLEMODE.

This also fixes the test that an earlier patch broke, so the todo_wine can be
removed again.
This commit is contained in:
Stefan Dösinger 2009-01-10 02:29:39 +01:00 committed by Alexandre Julliard
parent 8dcd51286d
commit 693d9ded47
3 changed files with 21 additions and 13 deletions

View File

@ -1539,15 +1539,9 @@ static void fog_with_shader_test(IDirect3DDevice9 *device)
/* As the red and green component are the result of blending use 5% tolerance on the expected value */
color = getPixelColor(device, 128, 240);
if(test_data[i].vshader == 1 && test_data[i].tfog == 0 && color != test_data[i].color[j]) {
todo_wine ok(color_match(color, test_data[i].color[j], 13),
"fog vs%i ps%i fvm%i ftm%i %d: got color %08x, expected %08x +-5%%(todo)\n",
test_data[i].vshader, test_data[i].pshader, test_data[i].vfog, test_data[i].tfog, j, color, test_data[i].color[j]);
} else {
ok(color_match(color, test_data[i].color[j], 13),
"fog vs%i ps%i fvm%i ftm%i %d: got color %08x, expected %08x +-5%%\n",
test_data[i].vshader, test_data[i].pshader, test_data[i].vfog, test_data[i].tfog, j, color, test_data[i].color[j]);
}
ok(color_match(color, test_data[i].color[j], 13),
"fog vs%i ps%i fvm%i ftm%i %d: got color %08x, expected %08x +-5%%\n",
test_data[i].vshader, test_data[i].pshader, test_data[i].vfog, test_data[i].tfog, j, color, test_data[i].color[j]);
}
}

View File

@ -2068,9 +2068,16 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BU
/* Base Shader Body */
shader_generate_main( (IWineD3DBaseShader*) This, buffer, reg_maps, function);
/* If this shader doesn't use fog copy the z coord to the fog coord so that we can use table fog */
if (!reg_maps->fog)
/* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used
* or if the fragment depth is used. If the fragment depth is used(FOGTABLEMODE != NONE),
* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
if(args->fog_src == VS_FOG_Z) {
shader_addline(buffer, "MOV result.fogcoord, TMP_OUT.z;\n");
} else if (!reg_maps->fog) {
shader_addline(buffer, "MOV result.fogcoord, 0.0;\n");
}
/* Write the final position.
*

View File

@ -3912,9 +3912,16 @@ static GLuint shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_B
if (reg_maps->shader_version >= WINED3DVS_VERSION(3,0)) shader_addline(buffer, "order_ps_input(OUT);\n");
else shader_addline(buffer, "order_ps_input();\n");
/* If this shader doesn't use fog copy the z coord to the fog coord so that we can use table fog */
if (!reg_maps->fog)
/* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used
* or if the fragment depth is used. If the fragment depth is used(FOGTABLEMODE != NONE),
* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
if(args->fog_src == VS_FOG_Z) {
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z;\n");
} else if (!reg_maps->fog) {
shader_addline(buffer, "gl_FogFragCoord = 0.0;\n");
}
/* Write the final position.
*