Commit f6f90daa authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

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

parent 9069913d
......@@ -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
{
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment