Commit 910a398b authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler/tests: Link directly to the relevant d3dcompiler version.

parent fb65de04
MODULE = d3dcompiler_43.dll
IMPORTLIB = d3dcompiler_43
EXTRADEFS = -DD3D_COMPILER_VERSION=43
EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native
......
TESTDLL = d3dcompiler_43.dll
IMPORTS = d3d9 user32
IMPORTS = d3d9 user32 d3dcompiler_43
EXTRADEFS = -DD3D_COMPILER_VERSION=43
C_SRCS = \
......
......@@ -27,11 +27,9 @@
perhaps with a different name? */
#define D3DXERR_INVALIDDATA 0x88760b59
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;
static pD3DDisassemble ppD3DDisassemble;
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);
struct shader_test {
const char *text;
......@@ -59,9 +57,8 @@ 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 = pD3DAssemble(tests[i].text, strlen(tests[i].text), NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = D3DAssemble(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));
......@@ -1415,9 +1412,7 @@ static void failure_test(void) {
{
shader = NULL;
messages = NULL;
hr = pD3DAssemble(tests[i], strlen(tests[i]), NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = D3DAssemble(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);
......@@ -1543,9 +1538,7 @@ static void assembleshader_test(void) {
/* defines test */
shader = NULL;
messages = NULL;
hr = pD3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = D3DAssemble(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));
......@@ -1555,17 +1548,13 @@ static void assembleshader_test(void) {
/* NULL messages test */
shader = NULL;
hr = pD3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, NULL);
hr = D3DAssemble(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 = pD3DAssemble(test1, strlen(test1), NULL,
defines, NULL, D3DCOMPILE_SKIP_VALIDATION,
NULL, &messages);
hr = D3DAssemble(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));
......@@ -1576,8 +1565,8 @@ static void assembleshader_test(void) {
shader = NULL;
messages = NULL;
include.ID3DInclude_iface.lpVtbl = &D3DInclude_Vtbl;
hr = pD3DAssemble(testshader, strlen(testshader), NULL, NULL, &include.ID3DInclude_iface,
D3DCOMPILE_SKIP_VALIDATION, &shader, &messages);
hr = D3DAssemble(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));
......@@ -1588,9 +1577,7 @@ static void assembleshader_test(void) {
/* NULL shader tests */
shader = NULL;
messages = NULL;
hr = pD3DAssemble(NULL, 0, NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
hr = D3DAssemble(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));
......@@ -1650,8 +1637,7 @@ static void d3dpreprocess_test(void)
/* pDefines test */
shader = NULL;
messages = NULL;
hr = ppD3DPreprocess(test1, strlen(test1), NULL,
defines, NULL, &shader, &messages);
hr = D3DPreprocess(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)
{
......@@ -1662,15 +1648,13 @@ static void d3dpreprocess_test(void)
/* NULL messages test */
shader = NULL;
hr = ppD3DPreprocess(test1, strlen(test1), NULL,
defines, NULL, &shader, NULL);
hr = D3DPreprocess(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 = ppD3DPreprocess(test1, strlen(test1), NULL,
defines, NULL, NULL, &messages);
hr = D3DPreprocess(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)
{
......@@ -1681,8 +1665,7 @@ static void d3dpreprocess_test(void)
/* quotation marks test */
shader = NULL;
messages = NULL;
hr = ppD3DPreprocess(quotation_marks_test, strlen(quotation_marks_test), NULL,
NULL, NULL, &shader, &messages);
hr = D3DPreprocess(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)
{
......@@ -1697,7 +1680,7 @@ static void d3dpreprocess_test(void)
{
shader = NULL;
messages = NULL;
hr = ppD3DPreprocess(include_test_shaders[i], strlen(include_test_shaders[i]), NULL, NULL,
hr = D3DPreprocess(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)
......@@ -1711,8 +1694,7 @@ static void d3dpreprocess_test(void)
/* NULL shader tests */
shader = NULL;
messages = NULL;
hr = ppD3DPreprocess(NULL, 0, NULL,
NULL, NULL, &shader, &messages);
hr = D3DPreprocess(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)
{
......@@ -1742,7 +1724,7 @@ static void test_disassemble_shader(void)
ID3DBlob *blob;
HRESULT hr;
hr = ppD3DDisassemble(vs_2_0, 0, 0, NULL, &blob);
hr = D3DDisassemble(vs_2_0, 0, 0, NULL, &blob);
todo_wine
#if D3D_COMPILER_VERSION == 47
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
......@@ -1750,37 +1732,15 @@ todo_wine
ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
#endif
hr = ppD3DDisassemble(vs_2_0, sizeof(vs_2_0), 0, NULL, &blob);
hr = D3DDisassemble(vs_2_0, sizeof(vs_2_0), 0, NULL, &blob);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
ID3D10Blob_Release(blob);
}
static BOOL load_d3dcompiler(void)
{
HMODULE module;
#if D3D_COMPILER_VERSION == 47
if (!(module = LoadLibraryA("d3dcompiler_47.dll"))) return FALSE;
#else
if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
#endif
pD3DAssemble = (void*)GetProcAddress(module, "D3DAssemble");
ppD3DPreprocess = (void*)GetProcAddress(module, "D3DPreprocess");
ppD3DDisassemble = (void *)GetProcAddress(module, "D3DDisassemble");
return TRUE;
}
START_TEST(asm)
{
if (!load_d3dcompiler())
{
win_skip("Could not load DLL.\n");
return;
}
preproc_test();
ps_1_1_test();
vs_1_1_test();
......
......@@ -24,9 +24,6 @@
#include "d3d11.h"
#include "wine/test.h"
static pD3DCompile ppD3DCompile;
static HRESULT (WINAPI *pD3DReflect)(const void *data, SIZE_T size, REFIID iid, void **out);
static HRESULT (WINAPI *pD3D11CreateDevice)(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type,
HMODULE swrast, UINT flags, const D3D_FEATURE_LEVEL *feature_levels, UINT levels,
UINT sdk_version, ID3D11Device **device_out, D3D_FEATURE_LEVEL *obtained_feature_level,
......@@ -49,7 +46,7 @@ static ID3D10Blob *compile_shader_(unsigned int line, const char *source, const
ID3D10Blob *blob = NULL, *errors = NULL;
HRESULT hr;
hr = ppD3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, flags, 0, &blob, &errors);
hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, flags, 0, &blob, &errors);
ok_(__FILE__, line)(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr);
if (errors)
{
......@@ -832,7 +829,7 @@ static void test_reflection(void)
if (!code)
return;
hr = pD3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
hr = D3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
&IID_ID3D11ShaderReflection, (void **)&reflection);
ok(hr == S_OK, "Got hr %#x.\n", hr);
......@@ -910,7 +907,7 @@ static void test_reflection(void)
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
code = compile_shader_flags(ps_source, "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY);
hr = pD3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
hr = D3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
&IID_ID3D11ShaderReflection, (void **)&reflection);
ok(hr == S_OK, "Got hr %#x.\n", hr);
......@@ -1140,7 +1137,7 @@ static void test_semantic_reflection(void)
continue;
}
hr = pD3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
hr = D3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
&IID_ID3D11ShaderReflection, (void **)&reflection);
ok(hr == S_OK, "Got hr %#x.\n", hr);
......@@ -1177,31 +1174,10 @@ static void test_semantic_reflection(void)
}
}
static BOOL load_d3dcompiler(void)
{
HMODULE module;
#if D3D_COMPILER_VERSION == 47
if (!(module = LoadLibraryA("d3dcompiler_47.dll"))) return FALSE;
#else
if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
#endif
ppD3DCompile = (void *)GetProcAddress(module, "D3DCompile");
pD3DReflect = (void *)GetProcAddress(module, "D3DReflect");
return TRUE;
}
START_TEST(hlsl_d3d11)
{
HMODULE mod;
if (!load_d3dcompiler())
{
win_skip("Could not load DLL.\n");
return;
}
test_reflection();
test_semantic_reflection();
......
......@@ -38,14 +38,10 @@
*/
#define D3DERR_INVALIDCALL 0x8876086c
#if D3D_COMPILER_VERSION
static HRESULT (WINAPI *pD3DReflect)(const void *, SIZE_T, REFIID, void **);
#endif
static HRESULT call_reflect(const void *data, SIZE_T data_size, REFIID riid, void **reflection)
{
#if D3D_COMPILER_VERSION
return pD3DReflect(data, data_size, riid, reflection);
return D3DReflect(data, data_size, riid, reflection);
#else
return D3D10ReflectShader(data, data_size, (ID3D10ShaderReflection **)reflection);
#endif
......@@ -93,7 +89,7 @@ static void test_reflection_references(void)
HRESULT hr, expected;
ULONG count;
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = D3DReflect(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);
......@@ -117,22 +113,22 @@ static void test_reflection_references(void)
#else
expected = E_NOINTERFACE;
#endif
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection, (void **)&ref10);
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection, (void **)&ref10);
ok(hr == expected || broken(hr == E_NOINTERFACE) /* Windows 8 */,
"D3DReflect failed, got %x, expected %x\n", hr, expected);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == expected || broken(hr == E_NOINTERFACE) /* Windows 8 */,
"D3DReflect failed, got %x, expected %x\n", hr, expected);
hr = pD3DReflect(NULL, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = D3DReflect(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 = pD3DReflect(NULL, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = D3DReflect(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 = pD3DReflect(test_reflection_blob, 31, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = D3DReflect(test_reflection_blob, 31, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
#if D3D_COMPILER_VERSION >= 46
......@@ -140,19 +136,19 @@ static void test_reflection_references(void)
#else
expected = E_FAIL;
#endif
hr = pD3DReflect(test_reflection_blob, 32, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = D3DReflect(test_reflection_blob, 32, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
hr = pD3DReflect(test_reflection_blob, 31, &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = D3DReflect(test_reflection_blob, 31, &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == D3DERR_INVALIDCALL, "Got %x, expected %x.\n", hr, D3DERR_INVALIDCALL);
hr = pD3DReflect(test_reflection_blob, 32, &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = D3DReflect(test_reflection_blob, 32, &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D11ShaderReflection, (void **)&ref11);
hr = D3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D11ShaderReflection, (void **)&ref11);
ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
}
#endif
......@@ -2122,32 +2118,8 @@ static const D3D12_SHADER_INPUT_BIND_DESC test_reflection_bound_resources_sm51_r
{"c2", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, 0, D3D_SRV_DIMENSION_UNKNOWN, 0, 1, 1},
};
static BOOL load_d3dreflect(void)
{
#if D3D_COMPILER_VERSION == 47
static const char filename[] = "d3dcompiler_47.dll";
#elif D3D_COMPILER_VERSION
static const char filename[] = "d3dcompiler_43.dll";
#endif
#if D3D_COMPILER_VERSION
HMODULE module;
if (!(module = LoadLibraryA(filename)))
return FALSE;
pD3DReflect = (void*)GetProcAddress(module, "D3DReflect");
#endif
return TRUE;
}
START_TEST(reflection)
{
if (!load_d3dreflect())
{
win_skip("Could not load DLL.\n");
return;
}
#if D3D_COMPILER_VERSION
test_reflection_references();
test_reflection_interfaces();
......
TESTDLL = d3dcompiler_47.dll
IMPORTS = d3d9 user32
IMPORTS = d3d9 user32 d3dcompiler
EXTRADEFS = -DD3D_COMPILER_VERSION=47
PARENTSRC = ../../d3dcompiler_43/tests
......
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