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

d3dx10: Support effect creation for compiled shader.

parent 7e8bd131
......@@ -28,12 +28,17 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
#define D3DERR_INVALIDCALL 0x8876086c
static HRESULT create_effect(const void *data, SIZE_T datasize, const char *filename,
const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile,
UINT shader_flags, UINT effect_flags, ID3D10Device *device, ID3D10EffectPool *effect_pool,
ID3D10Effect **effect, ID3D10Blob **errors)
{
ID3D10Blob *code;
const char dxbc[] = {'D','X','B','C'};
ID3D10Blob *code = NULL;
void *buffer;
SIZE_T size;
HRESULT hr;
if (!data || !device)
......@@ -42,17 +47,28 @@ static HRESULT create_effect(const void *data, SIZE_T datasize, const char *file
if (errors)
*errors = NULL;
if (FAILED(hr = D3DCompile(data, datasize, filename, defines, include, "main", profile,
shader_flags, effect_flags, &code, errors)))
buffer = (void *)data;
size = datasize;
/* Effect is not compiled. */
if (datasize < sizeof(dxbc) || memcmp(dxbc, data, sizeof(dxbc)))
{
WARN("Effect compilation failed, hr %#lx.\n", hr);
return hr;
if (!profile)
return D3DERR_INVALIDCALL;
if (FAILED(hr = D3DCompile(data, datasize, filename, defines, include, "main", profile,
shader_flags, effect_flags, &code, errors)))
{
WARN("Effect compilation failed, hr %#lx.\n", hr);
return hr;
}
buffer = ID3D10Blob_GetBufferPointer(code);
size = ID3D10Blob_GetBufferSize(code);
}
hr = D3D10CreateEffectFromMemory(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
effect_flags, device, effect_pool, effect);
ID3D10Blob_Release(code);
hr = D3D10CreateEffectFromMemory(buffer, size, effect_flags, device, effect_pool, effect);
if (code)
ID3D10Blob_Release(code);
return hr;
}
......
......@@ -3980,8 +3980,6 @@ static void test_create_effect_from_memory(void)
}
/* 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,
......@@ -4015,10 +4013,10 @@ static void test_create_effect_from_memory(void)
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);
todo_wine ok(!!errors && errors != (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors);
ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
ID3D10Blob_Release(errors);
}
if (errors && errors != (ID3D10Blob *)0xdeadbeef)
ID3D10Blob_Release(errors);
/* Test creating effect from source. */
errors = (ID3D10Blob *)0xdeadbeef;
......@@ -4086,8 +4084,6 @@ static void test_create_effect_from_file(void)
ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
/* Test creating effect from compiled shader file. */
if (strcmp(winetest_platform, "wine")) /* Crash on wine. */
{
create_file(test_file_name, test_fx, sizeof(test_fx), path);
errors = (ID3D10Blob *)0xdeadbeef;
......@@ -4109,7 +4105,6 @@ static void test_create_effect_from_file(void)
effect->lpVtbl->Release(effect);
delete_file(test_file_name);
}
/* Test creating effect from source file. */
create_file(test_file_name, test_fx_source, strlen(test_fx_source) + 1, path);
......@@ -4208,8 +4203,6 @@ static void test_create_effect_from_resource(void)
ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
/* Test creating effect from compiled shader resource. */
if (strcmp(winetest_platform, "wine")) /* Crash on wine. */
{
resource_module = create_resource_module(test_resource_name, test_fx, sizeof(test_fx));
errors = (ID3D10Blob *)0xdeadbeef;
......@@ -4231,7 +4224,6 @@ static void test_create_effect_from_resource(void)
effect->lpVtbl->Release(effect);
delete_resource_module(test_resource_name, resource_module);
}
/* Test creating effect from source resource. */
resource_module = create_resource_module(test_resource_name, test_fx_source, strlen(test_fx_source) + 1);
......
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