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>
This commit is contained in:
parent
9069913dbb
commit
f6f90daa31
|
@ -448,6 +448,15 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
|
||||||
ok(width == 4, "Got unexpected width %d.\n", width);
|
ok(width == 4, "Got unexpected width %d.\n", width);
|
||||||
ok(height == 4, "Got unexpected height %d.\n", height);
|
ok(height == 4, "Got unexpected height %d.\n", height);
|
||||||
ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include "d3dx9_private.h"
|
#include "d3dx9_private.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
|
||||||
|
@ -337,13 +337,12 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN
|
||||||
else if (h == D3DX_DEFAULT)
|
else if (h == D3DX_DEFAULT)
|
||||||
h = (width ? w : 256);
|
h = (width ? w : 256);
|
||||||
|
|
||||||
if (fmt->block_width != 1 || fmt->block_height != 1)
|
assert(!(fmt->block_width & (fmt->block_width - 1)));
|
||||||
{
|
assert(!(fmt->block_height & (fmt->block_height - 1)));
|
||||||
if (w < fmt->block_width)
|
if (w & (fmt->block_width - 1))
|
||||||
w = fmt->block_width;
|
w = (w + fmt->block_width) & ~(fmt->block_width - 1);
|
||||||
if (h < fmt->block_height)
|
if (h & (fmt->block_height - 1))
|
||||||
h = fmt->block_height;
|
h = (h + fmt->block_height) & ~(fmt->block_height - 1);
|
||||||
}
|
|
||||||
|
|
||||||
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
|
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
|
||||||
w = make_pow2(w);
|
w = make_pow2(w);
|
||||||
|
|
Loading…
Reference in New Issue