https://git.reactos.org/?p=reactos.git;a=commitdiff;h=03f8174d97a60faa02f25629e3e25edecc61bb4a

commit 03f8174d97a60faa02f25629e3e25edecc61bb4a
Author:     winesync <[email protected]>
AuthorDate: Mon Sep 21 23:00:51 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Thu Feb 4 16:37:04 2021 +0100

    [WINESYNC] d3dx9: Correctly align texture dimensions to block size in 
D3DXCheckTextureRequirements().
    
    Signed-off-by: Matteo Bruni <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id f6f90daa3117cf493e0815c42bb0fa1740d31308 by Christian Costa 
<[email protected]>
---
 dll/directx/wine/d3dx9_36/texture.c           | 15 +++++++--------
 modules/rostests/winetests/d3dx9_36/texture.c |  9 +++++++++
 sdk/tools/winesync/d3dx9.cfg                  |  2 +-
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/dll/directx/wine/d3dx9_36/texture.c 
b/dll/directx/wine/d3dx9_36/texture.c
index c42ae7eb1c1..07d5dbabca8 100644
--- a/dll/directx/wine/d3dx9_36/texture.c
+++ b/dll/directx/wine/d3dx9_36/texture.c
@@ -22,7 +22,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-
+#include <assert.h>
 #include "d3dx9_private.h"
 #endif /* __REACTOS__ */
 
@@ -341,13 +341,12 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct 
IDirect3DDevice9 *device, UIN
     else if (h == D3DX_DEFAULT)
         h = (width ? w : 256);
 
-    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;
-    }
+    assert(!(fmt->block_width & (fmt->block_width - 1)));
+    assert(!(fmt->block_height & (fmt->block_height - 1)));
+    if (w & (fmt->block_width - 1))
+        w = (w + fmt->block_width) & ~(fmt->block_width - 1);
+    if (h & (fmt->block_height - 1))
+        h = (h + fmt->block_height) & ~(fmt->block_height - 1);
 
     if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
         w = make_pow2(w);
diff --git a/modules/rostests/winetests/d3dx9_36/texture.c 
b/modules/rostests/winetests/d3dx9_36/texture.c
index 229c857ac2e..3416a3318b2 100644
--- a/modules/rostests/winetests/d3dx9_36/texture.c
+++ b/modules/rostests/winetests/d3dx9_36/texture.c
@@ -448,6 +448,15 @@ static void 
test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
         ok(width == 4, "Got unexpected width %d.\n", width);
         ok(height == 4, "Got unexpected height %d.\n", height);
         ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
+
+        width = 9;
+        height = 9;
+        hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 
0, &format, D3DPOOL_DEFAULT);
+        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(width == 12, "Got unexpected width %u.\n", width);
+        ok(height == 12, "Got unexpected height %u.\n", height);
+        ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
+        ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
     }
     else
     {
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index e3f20fc947c..35f8e8fc7e2 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, 
include/d3dx9anim.h: sdk/inc
   include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: 
sdk/include/dxsdk/d3dx9of.h,
   include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, 
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h,
   include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: 
sdk/include/dxsdk/d3dx9xof.h}
-tags: {wine: 9069913dbba0914b80544ce4afb9e7285efad2a5}
+tags: {wine: f6f90daa3117cf493e0815c42bb0fa1740d31308}

Reply via email to