Commit c6d46ff3 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

d3dx10/tests: Add tests for D3DX10CreateEffectFromMemory.

Passing NULL profile to effect creation will crash wine for now. So we have to skip these tests in wine.
parent 745df591
......@@ -546,6 +546,34 @@ static const BYTE test_wmp_data[] =
0xff, 0xff, 0xff, 0xff
};
static const char *test_fx_source =
"cbuffer cb : register(b1)\n"
"{\n"
" float f1 : SV_POSITION;\n"
" float f2 : COLOR0;\n"
"}\n";
static const BYTE test_fx[] =
{
0x44, 0x58, 0x42, 0x43, 0x95, 0x89, 0xe1, 0xa2, 0xcc, 0x97, 0x05, 0x54, 0x73, 0x9d, 0x0b, 0x67,
0x90, 0xe1, 0x7f, 0x77, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x24, 0x00, 0x00, 0x00, 0x46, 0x58, 0x31, 0x30, 0xde, 0x00, 0x00, 0x00, 0x01, 0x10, 0xff, 0xfe,
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x62, 0x00, 0x66,
0x6c, 0x6f, 0x61, 0x74, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x09, 0x00,
0x00, 0x66, 0x31, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00,
0x66, 0x32, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x30, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const struct test_image
{
const BYTE *data;
......@@ -3937,6 +3965,76 @@ todo_wine {
ok(!refcount, "Unexpected refcount.\n");
}
static void test_create_effect_from_memory(void)
{
ID3D10Device *device;
ID3D10Effect *effect;
ID3D10Blob *errors;
ULONG refcount;
HRESULT hr;
if (!(device = create_device()))
{
skip("Failed to create device, skipping tests.\n");
return;
}
/* Test NULL data. */
if (strcmp(winetest_platform, "wine")) /* Crash on wine. */
{
errors = (ID3D10Blob *)0xdeadbeef;
effect = (ID3D10Effect *)0xdeadbeef;
hr = D3DX10CreateEffectFromMemory(NULL, 0, NULL, NULL, NULL, NULL,
0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL);
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors);
ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
/* Test NULL device. */
errors = (ID3D10Blob *)0xdeadbeef;
effect = (ID3D10Effect *)0xdeadbeef;
hr = D3DX10CreateEffectFromMemory(test_fx, sizeof(test_fx), NULL, NULL, NULL, NULL,
0x0, 0x0, NULL, NULL, NULL, &effect, &errors, NULL);
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors);
ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
/* Test creating effect from compiled shader. */
errors = (ID3D10Blob *)0xdeadbeef;
effect = (ID3D10Effect *)0xdeadbeef;
hr = D3DX10CreateEffectFromMemory(test_fx, sizeof(test_fx), NULL, NULL, NULL, NULL,
0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(!errors, "Got unexpected errors %p.\n", errors);
ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
effect->lpVtbl->Release(effect);
/* Test creating effect from source without setting profile. */
errors = (ID3D10Blob *)0xdeadbeef;
effect = (ID3D10Effect *)0xdeadbeef;
hr = D3DX10CreateEffectFromMemory(test_fx_source, strlen(test_fx_source) + 1, NULL, NULL, NULL, NULL,
0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
ok(!!errors && errors != (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors);
ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
ID3D10Blob_Release(errors);
}
/* Test creating effect from source. */
errors = (ID3D10Blob *)0xdeadbeef;
effect = (ID3D10Effect *)0xdeadbeef;
hr = D3DX10CreateEffectFromMemory(test_fx_source, strlen(test_fx_source) + 1, NULL, NULL, NULL, "fx_4_0",
0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL);
todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine ok(!errors, "Got unexpected errors %p.\n", errors);
todo_wine ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
if (hr == S_OK)
effect->lpVtbl->Release(effect);
refcount = ID3D10Device_Release(device);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
}
static void test_create_effect_from_resource(void)
{
ID3D10Device *device;
......@@ -4005,6 +4103,7 @@ START_TEST(d3dx10)
test_create_texture();
test_font();
test_sprite();
test_create_effect_from_memory();
test_create_effect_from_resource();
test_preprocess_shader();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment