[WINESYNC] d3dx9: Correctly align texture dimensions to block size in D3DXCheckTextureRequirements().

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id f6f90daa3117cf493e0815c42bb0fa1740d31308 by Christian Costa <titan.costa@gmail.com>
This commit is contained in:
winesync 2020-09-21 23:00:51 +02:00 committed by Jérôme Gardou
parent d2eac4cdbf
commit 03f8174d97
3 changed files with 17 additions and 9 deletions

View file

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

View file

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

View file

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