=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3dx9: Correctly check if a texture is dynamic in D3DXCreateTextureFromFileInMemoryEx .

Alexandre Julliard julliard at winehq.org
Mon May 21 15:31:07 CDT 2012


Module: wine
Branch: master
Commit: eb55412f664ac07b6ff13e51d221ca26e3415448
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eb55412f664ac07b6ff13e51d221ca26e3415448

Author: Józef Kucia <joseph.kucia at gmail.com>
Date:   Fri May 18 15:50:11 2012 +0200

d3dx9: Correctly check if a texture is dynamic in D3DXCreateTextureFromFileInMemoryEx.

---

 dlls/d3dx9_36/tests/texture.c |   11 +++++++++++
 dlls/d3dx9_36/texture.c       |    4 +++-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index 79e4023..f88ea75 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -1238,6 +1238,17 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
         D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture);
     ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
     if (SUCCEEDED(hr)) IDirect3DTexture9_Release(texture);
+
+    if (!is_autogenmipmap_supported(device, D3DRTYPE_TEXTURE))
+    {
+        skip("No D3DUSAGE_AUTOGENMIPMAP support for textures\n");
+        return;
+    }
+
+    hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
+        D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture);
+    ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
+    if (SUCCEEDED(hr)) IDirect3DTexture9_Release(texture);
 }
 
 static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index 8ca42c5..2a4a300 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -513,6 +513,7 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(LPDIRECT3DDEVICE9 device,
     IDirect3DSurface9 *surface;
     BOOL file_width = FALSE, file_height = FALSE;
     BOOL file_format = FALSE, file_miplevels = FALSE;
+    BOOL dynamic_texture;
     D3DXIMAGE_INFO imginfo;
     UINT loaded_miplevels;
     D3DCAPS9 caps;
@@ -600,7 +601,8 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(LPDIRECT3DDEVICE9 device,
         return D3DERR_INVALIDCALL;
 
     /* Create the to-be-filled texture */
-    if (pool == D3DPOOL_DEFAULT && !((caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && usage == D3DUSAGE_DYNAMIC))
+    dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
+    if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
     {
         hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, D3DPOOL_SYSTEMMEM, &buftex);
         texptr = &buftex;




More information about the wine-cvs mailing list