[PATCH 2/7] d3d11/tests: Port test_create_texture2d() from d3d10core.

Józef Kucia jkucia at codeweavers.com
Sun Aug 9 18:11:20 CDT 2015


---
 configure                    |   3 +-
 configure.ac                 |   3 +-
 dlls/d3d11/Makefile.in       |   1 +
 dlls/d3d11/tests/Makefile.in |   5 ++
 dlls/d3d11/tests/d3d11.c     | 145 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 155 insertions(+), 2 deletions(-)
 create mode 100644 dlls/d3d11/tests/Makefile.in
 create mode 100644 dlls/d3d11/tests/d3d11.c

diff --git a/configure b/configure
index a66731b..1093a51 100755
--- a/configure
+++ b/configure
@@ -17235,7 +17235,8 @@ wine_fn_config_test dlls/d3d10/tests d3d10_test
 wine_fn_config_dll d3d10_1 enable_d3d10_1 implib
 wine_fn_config_dll d3d10core enable_d3d10core implib
 wine_fn_config_test dlls/d3d10core/tests d3d10core_test
-wine_fn_config_dll d3d11 enable_d3d11
+wine_fn_config_dll d3d11 enable_d3d11 implib
+wine_fn_config_test dlls/d3d11/tests d3d11_test
 wine_fn_config_dll d3d8 enable_d3d8 implib
 wine_fn_config_test dlls/d3d8/tests d3d8_test
 wine_fn_config_dll d3d9 enable_d3d9 implib
diff --git a/configure.ac b/configure.ac
index 1329786..659e378 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2836,7 +2836,8 @@ WINE_CONFIG_TEST(dlls/d3d10/tests)
 WINE_CONFIG_DLL(d3d10_1,,[implib])
 WINE_CONFIG_DLL(d3d10core,,[implib])
 WINE_CONFIG_TEST(dlls/d3d10core/tests)
-WINE_CONFIG_DLL(d3d11)
+WINE_CONFIG_DLL(d3d11,,[implib])
+WINE_CONFIG_TEST(dlls/d3d11/tests)
 WINE_CONFIG_DLL(d3d8,,[implib])
 WINE_CONFIG_TEST(dlls/d3d8/tests)
 WINE_CONFIG_DLL(d3d9,,[implib])
diff --git a/dlls/d3d11/Makefile.in b/dlls/d3d11/Makefile.in
index fce34cd..31f4562 100644
--- a/dlls/d3d11/Makefile.in
+++ b/dlls/d3d11/Makefile.in
@@ -1,4 +1,5 @@
 MODULE    = d3d11.dll
+IMPORTLIB = d3d11
 
 C_SRCS = \
 	d3d11_main.c
diff --git a/dlls/d3d11/tests/Makefile.in b/dlls/d3d11/tests/Makefile.in
new file mode 100644
index 0000000..735f05e
--- /dev/null
+++ b/dlls/d3d11/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = d3d11.dll
+IMPORTS = d3d11 dxguid
+
+C_SRCS = \
+	d3d11.c
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
new file mode 100644
index 0000000..fa651b3
--- /dev/null
+++ b/dlls/d3d11/tests/d3d11.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2008 Henri Verbeet for CodeWeavers
+ * Copyright 2015 Józef Kucia for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+#include "d3d11.h"
+#include "wine/test.h"
+
+static ULONG get_refcount(IUnknown *iface)
+{
+    IUnknown_AddRef(iface);
+    return IUnknown_Release(iface);
+}
+
+static ID3D11Device *create_device(void)
+{
+    ID3D11Device *device;
+
+    if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
+                    &device, NULL, NULL)))
+        return device;
+    if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_WARP, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
+                    &device, NULL, NULL)))
+        return device;
+    if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
+                    &device, NULL, NULL)))
+        return device;
+
+    return NULL;
+}
+
+static void test_create_texture2d(void)
+{
+    ULONG refcount, expected_refcount;
+    D3D11_SUBRESOURCE_DATA data = {0};
+    ID3D11Device *device, *tmp;
+    D3D11_TEXTURE2D_DESC desc;
+    ID3D11Texture2D *texture;
+    IDXGISurface *surface;
+    HRESULT hr;
+
+    if (!(device = create_device()))
+    {
+        skip("Failed to create device, skipping tests.\n");
+        return;
+    }
+
+    desc.Width = 512;
+    desc.Height = 512;
+    desc.MipLevels = 1;
+    desc.ArraySize = 1;
+    desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    desc.SampleDesc.Count = 1;
+    desc.SampleDesc.Quality = 0;
+    desc.Usage = D3D11_USAGE_DEFAULT;
+    desc.BindFlags = D3D11_BIND_RENDER_TARGET;
+    desc.CPUAccessFlags = 0;
+    desc.MiscFlags = 0;
+
+    hr = ID3D11Device_CreateTexture2D(device, &desc, &data, &texture);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+
+    expected_refcount = get_refcount((IUnknown *)device) + 1;
+    hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
+    ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
+    refcount = get_refcount((IUnknown *)device);
+    ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
+    tmp = NULL;
+    expected_refcount = refcount + 1;
+    ID3D11Texture2D_GetDevice(texture, &tmp);
+    ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
+    refcount = get_refcount((IUnknown *)device);
+    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ID3D11Device_Release(tmp);
+
+    hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
+    ok(SUCCEEDED(hr), "Texture should implement IDXGISurface\n");
+    if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
+    ID3D11Texture2D_Release(texture);
+
+    desc.MipLevels = 0;
+    expected_refcount = get_refcount((IUnknown *)device) + 1;
+    hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
+    ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
+    refcount = get_refcount((IUnknown *)device);
+    ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
+    tmp = NULL;
+    expected_refcount = refcount + 1;
+    ID3D11Texture2D_GetDevice(texture, &tmp);
+    ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
+    refcount = get_refcount((IUnknown *)device);
+    ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+    ID3D11Device_Release(tmp);
+
+    ID3D11Texture2D_GetDesc(texture, &desc);
+    ok(desc.Width == 512, "Got unexpected Width %u.\n", desc.Width);
+    ok(desc.Height == 512, "Got unexpected Height %u.\n", desc.Height);
+    ok(desc.MipLevels == 10, "Got unexpected MipLevels %u.\n", desc.MipLevels);
+    ok(desc.ArraySize == 1, "Got unexpected ArraySize %u.\n", desc.ArraySize);
+    ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format);
+    ok(desc.SampleDesc.Count == 1, "Got unexpected SampleDesc.Count %u.\n", desc.SampleDesc.Count);
+    ok(desc.SampleDesc.Quality == 0, "Got unexpected SampleDesc.Quality %u.\n", desc.SampleDesc.Quality);
+    ok(desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected Usage %u.\n", desc.Usage);
+    ok(desc.BindFlags == D3D11_BIND_RENDER_TARGET, "Got unexpected BindFlags %u.\n", desc.BindFlags);
+    ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %u.\n", desc.CPUAccessFlags);
+    ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %u.\n", desc.MiscFlags);
+
+    hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
+    ok(FAILED(hr), "Texture should not implement IDXGISurface\n");
+    if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
+    ID3D11Texture2D_Release(texture);
+
+    desc.MipLevels = 1;
+    desc.ArraySize = 2;
+    hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
+    ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
+
+    hr = ID3D11Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
+    ok(FAILED(hr), "Texture should not implement IDXGISurface\n");
+    if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
+    ID3D11Texture2D_Release(texture);
+
+    refcount = ID3D11Device_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+}
+
+START_TEST(d3d11)
+{
+    test_create_texture2d();
+}
-- 
2.4.6




More information about the wine-patches mailing list