From 69a02efd33ff8c4065c40e3c66ad52431cffc651 Mon Sep 17 00:00:00 2001 From: winesync Date: Wed, 5 Feb 2020 22:13:59 +0100 Subject: [PATCH] [WINESYNC] d3dx9_36: Align texture dimensions to block size for compressed textures in D3DXCheckTextureRequirements. wine-staging patch by Christian Costa --- dll/directx/wine/d3dx9_36/texture.c | 8 ++-- modules/rostests/winetests/d3dx9_36/texture.c | 10 +++++ ...tures_in_D3DXCheckTextureRequirements.diff | 40 +++++++++++++++++++ 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 sdk/tools/winesync/d3dx9_staging/0023-d3dx9_36__Align_texture_dimensions_to_block_size_for_compressed_textures_in_D3DXCheckTextureRequirements.diff diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c index 9f0e541cb61..552d02a30e9 100644 --- a/dll/directx/wine/d3dx9_36/texture.c +++ b/dll/directx/wine/d3dx9_36/texture.c @@ -335,10 +335,10 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN if (fmt->block_width != 1 || fmt->block_height != 1) { - if (w < fmt->block_width) - w = fmt->block_width; - if (h < fmt->block_height) - h = fmt->block_height; + if (w % fmt->block_width) + w += fmt->block_width - w % fmt->block_width; + if (h % fmt->block_height) + h += fmt->block_height - h % fmt->block_height; } if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w))) diff --git a/modules/rostests/winetests/d3dx9_36/texture.c b/modules/rostests/winetests/d3dx9_36/texture.c index 6c25a158118..98a9fc344db 100644 --- a/modules/rostests/winetests/d3dx9_36/texture.c +++ b/modules/rostests/winetests/d3dx9_36/texture.c @@ -400,6 +400,16 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device) ok(height == 4, "Returned height %d, expected %d\n", height, 4); ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1); ok(format == D3DFMT_DXT5, "Returned format %u, expected %u\n", format, D3DFMT_DXT5); + + format = D3DFMT_DXT5; + width = 5; height = 5; + mipmaps = 1; + hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 0, &format, D3DPOOL_DEFAULT); + ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK); + ok(width == 8, "Returned width %d, expected %d\n", width, 8); + ok(height == 8, "Returned height %d, expected %d\n", height, 8); + ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1); + ok(format == D3DFMT_DXT5, "Returned format %u, expected %u\n", format, D3DFMT_DXT5); } else { diff --git a/sdk/tools/winesync/d3dx9_staging/0023-d3dx9_36__Align_texture_dimensions_to_block_size_for_compressed_textures_in_D3DXCheckTextureRequirements.diff b/sdk/tools/winesync/d3dx9_staging/0023-d3dx9_36__Align_texture_dimensions_to_block_size_for_compressed_textures_in_D3DXCheckTextureRequirements.diff new file mode 100644 index 00000000000..07ae161b293 --- /dev/null +++ b/sdk/tools/winesync/d3dx9_staging/0023-d3dx9_36__Align_texture_dimensions_to_block_size_for_compressed_textures_in_D3DXCheckTextureRequirements.diff @@ -0,0 +1,40 @@ +diff --git a/modules/rostests/winetests/d3dx9_36/texture.c b/modules/rostests/winetests/d3dx9_36/texture.c +index 6c25a15..98a9fc3 100644 +--- a/modules/rostests/winetests/d3dx9_36/texture.c ++++ b/modules/rostests/winetests/d3dx9_36/texture.c +@@ -400,6 +400,16 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device) + ok(height == 4, "Returned height %d, expected %d\n", height, 4); + ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1); + ok(format == D3DFMT_DXT5, "Returned format %u, expected %u\n", format, D3DFMT_DXT5); ++ ++ format = D3DFMT_DXT5; ++ width = 5; height = 5; ++ mipmaps = 1; ++ hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 0, &format, D3DPOOL_DEFAULT); ++ ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK); ++ ok(width == 8, "Returned width %d, expected %d\n", width, 8); ++ ok(height == 8, "Returned height %d, expected %d\n", height, 8); ++ ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1); ++ ok(format == D3DFMT_DXT5, "Returned format %u, expected %u\n", format, D3DFMT_DXT5); + } + else + { +diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c +index 9f0e541..552d02a 100644 +--- a/dll/directx/wine/d3dx9_36/texture.c ++++ b/dll/directx/wine/d3dx9_36/texture.c +@@ -335,10 +335,10 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN + + if (fmt->block_width != 1 || fmt->block_height != 1) + { +- if (w < fmt->block_width) +- w = fmt->block_width; +- if (h < fmt->block_height) +- h = fmt->block_height; ++ if (w % fmt->block_width) ++ w += fmt->block_width - w % fmt->block_width; ++ if (h % fmt->block_height) ++ h += fmt->block_height - h % fmt->block_height; + } + + if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))