[PATCH 7/7] d3d11/tests: Add test for device feature level.

Józef Kucia jkucia at codeweavers.com
Sun Aug 9 12:53:46 CDT 2015


---
 dlls/d3d11/tests/d3d11.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 61abc8a..66c0d61 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -44,6 +44,49 @@ static ID3D11Device *create_device(void)
     return NULL;
 }
 
+static void test_feature_level(void)
+{
+    D3D_FEATURE_LEVEL feature_level, default_feature_level, supported_feature_level;
+    static const D3D_FEATURE_LEVEL feature_levels[] =
+    {
+        D3D_FEATURE_LEVEL_11_1,
+        D3D_FEATURE_LEVEL_11_0,
+        D3D_FEATURE_LEVEL_10_1,
+        D3D_FEATURE_LEVEL_10_0,
+        D3D_FEATURE_LEVEL_9_3,
+        D3D_FEATURE_LEVEL_9_2,
+        D3D_FEATURE_LEVEL_9_1
+    };
+    ID3D11Device *device, *default_device;
+    HRESULT hr;
+
+    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION,
+            &default_device, &default_feature_level, NULL);
+    if (FAILED(hr))
+    {
+        skip("Failed to create hardware device, skipping tests.\n");
+        return;
+    }
+
+    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, feature_levels,
+            sizeof(feature_levels) / sizeof (*feature_levels), D3D11_SDK_VERSION, &device,
+            &supported_feature_level, NULL);
+    /* D3D_FEATURE_LEVEL_11_1 is not available on all Windows versions. */
+    ok(SUCCEEDED(hr) || broken(hr == E_INVALIDARG), "Failed to create device, hr %#x.\n", hr);
+    if (FAILED(hr)) supported_feature_level = default_feature_level;
+
+    trace("Feature level: %#x.\n", supported_feature_level);
+
+    feature_level = ID3D11Device_GetFeatureLevel(default_device);
+    ok(feature_level == default_feature_level, "Got unexpected feature level %#x.\n", feature_level);
+
+    feature_level = ID3D11Device_GetFeatureLevel(device);
+    ok(feature_level == supported_feature_level, "Got unexpected feature level %#x.\n", feature_level);
+
+    ID3D11Device_Release(device);
+    ID3D11Device_Release(default_device);
+}
+
 static void test_create_texture2d(void)
 {
     ULONG refcount, expected_refcount;
@@ -459,6 +502,7 @@ static void test_create_shader_resource_view(void)
 
 START_TEST(d3d11)
 {
+    test_feature_level();
     test_create_texture2d();
     test_create_texture3d();
     test_create_depthstencil_view();
-- 
2.4.6




More information about the wine-patches mailing list