[WINESYNC] d3dx9_36: Align texture dimensions to block size for compressed textures in D3DXCheckTextureRequirements.

wine-staging patch by Christian Costa <titan.costa@gmail.com>
This commit is contained in:
winesync 2020-02-05 22:13:59 +01:00 committed by Jérôme Gardou
parent b7a4b73b65
commit 69a02efd33
3 changed files with 54 additions and 4 deletions

View file

@ -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)))

View file

@ -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
{

View file

@ -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)))