d3dcompiler/tests: Add a simple test for global variable initializers.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
549fa04cbd
commit
610baeac56
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue