2014-11-06 21:51 GMT+01:00 Joachim Priesner <joachim.priesner(a)web.de>:
> Take the absolute value of vertex.z as fog coordinate instead of just
> the z coordinate. This fixes e.g. fog for applications that use
> right-handed projection matrices.
>
> Also test the clamp behavior of the oFog vertex shader output.
>
> Tested on openSuse 13.1 and Windows 8.1 (VMware Player).
>
> Try 5 that fixes a test failure I overlooked.
> ---
> dlls/d3d8/tests/visual.c | 296 +++++++++++++++++++++++++++++++++++++
> dlls/d3d9/tests/visual.c | 360 +++++++++++++++++++++++++++++++++++++++++++++
> dlls/ddraw/tests/ddraw7.c | 161 ++++++++++++++++++++
> dlls/wined3d/glsl_shader.c | 2 +-
> 4 files changed, 818 insertions(+), 1 deletion(-)
>
> diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
> index 163110c..a1eabcd 100644
> --- a/dlls/d3d8/tests/visual.c
> +++ b/dlls/d3d8/tests/visual.c
> @@ -696,6 +696,301 @@ done:
> DestroyWindow(window);
> }
>
> +/* This test tests fog in combination with negative vertex z coordinates. */
> +static void fog_negative_z_test(void)
> +{
> + enum
> + {
> + C_ALPHA_0x00 = 0x00000000,
> + C_CLEAR = 0xffff00ff,
> + C_FOGGED = 0x0000ff00,
> + C_HALF_FOGGED = 0x00808000,
> + C_UNFOGGED = 0x00ff0000,
> + C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
> + };
> +
> + /* Fill the null-shader entry with the FVF (SetVertexShader is "overloaded" on d3d8). */
> + DWORD vertex_shader[3] = {D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, 0, 0};
> + DWORD pixel_shader[2] = {0, 0};
> + IDirect3D8 *d3d;
> + IDirect3DDevice8 *device;
> + BOOL has_vs_support, has_ps_support, has_table_fog_support;
> + unsigned int i, ps, y;
> + D3DCOLOR color, expected_middle_color;
> + ULONG refcount;
> + D3DCAPS8 caps;
> + HWND window;
> + HRESULT hr;
> +
> + /* Basic vertex shader without fog computation ("non foggy") */
> + static const DWORD vertex_shader_code1[] =
> + {
> + 0xfffe0100, /* vs_1_0 */
> + /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
> + 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
> + 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
> + /* output.Pos.xyw = input.Pos.xyw */
> + 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
> + /* output.Color = input.Color */
> + 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
> + 0x0000ffff, /* END */
> + };
Where are you setting the value of c0 in the d3d8 test?