[PATCH 1/3] d3dx10_43: Add D3DX10CreateEffectFrom* tests

Andrew Eikum wine at gitlab.winehq.org
Tue Jun 28 09:22:49 CDT 2022


From: Andrew Eikum <aeikum at codeweavers.com>

---
 dlls/d3dx10_43/tests/Makefile.in       |   2 +
 dlls/d3dx10_43/tests/d3dx10.c          | 171 ++++++++++++++++++++++++-
 dlls/d3dx10_43/tests/fx_test_ecbt.fx   | Bin 0 -> 325 bytes
 dlls/d3dx10_43/tests/fx_test_ecbt.hlsl |  10 ++
 dlls/d3dx10_43/tests/resource.rc       |  23 ++++
 5 files changed, 204 insertions(+), 2 deletions(-)
 create mode 100644 dlls/d3dx10_43/tests/fx_test_ecbt.fx
 create mode 100644 dlls/d3dx10_43/tests/fx_test_ecbt.hlsl
 create mode 100644 dlls/d3dx10_43/tests/resource.rc

diff --git a/dlls/d3dx10_43/tests/Makefile.in b/dlls/d3dx10_43/tests/Makefile.in
index 95078d0e12b..0759443ef3d 100644
--- a/dlls/d3dx10_43/tests/Makefile.in
+++ b/dlls/d3dx10_43/tests/Makefile.in
@@ -4,3 +4,5 @@ IMPORTS = d3dx10 ole32 gdi32
 
 C_SRCS = \
 	d3dx10.c
+
+RC_SRCS = resource.rc
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c
index 1c28a62b700..252e2a40ee8 100644
--- a/dlls/d3dx10_43/tests/d3dx10.c
+++ b/dlls/d3dx10_43/tests/d3dx10.c
@@ -942,6 +942,23 @@ static char *get_str_a(const WCHAR *wstr)
     return buffer;
 }
 
+BOOL load_resource(HMODULE module, const WCHAR *resource, void **data, DWORD *size)
+{
+    HGLOBAL hglobal;
+    HRSRC rsrc;
+
+    if (!(rsrc = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)) ||
+            !(*size = SizeofResource(module, rsrc)) ||
+            !(hglobal = LoadResource(module, rsrc)) ||
+            !(*data = LockResource(hglobal)))
+    {
+        ok(0, "Failed to find resource.\n");
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
 static BOOL create_file(const WCHAR *filename, const void *data, unsigned int size, WCHAR *out_path)
 {
     WCHAR path[MAX_PATH];
@@ -3543,10 +3560,11 @@ todo_wine {
     ok(!refcount, "Unexpected refcount.\n");
 }
 
-static void test_create_effect_from_resource(void)
+static void test_D3DX10CreateEffectFromResource(void)
 {
     ID3D10Device *device;
     ID3D10Effect *effect;
+    ID3D10Blob *errors;
     ULONG refcount;
     HRESULT hr;
 
@@ -3556,10 +3574,157 @@ static void test_create_effect_from_resource(void)
         return;
     }
 
+    /* test resource that doesn't exist */
     hr = D3DX10CreateEffectFromResourceA(GetModuleHandleA(NULL), "resource", NULL, NULL, NULL,
             "fx_4_0", 0, 0, device, NULL, NULL, &effect, NULL, NULL);
     ok(hr == D3DX10_ERR_INVALID_DATA, "Unexpected hr %#x.\n", hr);
 
+
+    /* test creating effect from pre-built DXBC shader */
+    errors = NULL;
+    effect = NULL;
+    hr = D3DX10CreateEffectFromResourceA(GetModuleHandleA(NULL), "fx_test_ecbt.fx", NULL,
+            NULL, NULL, "fx_4_0", 0x0, 0x0, device, NULL, NULL, &effect,
+            &errors, NULL);
+    todo_wine ok(hr == S_OK, "D3DX10CreateEffectFromResource failed: %#x\n", hr);
+    todo_wine ok(errors == NULL, "Got unexpected effect errors\n");
+    todo_wine ok(effect != NULL, "No effect created\n");
+    if (errors)
+        ID3D10Blob_Release(errors);
+    if (effect)
+        effect->lpVtbl->Release(effect);
+
+
+    /* test creating effect from source */
+    errors = NULL;
+    effect = NULL;
+    hr = D3DX10CreateEffectFromResourceA(GetModuleHandleA(NULL), "fx_test_ecbt.hlsl", NULL,
+            NULL, NULL, "fx_4_0", 0x0, 0x0, device, NULL, NULL, &effect,
+            &errors, NULL);
+    todo_wine ok(hr == S_OK, "D3DX10CreateEffectFromResource failed: %#x\n", hr);
+    todo_wine ok(errors == NULL, "Got unexpected effect errors\n");
+    todo_wine ok(effect != NULL, "No effect created\n");
+    if (errors)
+        ID3D10Blob_Release(errors);
+    if (effect)
+        effect->lpVtbl->Release(effect);
+
+
+    refcount = ID3D10Device_Release(device);
+    ok(!refcount, "Unexpected refcount.\n");
+}
+
+static void test_D3DX10CreateEffectFromMemory(void)
+{
+    DWORD fx_test_ecbt_size, fx_test_ecbt_src_size;
+    void *fx_test_ecbt, *fx_test_ecbt_src;
+    ID3D10Device *device;
+    ID3D10Effect *effect;
+    ID3D10Blob *errors;
+    ULONG refcount;
+    HRESULT hr;
+
+    if (!(device = create_device()))
+    {
+        skip("Failed to create device, skipping tests.\n");
+        return;
+    }
+
+    /* test creating effect from pre-built DXBC shader */
+    load_resource(GetModuleHandleA(NULL), L"fx_test_ecbt.fx", &fx_test_ecbt, &fx_test_ecbt_size);
+
+    errors = NULL;
+    effect = NULL;
+    hr = D3DX10CreateEffectFromMemory(fx_test_ecbt, fx_test_ecbt_size, NULL,
+            NULL, NULL, "fx_4_0", 0x0, 0x0, device, NULL, NULL, &effect,
+            &errors, NULL);
+    todo_wine ok(hr == S_OK, "D3DX10CreateEffectFromMemory failed: %#x\n", hr);
+    todo_wine ok(errors == NULL, "Got unexpected effect errors\n");
+    todo_wine ok(effect != NULL, "No effect created\n");
+    if (errors)
+        ID3D10Blob_Release(errors);
+    if (effect)
+        effect->lpVtbl->Release(effect);
+
+
+    /* test creating effect from source */
+    load_resource(GetModuleHandleA(NULL), L"fx_test_ecbt.hlsl", &fx_test_ecbt_src, &fx_test_ecbt_src_size);
+
+    errors = NULL;
+    effect = NULL;
+    hr = D3DX10CreateEffectFromMemory(fx_test_ecbt_src, fx_test_ecbt_src_size, NULL,
+            NULL, NULL, "fx_4_0", 0x0, 0x0, device, NULL, NULL, &effect,
+            &errors, NULL);
+    todo_wine ok(hr == S_OK, "D3DX10CreateEffectFromMemory failed: %#x\n", hr);
+    todo_wine ok(errors == NULL, "Got unexpected effect errors\n");
+    todo_wine ok(effect != NULL, "No effect created\n");
+    if (errors)
+        ID3D10Blob_Release(errors);
+    if (effect)
+        effect->lpVtbl->Release(effect);
+
+
+    refcount = ID3D10Device_Release(device);
+    ok(!refcount, "Unexpected refcount.\n");
+}
+
+static void test_D3DX10CreateEffectFromFile(void)
+{
+    DWORD fx_test_ecbt_size, fx_test_ecbt_src_size;
+    void *fx_test_ecbt, *fx_test_ecbt_src;
+    ID3D10Device *device;
+    ID3D10Effect *effect;
+    WCHAR path[MAX_PATH];
+    ID3D10Blob *errors;
+    ULONG refcount;
+    HRESULT hr;
+
+    if (!(device = create_device()))
+    {
+        skip("Failed to create device, skipping tests.\n");
+        return;
+    }
+
+    /* test creating effect from pre-built DXBC shader */
+    load_resource(GetModuleHandleA(NULL), L"fx_test_ecbt.fx", &fx_test_ecbt, &fx_test_ecbt_size);
+
+    create_file(L"fx_test_ecbt.fx", fx_test_ecbt, fx_test_ecbt_size, path);
+
+    errors = NULL;
+    effect = NULL;
+    hr = D3DX10CreateEffectFromFileW(path,
+            NULL, NULL, "fx_4_0", 0x0, 0x0, device, NULL, NULL, &effect,
+            &errors, NULL);
+    todo_wine ok(hr == S_OK, "D3DX10CreateEffectFromFile failed: %#x\n", hr);
+    todo_wine ok(errors == NULL, "Got unexpected effect errors\n");
+    todo_wine ok(effect != NULL, "No effect created\n");
+    if (errors)
+        ID3D10Blob_Release(errors);
+    if (effect)
+        effect->lpVtbl->Release(effect);
+    delete_file(L"fx_test_ecbt.fx");
+
+
+    /* test creating effect from source */
+    load_resource(GetModuleHandleA(NULL), L"fx_test_ecbt.hlsl", &fx_test_ecbt_src, &fx_test_ecbt_src_size);
+
+    create_file(L"fx_test_ecbt.hlsl", fx_test_ecbt_src, fx_test_ecbt_src_size, path);
+
+    errors = NULL;
+    effect = NULL;
+    hr = D3DX10CreateEffectFromFileW(path,
+            NULL, NULL, "fx_4_0", 0x0, 0x0, device, NULL, NULL, &effect,
+            &errors, NULL);
+    todo_wine ok(hr == S_OK, "D3DX10CreateEffectFromFile failed: %#x\n", hr);
+    todo_wine ok(errors == NULL, "Got unexpected effect errors\n");
+    todo_wine ok(effect != NULL, "No effect created\n");
+    if (errors)
+        ID3D10Blob_Release(errors);
+    if (effect)
+        effect->lpVtbl->Release(effect);
+    delete_file(L"fx_test_ecbt.hlsl");
+
+
     refcount = ID3D10Device_Release(device);
     ok(!refcount, "Unexpected refcount.\n");
 }
@@ -3576,5 +3741,7 @@ START_TEST(d3dx10)
     test_create_texture();
     test_font();
     test_sprite();
-    test_create_effect_from_resource();
+    test_D3DX10CreateEffectFromResource();
+    test_D3DX10CreateEffectFromMemory();
+    test_D3DX10CreateEffectFromFile();
 }
diff --git a/dlls/d3dx10_43/tests/fx_test_ecbt.fx b/dlls/d3dx10_43/tests/fx_test_ecbt.fx
new file mode 100644
index 0000000000000000000000000000000000000000..5996abb2d3d194f97aec71862e4e18af9e192749
GIT binary patch
literal 325
zcmZ>XaB{xa^SfrM?i)iVh5(Cn9^;ja3=9meKmtUo0I^$yp at AfbFYx~#6Ohjg#Mpo*
zHbFdM$w>@pIr)ht4D3KfAj?321&9TpG$$tmLz*E&a9DhRf3RnWr at tRVnh}GuzmI>A
z0Yh?<5ks0WTs=rH$Z;@pG=XehAl3n5bYKA#0LfVcF~~k--~{9tKm}lCfw*o!4AKJv
J3SbhU7XXq|7`p%f

literal 0
HcmV?d00001

diff --git a/dlls/d3dx10_43/tests/fx_test_ecbt.hlsl b/dlls/d3dx10_43/tests/fx_test_ecbt.hlsl
new file mode 100644
index 00000000000..24581832dc3
--- /dev/null
+++ b/dlls/d3dx10_43/tests/fx_test_ecbt.hlsl
@@ -0,0 +1,10 @@
+cbuffer cb : register(b1)
+{
+    float   f1 : SV_POSITION;
+    float   f2 : COLOR0;
+};
+
+cbuffer cb2 : register(b0)
+{
+    float   f3 : packoffset(c2);
+};
diff --git a/dlls/d3dx10_43/tests/resource.rc b/dlls/d3dx10_43/tests/resource.rc
new file mode 100644
index 00000000000..e8c04cc15e6
--- /dev/null
+++ b/dlls/d3dx10_43/tests/resource.rc
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2022 Andrew Eikum 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
+ */
+
+/* @makedep: fx_test_ecbt.fx */
+fx_test_ecbt.fx RCDATA fx_test_ecbt.fx
+
+/* @makedep: fx_test_ecbt.hlsl */
+fx_test_ecbt.hlsl RCDATA fx_test_ecbt.hlsl
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/332



More information about the wine-devel mailing list