[PATCH 3/6] d3dcompiler/tests: Add a simple test for global variable initializers.

Zebediah Figura z.figura12 at gmail.com
Thu Jun 11 16:44:19 CDT 2020


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 43 +++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
index d82a0b015af..83f5b7bdd56 100644
--- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
+++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
@@ -948,6 +948,48 @@ static void test_struct_semantics(void)
     release_test_context(&test_context);
 }
 
+static void test_global_initializer(void)
+{
+    struct test_context test_context;
+    ID3DXConstantTable *constants;
+    ID3D10Blob *ps_code = NULL;
+    struct vec4 v;
+    HRESULT hr;
+
+    static const char ps_source[] =
+        "float myfunc()\n"
+        "{\n"
+        "    return 0.6;\n"
+        "}\n"
+        "static float sf = myfunc() + 0.2;\n"
+        "uniform float uf = 0.2;\n"
+        "float4 main() : COLOR\n"
+        "{\n"
+        "    return float4(sf, uf, 0, 0);\n"
+        "}";
+
+    if (!init_test_context(&test_context))
+        return;
+
+    todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
+    if (ps_code)
+    {
+        hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
+        ok(hr == D3D_OK, "Failed to get constant table, hr %#x.\n", hr);
+        hr = ID3DXConstantTable_SetDefaults(constants, test_context.device);
+        ok(hr == D3D_OK, "Failed to get constant table, hr %#x.\n", hr);
+        ID3DXConstantTable_Release(constants);
+        draw_quad(test_context.device, ps_code);
+
+        v = get_color_vec4(test_context.device, 0, 0);
+        todo_wine ok(compare_vec4(&v, 0.8f, 0.2f, 0.0f, 0.0f, 4096),
+                "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+
+        ID3D10Blob_Release(ps_code);
+    }
+    release_test_context(&test_context);
+}
+
 static void check_constant_desc(const char *prefix, const D3DXCONSTANT_DESC *desc,
         const D3DXCONSTANT_DESC *expect, BOOL nonzero_defaultvalue)
 {
@@ -1263,6 +1305,7 @@ START_TEST(hlsl_d3d9)
     test_majority();
     test_struct_assignment();
     test_struct_semantics();
+    test_global_initializer();
 
     test_constant_table();
     test_fail();
-- 
2.27.0




More information about the wine-devel mailing list