[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: [PATCH 2/2] ddraw/tests: Add pitch alignment tests (try 2)
From:       Stefan =?ISO-8859-1?Q?D=F6singer?= <stefan () codeweavers ! com>
Date:       2012-02-27 12:16:29
Message-ID: 190053977.Acjgb4g6Xk () macbookpro
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Please ignore this patch for now, it looks like 64 bit ddraw.dll behaves 
differently. It probably doesn't matter for real games, since they're all 32 
bit, but I'll have to investigate this closer.
Am Montag, 27. Februar 2012, 12:11:16 schrieb Stefan Dösinger:
> This patch is a side product of my attempts to debug bug 21238. It
> confirms that the 8 byte aligned pitches are correct for all pools.
> 
> try 2: Don't fail and crash if video memory surfaces are not available
> ---
>  dlls/ddraw/tests/ddraw1.c |   77 ++++++++++++++++++++++++++++++++++++++++++
> dlls/ddraw/tests/ddraw2.c |   81
> ++++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw4.c |  
> 82 +++++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw7.c
> |   82 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 322
> insertions(+), 0 deletions(-)
> 
> diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
> index 5d0d6da..8fa813b 100644
> --- a/dlls/ddraw/tests/ddraw1.c
> +++ b/dlls/ddraw/tests/ddraw1.c
> @@ -1121,6 +1121,82 @@ static void test_zenable(void)
>      DestroyWindow(window);
>  }
> 
> +static void test_pitch_alignment(void)
> +{
> +    IDirectDraw *ddraw;
> +    IDirectDrawSurface *surface;
> +    HRESULT hr;
> +    static const struct
> +    {
> +        DWORD caps;
> +        UINT align;
> +        LONG pitch;
> +        const char *name;
> +    }
> +    pools[] =
> +    {
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY,
> +            8, 0, "D3DPOOL_DEFAULT"
> +        },
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
> +            8, 16, "D3DPOOL_SYSTEMMEM"
> +        },
> +    };
> +    unsigned int i;
> +    DDSURFACEDESC ddsd;
> +
> +    if (!(ddraw = create_ddraw()))
> +    {
> +        skip("Failed to create a ddraw object, skipping test.\n");
> +        return;
> +    }
> +
> +    hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
> +    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
> +
> +    for (i = 0; i < (sizeof(pools) / sizeof(*pools)); i++)
> +    {
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT |
> DDSD_PIXELFORMAT; +        ddsd.dwWidth = 5;
> +        ddsd.dwHeight = 5;
> +        ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
> +        ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
> +        U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 16;
> +        U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xF800;
> +        U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x07E0;
> +        U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001F;
> +        ddsd.ddsCaps.dwCaps = pools[i].caps;
> +
> +        hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
> +        ok(SUCCEEDED(hr) || hr == DDERR_UNSUPPORTEDFORMAT || hr ==
> DDERR_NODIRECTDRAWHW, +                "%s: Failed to create surface, hr
> %#x.\n", pools[i].name, hr); +        if (!surface)
> +        {
> +            skip("%s: Failed to create surface, skipping pitch alignment
> test\n", pools[i].name); +            continue;
> +        }
> +
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
> +        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
> +
> +        ok(!(ddsd.lPitch & (pools[i].align - 1)), "%s: Pitch %d is not %u
> byte aligned.\n", +                pools[i].name, ddsd.lPitch,
> pools[i].align);
> +        if (pools[i].pitch)
> +            ok(ddsd.lPitch == pools[i].pitch, "%s: Expected pitch %d, got
> %d.\n", +                    pools[i].name, pools[i].pitch, ddsd.lPitch);
> +
> +        IDirectDrawSurface_Release(surface);
> +    }
> +
> +    IDirectDraw_Release(ddraw);
> +}
> +
>  START_TEST(ddraw1)
>  {
>      test_coop_level_create_device_window();
> @@ -1130,4 +1206,5 @@ START_TEST(ddraw1)
>      test_coop_level_threaded();
>      test_viewport_interfaces();
>      test_zenable();
> +    test_pitch_alignment();
>  }
> diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
> index ba8d3b6..348cbfc 100644
> --- a/dlls/ddraw/tests/ddraw2.c
> +++ b/dlls/ddraw/tests/ddraw2.c
> @@ -1383,6 +1383,86 @@ static void test_zenable(void)
>      DestroyWindow(window);
>  }
> 
> +static void test_pitch_alignment(void)
> +{
> +    IDirectDraw2 *ddraw;
> +    IDirectDrawSurface *surface1;
> +    IDirectDrawSurface2 *surface;
> +    HRESULT hr;
> +    static const struct
> +    {
> +        DWORD caps;
> +        UINT align;
> +        LONG pitch;
> +        const char *name;
> +    }
> +    pools[] =
> +    {
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY,
> +            8, 0, "D3DPOOL_DEFAULT"
> +        },
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
> +            8, 16, "D3DPOOL_SYSTEMMEM"
> +        },
> +    };
> +    unsigned int i;
> +    DDSURFACEDESC ddsd;
> +
> +    if (!(ddraw = create_ddraw()))
> +    {
> +        skip("Failed to create a ddraw object, skipping test.\n");
> +        return;
> +    }
> +
> +    hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
> +    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
> +
> +    for (i = 0; i < (sizeof(pools) / sizeof(*pools)); i++)
> +    {
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT |
> DDSD_PIXELFORMAT; +        ddsd.dwWidth = 5;
> +        ddsd.dwHeight = 5;
> +        ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
> +        ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
> +        U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 16;
> +        U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xF800;
> +        U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x07E0;
> +        U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001F;
> +        ddsd.ddsCaps.dwCaps = pools[i].caps;
> +
> +        hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface1, NULL);
> +        ok(SUCCEEDED(hr) || hr == DDERR_UNSUPPORTEDFORMAT || hr ==
> DDERR_NODIRECTDRAWHW, +                "%s: Failed to create surface, hr
> %#x.\n", pools[i].name, hr); +        if (!surface1)
> +        {
> +            skip("%s: Failed to create surface, skipping pitch alignment
> test\n", pools[i].name); +            continue;
> +        }
> +        hr = IDirectDrawSurface_QueryInterface(surface1,
> &IID_IDirectDrawSurface2, (void **) &surface); +        ok(SUCCEEDED(hr),
> "%s: Failed to get DirectDrawSurace2 interface, hr %#x.\n", pools[i].name,
> hr); +        IDirectDrawSurface_Release(surface1);
> +
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        hr = IDirectDrawSurface2_GetSurfaceDesc(surface, &ddsd);
> +        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
> +
> +        ok(!(ddsd.lPitch & (pools[i].align - 1)), "%s: Pitch %d is not %u
> byte aligned.\n", +                pools[i].name, ddsd.lPitch,
> pools[i].align);
> +        if (pools[i].pitch)
> +            ok(ddsd.lPitch == pools[i].pitch, "%s: Expected pitch %d, got
> %d.\n", +                    pools[i].name, pools[i].pitch, ddsd.lPitch);
> +
> +        IDirectDrawSurface2_Release(surface);
> +    }
> +
> +    IDirectDraw2_Release(ddraw);
> +}
> +
>  START_TEST(ddraw2)
>  {
>      test_coop_level_create_device_window();
> @@ -1394,4 +1474,5 @@ START_TEST(ddraw2)
>      test_texture_load_ckey();
>      test_viewport_interfaces();
>      test_zenable();
> +    test_pitch_alignment();
>  }
> diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
> index d9ed90d..c19ba3a 100644
> --- a/dlls/ddraw/tests/ddraw4.c
> +++ b/dlls/ddraw/tests/ddraw4.c
> @@ -1490,6 +1490,87 @@ static void test_zenable(void)
>      DestroyWindow(window);
>  }
> 
> +static void test_pitch_alignment(void)
> +{
> +    IDirectDraw4 *ddraw;
> +    IDirectDrawSurface4 *surface;
> +    HRESULT hr;
> +    static const struct
> +    {
> +        DWORD caps, caps2;
> +        UINT align;
> +        LONG pitch;
> +        const char *name;
> +    }
> +    pools[] =
> +    {
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY, 0,
> +            8, 0, "D3DPOOL_DEFAULT"
> +        },
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY, 0,
> +            8, 16, "D3DPOOL_SYSTEMMEM"
> +        },
> +        {
> +            DDSCAPS_TEXTURE, DDSCAPS2_TEXTUREMANAGE,
> +            8, 16, "D3DPOOL_MANAGED"
> +        }
> +    };
> +    unsigned int i;
> +    DDSURFACEDESC2 ddsd;
> +
> +    if (!(ddraw = create_ddraw()))
> +    {
> +        skip("Failed to create a ddraw object, skipping test.\n");
> +        return;
> +    }
> +
> +    hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
> +    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
> +
> +    for (i = 0; i < (sizeof(pools) / sizeof(*pools)); i++)
> +    {
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT |
> DDSD_PIXELFORMAT; +        ddsd.dwWidth = 5;
> +        ddsd.dwHeight = 5;
> +        U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
> +        U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_RGB;
> +        U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount = 16;
> +        U2(U4(ddsd).ddpfPixelFormat).dwRBitMask = 0xF800;
> +        U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x07E0;
> +        U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x001F;
> +        ddsd.ddsCaps.dwCaps = pools[i].caps;
> +        ddsd.ddsCaps.dwCaps2 = pools[i].caps2;
> +
> +        hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
> +        ok(SUCCEEDED(hr) || hr == DDERR_UNSUPPORTEDFORMAT || hr ==
> DDERR_NODIRECTDRAWHW, +                "%s: Failed to create surface, hr
> %#x.\n", pools[i].name, hr); +        if (!surface)
> +        {
> +            skip("%s: Failed to create surface, skipping pitch alignment
> test\n", pools[i].name); +            continue;
> +        }
> +
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
> +        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
> +
> +        ok(!(ddsd.lPitch & (pools[i].align - 1)), "%s: Pitch %d is not %u
> byte aligned.\n", +                pools[i].name, ddsd.lPitch,
> pools[i].align);
> +        if (pools[i].pitch)
> +            ok(ddsd.lPitch == pools[i].pitch, "%s: Expected pitch %d, got
> %d.\n", +                    pools[i].name, pools[i].pitch, ddsd.lPitch);
> +
> +        IDirectDrawSurface4_Release(surface);
> +    }
> +
> +    IDirectDraw4_Release(ddraw);
> +}
> +
>  START_TEST(ddraw4)
>  {
>      test_process_vertices();
> @@ -1502,4 +1583,5 @@ START_TEST(ddraw4)
>      test_texture_load_ckey();
>      test_viewport_interfaces();
>      test_zenable();
> +    test_pitch_alignment();
>  }
> diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
> index 2ea77fe..4425ad4 100644
> --- a/dlls/ddraw/tests/ddraw7.c
> +++ b/dlls/ddraw/tests/ddraw7.c
> @@ -1277,6 +1277,87 @@ static void test_zenable(void)
>      DestroyWindow(window);
>  }
> 
> +static void test_pitch_alignment(void)
> +{
> +    IDirectDraw7 *ddraw;
> +    IDirectDrawSurface7 *surface;
> +    HRESULT hr;
> +    static const struct
> +    {
> +        DWORD caps, caps2;
> +        UINT align;
> +        LONG pitch;
> +        const char *name;
> +    }
> +    pools[] =
> +    {
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY, 0,
> +            8, 0, "D3DPOOL_DEFAULT"
> +        },
> +        {
> +            DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY, 0,
> +            8, 16, "D3DPOOL_SYSTEMMEM"
> +        },
> +        {
> +            DDSCAPS_TEXTURE, DDSCAPS2_TEXTUREMANAGE,
> +            8, 16, "D3DPOOL_MANAGED"
> +        }
> +    };
> +    unsigned int i;
> +    DDSURFACEDESC2 ddsd;
> +
> +    if (!(ddraw = create_ddraw()))
> +    {
> +        skip("Failed to create a ddraw object, skipping test.\n");
> +        return;
> +    }
> +
> +    hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
> +    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
> +
> +    for (i = 0; i < (sizeof(pools) / sizeof(*pools)); i++)
> +    {
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT |
> DDSD_PIXELFORMAT; +        ddsd.dwWidth = 5;
> +        ddsd.dwHeight = 5;
> +        U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
> +        U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_RGB;
> +        U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount = 16;
> +        U2(U4(ddsd).ddpfPixelFormat).dwRBitMask = 0xF800;
> +        U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x07E0;
> +        U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x001F;
> +        ddsd.ddsCaps.dwCaps = pools[i].caps;
> +        ddsd.ddsCaps.dwCaps2 = pools[i].caps2;
> +
> +        hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
> +        ok(SUCCEEDED(hr) || hr == DDERR_UNSUPPORTEDFORMAT || hr ==
> DDERR_NODIRECTDRAWHW, +                "%s: Failed to create surface, hr
> %#x.\n", pools[i].name, hr); +        if (!surface)
> +        {
> +            skip("%s: Failed to create surface, skipping pitch alignment
> test\n", pools[i].name); +            continue;
> +        }
> +
> +        memset(&ddsd, 0, sizeof(ddsd));
> +        ddsd.dwSize = sizeof(ddsd);
> +        hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
> +        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
> +
> +        ok(!(ddsd.lPitch & (pools[i].align - 1)), "%s: Pitch %d is not %u
> byte aligned.\n", +                pools[i].name, ddsd.lPitch,
> pools[i].align);
> +        if (pools[i].pitch)
> +            ok(ddsd.lPitch == pools[i].pitch, "%s: Expected pitch %d, got
> %d.\n", +                    pools[i].name, pools[i].pitch, ddsd.lPitch);
> +
> +        IDirectDrawSurface7_Release(surface);
> +    }
> +
> +    IDirectDraw7_Release(ddraw);
> +}
> +
>  START_TEST(ddraw7)
>  {
>      HMODULE module = GetModuleHandleA("ddraw.dll");
> @@ -1296,4 +1377,5 @@ START_TEST(ddraw7)
>      test_depth_blit();
>      test_texture_load_ckey();
>      test_zenable();
> +    test_pitch_alignment();
>  }
["signature.asc" (application/pgp-signature)]



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic