[9/9] d3dx9: Properly check if a texture is lockable in D3DXCreateTextureFromFileInMemoryEx.

Józef Kucia joseph.kucia at gmail.com
Sun May 13 16:00:11 CDT 2012


---
 dlls/d3dx9_36/tests/texture.c |   17 +++++++++++++++++
 dlls/d3dx9_36/texture.c       |   10 +++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index 60017ec..1314fa2 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -1149,6 +1149,22 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
     ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
 }
 
+static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
+{
+    HRESULT hr;
+    IDirect3DTexture9 *texture;
+
+    hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
+        0, 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);
+
+    hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
+        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);
+}
+
 static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
 {
     HRESULT hr;
@@ -1273,6 +1289,7 @@ START_TEST(texture)
     test_D3DXFillCubeTexture(device);
     test_D3DXFillVolumeTexture(device);
     test_D3DXCreateTextureFromFileInMemory(device);
+    test_D3DXCreateTextureFromFileInMemoryEx(device);
     test_D3DXCreateCubeTextureFromFileInMemory(device);
     test_D3DXCreateVolumeTextureFromFileInMemory(device);
 
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index 07e3d02..6a33547 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -590,15 +590,15 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(LPDIRECT3DDEVICE9 device,
         return D3DERR_INVALIDCALL;
 
     /* Create the to-be-filled texture */
-    if ((caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (pool != D3DPOOL_DEFAULT) && (usage != D3DUSAGE_DYNAMIC))
+    if (pool == D3DPOOL_DEFAULT && !((caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && usage == D3DUSAGE_DYNAMIC))
     {
-        hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, pool, texture);
-        texptr = texture;
+        hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, D3DPOOL_SYSTEMMEM, &buftex);
+        texptr = &buftex;
     }
     else
     {
-        hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, D3DPOOL_SYSTEMMEM, &buftex);
-        texptr = &buftex;
+        hr = D3DXCreateTexture(device, width, height, miplevels, usage, format, pool, texture);
+        texptr = texture;
     }
 
     if (FAILED(hr))
-- 
1.7.8.6




More information about the wine-patches mailing list