From: Christian Costa titan.costa@gmail.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com ---
From staging. Do we know of any application affected by this?
dlls/d3dx9_36/tests/texture.c | 9 +++++++++ dlls/d3dx9_36/texture.c | 15 +++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 229c857ac2e..3416a3318b2 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/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/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 8708ed702fd..6ee7d72e38e 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
- +#include <assert.h> #include "d3dx9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx); @@ -337,13 +337,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);