Commit a8496091 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

d3dcompiler/tests: Load d3dcompiler_43.dll dynamically.

parent 25cc380b
TESTDLL = d3dcompiler_43.dll
IMPORTS = d3dcompiler d3d9 d3dx9 user32
IMPORTS = d3d9 d3dx9 user32
C_SRCS = \
asm.c \
......
......@@ -27,8 +27,10 @@
perhaps with a different name? */
#define D3DXERR_INVALIDDATA 0x88760b59
HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filename, const D3D_SHADER_MACRO *defines,
ID3DInclude *include, UINT flags, ID3DBlob **shader, ID3DBlob **error_messages);
static HRESULT (WINAPI *pD3DAssemble)(const void *data, SIZE_T datasize, const char *filename,
const D3D_SHADER_MACRO *defines, ID3DInclude *include, UINT flags, ID3DBlob **shader,
ID3DBlob **error_messages);
static pD3DPreprocess ppD3DPreprocess;
struct shader_test {
const char *text;
......@@ -56,9 +58,9 @@ static void exec_tests(const char *name, struct shader_test tests[], unsigned in
for(i = 0; i < count; i++) {
/* D3DAssemble sets messages to 0 if there aren't error messages */
messages = NULL;
hr = D3DAssemble(tests[i].text, strlen(tests[i].text), NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = pD3DAssemble(tests[i].text, strlen(tests[i].text), NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
ok(hr == S_OK, "Test %s, shader %d: D3DAssemble failed with error 0x%x - %d\n", name, i, hr, hr & 0x0000FFFF);
if(messages) {
trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
......@@ -1412,9 +1414,9 @@ static void failure_test(void) {
{
shader = NULL;
messages = NULL;
hr = D3DAssemble(tests[i], strlen(tests[i]), NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = pD3DAssemble(tests[i], strlen(tests[i]), NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
ok(hr == D3DXERR_INVALIDDATA, "Failure test, shader %d: "
"expected D3DAssemble failure with D3DXERR_INVALIDDATA, "
"got 0x%x - %d\n", i, hr, hr & 0x0000FFFF);
......@@ -1540,9 +1542,9 @@ static void assembleshader_test(void) {
/* defines test */
shader = NULL;
messages = NULL;
hr = D3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = pD3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
ok(hr == S_OK, "defines test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if(messages) {
trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
......@@ -1552,17 +1554,17 @@ static void assembleshader_test(void) {
/* NULL messages test */
shader = NULL;
hr = D3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, NULL);
hr = pD3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, NULL);
ok(hr == S_OK, "NULL messages test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if(shader) ID3D10Blob_Release(shader);
/* NULL shader test */
messages = NULL;
hr = D3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
NULL, &messages);
hr = pD3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
NULL, &messages);
ok(hr == S_OK, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if(messages) {
trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
......@@ -1573,8 +1575,8 @@ static void assembleshader_test(void) {
shader = NULL;
messages = NULL;
include.ID3DInclude_iface.lpVtbl = &D3DInclude_Vtbl;
hr = D3DAssemble(testshader, strlen(testshader), NULL, NULL, &include.ID3DInclude_iface,
D3DCOMPILE_SKIP_VALIDATION, &shader, &messages);
hr = pD3DAssemble(testshader, strlen(testshader), NULL, NULL, &include.ID3DInclude_iface,
D3DCOMPILE_SKIP_VALIDATION, &shader, &messages);
ok(hr == S_OK, "D3DInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if(messages) {
trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
......@@ -1585,9 +1587,9 @@ static void assembleshader_test(void) {
/* NULL shader tests */
shader = NULL;
messages = NULL;
hr = D3DAssemble(NULL, 0, NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = pD3DAssemble(NULL, 0, NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
ok(hr == D3DXERR_INVALIDDATA, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if(messages) {
trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
......@@ -1647,7 +1649,7 @@ static void d3dpreprocess_test(void)
/* pDefines test */
shader = NULL;
messages = NULL;
hr = D3DPreprocess(test1, strlen(test1), NULL,
hr = ppD3DPreprocess(test1, strlen(test1), NULL,
defines, NULL, &shader, &messages);
ok(hr == S_OK, "pDefines test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if (messages)
......@@ -1659,14 +1661,14 @@ static void d3dpreprocess_test(void)
/* NULL messages test */
shader = NULL;
hr = D3DPreprocess(test1, strlen(test1), NULL,
hr = ppD3DPreprocess(test1, strlen(test1), NULL,
defines, NULL, &shader, NULL);
ok(hr == S_OK, "NULL messages test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if (shader) ID3D10Blob_Release(shader);
/* NULL shader test */
messages = NULL;
hr = D3DPreprocess(test1, strlen(test1), NULL,
hr = ppD3DPreprocess(test1, strlen(test1), NULL,
defines, NULL, NULL, &messages);
ok(hr == E_INVALIDARG, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if (messages)
......@@ -1678,7 +1680,7 @@ static void d3dpreprocess_test(void)
/* quotation marks test */
shader = NULL;
messages = NULL;
hr = D3DPreprocess(quotation_marks_test, strlen(quotation_marks_test), NULL,
hr = ppD3DPreprocess(quotation_marks_test, strlen(quotation_marks_test), NULL,
NULL, NULL, &shader, &messages);
todo_wine ok(hr == S_OK, "quotation marks test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if (messages)
......@@ -1694,7 +1696,7 @@ static void d3dpreprocess_test(void)
{
shader = NULL;
messages = NULL;
hr = D3DPreprocess(include_test_shaders[i], strlen(include_test_shaders[i]), NULL, NULL,
hr = ppD3DPreprocess(include_test_shaders[i], strlen(include_test_shaders[i]), NULL, NULL,
&include.ID3DInclude_iface, &shader, &messages);
ok(hr == S_OK, "pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if (messages)
......@@ -1708,7 +1710,7 @@ static void d3dpreprocess_test(void)
/* NULL shader tests */
shader = NULL;
messages = NULL;
hr = D3DPreprocess(NULL, 0, NULL,
hr = ppD3DPreprocess(NULL, 0, NULL,
NULL, NULL, &shader, &messages);
ok(hr == E_INVALIDARG, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
if (messages)
......@@ -1719,8 +1721,25 @@ static void d3dpreprocess_test(void)
if (shader) ID3D10Blob_Release(shader);
}
static BOOL load_d3dcompiler(void)
{
HMODULE module;
if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
pD3DAssemble = (void*)GetProcAddress(module, "D3DAssemble");
ppD3DPreprocess = (void*)GetProcAddress(module, "D3DPreprocess");
return TRUE;
}
START_TEST(asm)
{
if (!load_d3dcompiler())
{
win_skip("Could not load d3dcompiler_43.dll\n");
return;
}
preproc_test();
ps_1_1_test();
vs_1_1_test();
......
......@@ -22,6 +22,8 @@
#include <math.h>
static pD3DCompile ppD3DCompile;
struct vertex
{
float x, y, z;
......@@ -134,7 +136,7 @@ static IDirect3DDevice9 *init_d3d9(IDirect3DVertexDeclaration9 **vdeclaration,
ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned: %08x\n", hr);
/* Create a simple vertex shader to just pass through the values */
hr = D3DCompile(vshader_passthru_hlsl, strlen(vshader_passthru_hlsl), NULL,
hr = ppD3DCompile(vshader_passthru_hlsl, strlen(vshader_passthru_hlsl), NULL,
NULL, NULL, "vshader", "vs_1_1", 0, 0, &compiled, &errors);
if (FAILED(hr))
{
......@@ -173,7 +175,7 @@ static IDirect3DPixelShader9 *compile_pixel_shader9(IDirect3DDevice9 *device, co
IDirect3DPixelShader9 *pshader;
HRESULT hr;
hr = D3DCompile(shader, strlen(shader), NULL, NULL,
hr = ppD3DCompile(shader, strlen(shader), NULL, NULL,
NULL, "test", profile, /* test is the name of the entry point of our shader */
0, 0, &compiled, &errors);
ok(hr == D3D_OK, "Pixel shader %s compilation failed: %s\n", shader,
......@@ -599,7 +601,7 @@ static void test_fail(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *qquad_ge
ID3D10Blob *compiled = NULL, *errors = NULL;
HRESULT hr;
hr = D3DCompile(undefined_variable_shader, strlen(undefined_variable_shader), NULL, NULL, NULL,
hr = ppD3DCompile(undefined_variable_shader, strlen(undefined_variable_shader), NULL, NULL, NULL,
"test", "ps_2_0", 0, 0, &compiled, &errors);
ok(hr != D3D_OK, "Pixel shader compilation succeeded on shader with undefined variable\n");
ok(errors != NULL, "No errors returned for a shader with undefined variables\n");
......@@ -608,7 +610,7 @@ static void test_fail(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *qquad_ge
ID3D10Blob_Release(errors);
errors = NULL;
hr = D3DCompile(invalid_swizzle_shader, strlen(invalid_swizzle_shader), NULL, NULL, NULL,
hr = ppD3DCompile(invalid_swizzle_shader, strlen(invalid_swizzle_shader), NULL, NULL, NULL,
"test","ps_2_0", 0, 0, &compiled, &errors);
ok(hr != D3D_OK, "Pixel shader compilation succeeded on shader with an invalid swizzle mask\n");
ok(errors != NULL, "No errors returned for a shader with an invalid swizzle mask\n");
......@@ -617,7 +619,7 @@ static void test_fail(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *qquad_ge
ID3D10Blob_Release(errors);
errors = NULL;
hr = D3DCompile(invalid_conversion_shader, strlen(invalid_conversion_shader), NULL, NULL, NULL,
hr = ppD3DCompile(invalid_conversion_shader, strlen(invalid_conversion_shader), NULL, NULL, NULL,
"test", "ps_2_0", 0, 0, &compiled, &errors);
ok(hr != D3D_OK, "Pixel shader compilation succeeded on shader with an invalid type "
"conversion\n");
......@@ -627,7 +629,7 @@ static void test_fail(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *qquad_ge
ID3D10Blob_Release(errors);
errors = NULL;
hr = D3DCompile(invalid_syntax_shader, strlen(invalid_syntax_shader), NULL, NULL, NULL, "test",
hr = ppD3DCompile(invalid_syntax_shader, strlen(invalid_syntax_shader), NULL, NULL, NULL, "test",
"ps_2_0", 0, 0, &compiled, &errors);
ok(hr != D3D_OK, "Pixel shader compilation succeeded on shader with blatantly invalid "
"syntax\n");
......@@ -637,7 +639,7 @@ static void test_fail(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *qquad_ge
ID3D10Blob_Release(errors);
errors = NULL;
hr = D3DCompile(invalid_identifiers_shader, strlen(invalid_identifiers_shader), NULL, NULL,
hr = ppD3DCompile(invalid_identifiers_shader, strlen(invalid_identifiers_shader), NULL, NULL,
NULL, "test", "ps_2_0", 0, 0, &compiled, &errors);
ok(hr != D3D_OK, "Pixel shader compilation successful on a shader with invalid variable and "
"function names\n");
......@@ -649,6 +651,16 @@ static void test_fail(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *qquad_ge
ID3D10Blob_Release(errors);
}
static BOOL load_d3dcompiler(void)
{
HMODULE module;
if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
ppD3DCompile = (void*)GetProcAddress(module, "D3DCompile");
return TRUE;
}
START_TEST(hlsl)
{
D3DCAPS9 caps;
......@@ -658,6 +670,12 @@ START_TEST(hlsl)
IDirect3DVertexBuffer9 *quad_geometry;
IDirect3DVertexShader9 *vshader_passthru;
if (!load_d3dcompiler())
{
win_skip("Could not load d3dcompiler_43.dll\n");
return;
}
device = init_d3d9(&vdeclaration, &quad_geometry, &vshader_passthru);
if (!device) return;
......
......@@ -38,6 +38,8 @@
*/
#define D3DERR_INVALIDCALL 0x8876086c
static typeof(D3DReflect) *pD3DReflect;
/* Creator string for comparison - Version 9.29.952.3111 (43) */
static DWORD shader_creator[] = {
0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
......@@ -79,7 +81,7 @@ static void test_reflection_references(void)
ID3D10ShaderReflection *ref10;
ID3D10ShaderReflection1 *ref10_1;
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == S_OK, "D3DReflect failed, got %x, expected %x\n", hr, S_OK);
hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D11ShaderReflection, (void **)&ref11_test);
......@@ -98,35 +100,35 @@ static void test_reflection_references(void)
ok(count == 0, "Release failed %u\n", count);
/* check invalid cases */
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection, (void **)&ref10);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection, (void **)&ref10);
ok(hr == E_NOINTERFACE, "D3DReflect failed, got %x, expected %x\n", hr, E_NOINTERFACE);
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == E_NOINTERFACE, "D3DReflect failed, got %x, expected %x\n", hr, E_NOINTERFACE);
hr = D3DReflect(NULL, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = pD3DReflect(NULL, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
hr = D3DReflect(NULL, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(NULL, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
/* returns different errors with different sizes */
hr = D3DReflect(test_reflection_blob, 31, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = pD3DReflect(test_reflection_blob, 31, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
hr = D3DReflect(test_reflection_blob, 32, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = pD3DReflect(test_reflection_blob, 32, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == E_FAIL, "D3DReflect failed, got %x, expected %x\n", hr, E_FAIL);
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == E_FAIL, "D3DReflect failed, got %x, expected %x\n", hr, E_FAIL);
hr = D3DReflect(test_reflection_blob, 31, &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_blob, 31, &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
hr = D3DReflect(test_reflection_blob, 32, &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_blob, 32, &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == E_FAIL, "D3DReflect failed, got %x, expected %x\n", hr, E_FAIL);
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == E_FAIL, "D3DReflect failed, got %x, expected %x\n", hr, E_FAIL);
}
......@@ -295,7 +297,7 @@ static void test_reflection_desc_vs(void)
UINT ret;
unsigned int i;
hr = D3DReflect(test_reflection_desc_vs_blob, test_reflection_desc_vs_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_desc_vs_blob, test_reflection_desc_vs_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == S_OK, "D3DReflect failed %x\n", hr);
hr = ref11->lpVtbl->GetDesc(ref11, NULL);
......@@ -582,7 +584,7 @@ static void test_reflection_desc_ps(void)
UINT ret;
unsigned int i;
hr = D3DReflect(test_reflection_desc_ps_blob, test_reflection_desc_ps_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_desc_ps_blob, test_reflection_desc_ps_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == S_OK, "D3DReflect failed %x\n", hr);
hr = ref11->lpVtbl->GetDesc(ref11, &sdesc11);
......@@ -901,7 +903,7 @@ static void test_reflection_desc_ps_output(void)
for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_output_result); ++i)
{
hr = D3DReflect(test_reflection_desc_ps_output_blob[i], test_reflection_desc_ps_output_blob[i][6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_desc_ps_output_blob[i], test_reflection_desc_ps_output_blob[i][6], &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == S_OK, "(%u): D3DReflect failed %x\n", i, hr);
pdesc = &test_reflection_desc_ps_output_result[i];
......@@ -1013,7 +1015,7 @@ static void test_reflection_bound_resources(void)
const D3D11_SHADER_INPUT_BIND_DESC *pdesc;
unsigned int i;
hr = D3DReflect(test_reflection_bound_resources_blob, test_reflection_bound_resources_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_bound_resources_blob, test_reflection_bound_resources_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == S_OK, "D3DReflect failed %x\n", hr);
/* check invalid cases */
......@@ -1230,7 +1232,7 @@ static void test_reflection_constant_buffer(void)
unsigned int i;
LPCSTR string;
hr = D3DReflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = pD3DReflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == S_OK, "D3DReflect failed %x\n", hr);
hr = ref11->lpVtbl->GetDesc(ref11, &sdesc);
......@@ -1505,8 +1507,24 @@ static void test_reflection_constant_buffer(void)
ok(count == 0, "Release failed %u\n", count);
}
static BOOL load_d3dcompiler(void)
{
HMODULE module;
if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
pD3DReflect = (void*)GetProcAddress(module, "D3DReflect");
return TRUE;
}
START_TEST(reflection)
{
if (!load_d3dcompiler())
{
win_skip("Could not load d3dcompiler_43.dll\n");
return;
}
test_reflection_references();
test_reflection_desc_vs();
test_reflection_desc_ps();
......
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