Felix Nawothnig : wined3d: Make CreateCubeTexture fail when not supported.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 2 06:22:56 CDT 2007


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

Author: Felix Nawothnig <flexo at holycrap.org>
Date:   Fri Mar 30 21:29:38 2007 +0200

wined3d: Make CreateCubeTexture fail when not supported.

---

 dlls/d3d8/tests/texture.c |   27 +++++++++++++++++++++++++++
 dlls/d3d9/tests/texture.c |   27 +++++++++++++++++++++++++++
 dlls/wined3d/device.c     |    5 +++++
 3 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/dlls/d3d8/tests/texture.c b/dlls/d3d8/tests/texture.c
index 3e0b805..df7da8b 100644
--- a/dlls/d3d8/tests/texture.c
+++ b/dlls/d3d8/tests/texture.c
@@ -101,6 +101,32 @@ static void test_texture_stage_states(IDirect3DDevice8 *device_ptr, int num_stag
     }
 }
 
+static void test_cube_texture_from_pool(IDirect3DDevice8 *device_ptr, DWORD caps, D3DPOOL pool, BOOL need_cap)
+{
+    IDirect3DCubeTexture8 *texture_ptr = NULL;
+    HRESULT hr;
+
+    hr = IDirect3DDevice8_CreateCubeTexture(device_ptr, 512, 1, 0, D3DFMT_X8R8G8B8, pool, &texture_ptr);
+    trace("pool=%d hr=0x%.8x\n", pool, hr);
+
+    if((caps & D3DPTEXTURECAPS_CUBEMAP) || !need_cap)
+        ok(SUCCEEDED(hr), "hr=0x%.8x\n", hr);
+    else
+        ok(hr == D3DERR_INVALIDCALL, "hr=0x%.8x\n", hr);
+
+    if(texture_ptr) IDirect3DCubeTexture8_Release(texture_ptr);
+}
+
+static void test_cube_textures(IDirect3DDevice8 *device_ptr, DWORD caps)
+{
+    trace("texture caps: 0x%.8x\n", caps);
+
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_DEFAULT, TRUE);
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_MANAGED, TRUE);
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SYSTEMMEM, TRUE);
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SCRATCH, FALSE);
+}
+
 START_TEST(texture)
 {
     D3DCAPS8 caps;
@@ -120,4 +146,5 @@ START_TEST(texture)
     IDirect3DDevice8_GetDeviceCaps(device_ptr, &caps);
 
     test_texture_stage_states(device_ptr, caps.MaxTextureBlendStages);
+    test_cube_textures(device_ptr, caps.TextureCaps);
 }
diff --git a/dlls/d3d9/tests/texture.c b/dlls/d3d9/tests/texture.c
index d34ac4b..79d855d 100644
--- a/dlls/d3d9/tests/texture.c
+++ b/dlls/d3d9/tests/texture.c
@@ -100,6 +100,32 @@ static void test_texture_stage_states(IDirect3DDevice9 *device_ptr, int num_stag
     }
 }
 
+static void test_cube_texture_from_pool(IDirect3DDevice9 *device_ptr, DWORD caps, D3DPOOL pool, BOOL need_cap)
+{
+    IDirect3DCubeTexture9 *texture_ptr = NULL;
+    HRESULT hr;
+
+    hr = IDirect3DDevice9_CreateCubeTexture(device_ptr, 512, 1, 0, D3DFMT_X8R8G8B8, pool, &texture_ptr, NULL);
+    trace("pool=%d hr=0x%.8x\n", pool, hr);
+
+    if((caps & D3DPTEXTURECAPS_CUBEMAP) || !need_cap)
+        ok(SUCCEEDED(hr), "hr=0x%.8x\n", hr);
+    else
+        ok(hr == D3DERR_INVALIDCALL, "hr=0x%.8x\n", hr);
+
+    if(texture_ptr) IDirect3DCubeTexture9_Release(texture_ptr);
+}
+
+static void test_cube_textures(IDirect3DDevice9 *device_ptr, DWORD caps)
+{
+    trace("texture caps: 0x%.8x\n", caps);
+
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_DEFAULT, TRUE);
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_MANAGED, TRUE);
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SYSTEMMEM, TRUE);
+    test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SCRATCH, FALSE);
+}
+
 START_TEST(texture)
 {
     D3DCAPS9 caps;
@@ -119,4 +145,5 @@ START_TEST(texture)
     IDirect3DDevice9_GetDeviceCaps(device_ptr, &caps);
 
     test_texture_stage_states(device_ptr, caps.MaxTextureBlendStages);
+    test_cube_textures(device_ptr, caps.TextureCaps);
 }
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 7863714..ea09780 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -999,6 +999,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
         return WINED3DERR_INVALIDCALL;
     }
 
+    if (!GL_SUPPORT(ARB_TEXTURE_CUBE_MAP) && Pool != WINED3DPOOL_SCRATCH) {
+        WARN("(%p) : Tried to create not supported cube texture\n", This);
+        return WINED3DERR_INVALIDCALL;
+    }
+
     D3DCREATERESOURCEOBJECTINSTANCE(object, CubeTexture, WINED3DRTYPE_CUBETEXTURE, 0);
     D3DINITIALIZEBASETEXTURE(object->baseTexture);
 




More information about the wine-cvs mailing list