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,7 +58,7 @@ 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,
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);
......@@ -1412,7 +1414,7 @@ static void failure_test(void) {
{
shader = NULL;
messages = NULL;
hr = D3DAssemble(tests[i], strlen(tests[i]), NULL,
hr = pD3DAssemble(tests[i], strlen(tests[i]), NULL,
NULL, NULL, D3DCOMPILE_SKIP_VALIDATION,
&shader, &messages);
ok(hr == D3DXERR_INVALIDDATA, "Failure test, shader %d: "
......@@ -1540,7 +1542,7 @@ static void assembleshader_test(void) {
/* defines test */
shader = NULL;
messages = NULL;
hr = D3DAssemble(test1, strlen(test1), NULL,
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);
......@@ -1552,7 +1554,7 @@ static void assembleshader_test(void) {
/* NULL messages test */
shader = NULL;
hr = D3DAssemble(test1, strlen(test1), 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);
......@@ -1560,7 +1562,7 @@ static void assembleshader_test(void) {
/* NULL shader test */
messages = NULL;
hr = D3DAssemble(test1, strlen(test1), NULL,
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);
......@@ -1573,7 +1575,7 @@ 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,
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) {
......@@ -1585,7 +1587,7 @@ static void assembleshader_test(void) {
/* NULL shader tests */
shader = NULL;
messages = NULL;
hr = D3DAssemble(NULL, 0, NULL,
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);
......@@ -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();
......
......@@ -33,6 +33,10 @@
*/
#define D3DERR_INVALIDCALL 0x8876086c
static typeof(D3DCreateBlob) *pD3DCreateBlob;
static typeof(D3DGetBlobPart) *pD3DGetBlobPart;
static typeof(D3DStripShader) *pD3DStripShader;
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
......@@ -55,13 +59,13 @@ static void test_create_blob(void)
HRESULT hr;
ULONG refcount;
hr = D3DCreateBlob(1, NULL);
hr = pD3DCreateBlob(1, NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DCreateBlob failed with %x\n", hr);
hr = D3DCreateBlob(0, NULL);
hr = pD3DCreateBlob(0, NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DCreateBlob failed with %x\n", hr);
hr = D3DCreateBlob(0, &blob);
hr = pD3DCreateBlob(0, &blob);
ok(hr == S_OK, "D3DCreateBlob failed with %x\n", hr);
refcount = ID3D10Blob_Release(blob);
......@@ -120,40 +124,40 @@ static void test_get_blob_part(void)
SIZE_T size;
UINT i;
hr = D3DCreateBlob(1, &blob2);
hr = pD3DCreateBlob(1, &blob2);
ok(hr == S_OK, "D3DCreateBlob failed with %x\n", hr);
blob = blob2;
/* invalid cases */
hr = D3DGetBlobPart(NULL, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(NULL, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
ok(blob2 == blob, "D3DGetBlobPart failed got %p, expected %p\n", blob, blob2);
hr = D3DGetBlobPart(NULL, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(NULL, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
ok(blob2 == blob, "D3DGetBlobPart failed got %p, expected %p\n", blob, blob2);
hr = D3DGetBlobPart(NULL, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
hr = pD3DGetBlobPart(NULL, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
hr = D3DGetBlobPart(NULL, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
hr = pD3DGetBlobPart(NULL, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
hr = D3DGetBlobPart(test_blob_part, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
ok(blob2 == blob, "D3DGetBlobPart failed got %p, expected %p\n", blob, blob2);
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
hr = D3DGetBlobPart(test_blob_part, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
hr = pD3DGetBlobPart(test_blob_part, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 1, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 1, &blob);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
ok(blob2 == blob, "D3DGetBlobPart failed got %p, expected %p\n", blob, blob2);
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], 0xffffffff, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], 0xffffffff, 0, &blob);
ok(hr == D3DERR_INVALIDCALL, "D3DGetBlobPart failed with %x\n", hr);
ok(blob2 == blob, "D3DGetBlobPart failed got %p, expected %p\n", blob, blob2);
......@@ -161,7 +165,7 @@ static void test_get_blob_part(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_INPUT_SIGNATURE_BLOB */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -173,7 +177,7 @@ static void test_get_blob_part(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
if (parts[i] == D3D_BLOB_INPUT_SIGNATURE_BLOB)
{
......@@ -192,7 +196,7 @@ static void test_get_blob_part(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_OUTPUT_SIGNATURE_BLOB */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_OUTPUT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_OUTPUT_SIGNATURE_BLOB, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -204,7 +208,7 @@ static void test_get_blob_part(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
if (parts[i] == D3D_BLOB_OUTPUT_SIGNATURE_BLOB)
{
......@@ -223,7 +227,7 @@ static void test_get_blob_part(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -236,7 +240,7 @@ static void test_get_blob_part(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
if (parts[i] == D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB
|| parts[i] == D3D_BLOB_INPUT_SIGNATURE_BLOB
......@@ -257,19 +261,19 @@ static void test_get_blob_part(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, 0, &blob);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
/* D3D_BLOB_ALL_SIGNATURE_BLOB */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_ALL_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_ALL_SIGNATURE_BLOB, 0, &blob);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
/* D3D_BLOB_DEBUG_INFO */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_DEBUG_INFO, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_DEBUG_INFO, 0, &blob);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
/* D3D_BLOB_LEGACY_SHADER */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_LEGACY_SHADER, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_LEGACY_SHADER, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -281,7 +285,7 @@ static void test_get_blob_part(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
/* There isn't a full DXBC blob returned for D3D_BLOB_LEGACY_SHADER */
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
}
......@@ -289,7 +293,7 @@ static void test_get_blob_part(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_XNA_PREPASS_SHADER */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_XNA_PREPASS_SHADER, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_XNA_PREPASS_SHADER, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -301,7 +305,7 @@ static void test_get_blob_part(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
/* There isn't a full DXBC blob returned for D3D_BLOB_XNA_PREPASS_SHADER */
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
}
......@@ -309,7 +313,7 @@ static void test_get_blob_part(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_XNA_SHADER */
hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_XNA_SHADER, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_XNA_SHADER, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -321,7 +325,7 @@ static void test_get_blob_part(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
/* There isn't a full DXBC blob returned for D3D_BLOB_XNA_SHADER */
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
}
......@@ -329,35 +333,35 @@ static void test_get_blob_part(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* check corner cases for D3DStripShader */
hr = D3DStripShader(test_blob_part, test_blob_part[6], 0xffffffff, &blob);
hr = pD3DStripShader(test_blob_part, test_blob_part[6], 0xffffffff, &blob);
ok(hr == S_OK, "D3DStripShader failed, got %x, expected %x\n", hr, S_OK);
refcount = ID3D10Blob_Release(blob);
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
hr = D3DStripShader(test_blob_part, test_blob_part[6], 0, &blob);
hr = pD3DStripShader(test_blob_part, test_blob_part[6], 0, &blob);
ok(hr == S_OK, "D3DStripShader failed, got %x, expected %x\n", hr, S_OK);
refcount = ID3D10Blob_Release(blob);
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
hr = D3DStripShader(NULL, test_blob_part[6], 0, &blob);
hr = pD3DStripShader(NULL, test_blob_part[6], 0, &blob);
ok(hr == D3DERR_INVALIDCALL, "D3DStripShader failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
hr = D3DStripShader(test_blob_part, 2, 0, &blob);
hr = pD3DStripShader(test_blob_part, 2, 0, &blob);
ok(hr == D3DERR_INVALIDCALL, "D3DStripShader failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
hr = D3DStripShader(test_blob_part, test_blob_part[6], 0, NULL);
hr = pD3DStripShader(test_blob_part, test_blob_part[6], 0, NULL);
ok(hr == E_FAIL, "D3DStripShader failed, got %x, expected %x\n", hr, E_FAIL);
hr = D3DStripShader(NULL, test_blob_part[6], 0, NULL);
hr = pD3DStripShader(NULL, test_blob_part[6], 0, NULL);
ok(hr == E_FAIL, "D3DStripShader failed, got %x, expected %x\n", hr, E_FAIL);
hr = D3DStripShader(test_blob_part, 0, 0, NULL);
hr = pD3DStripShader(test_blob_part, 0, 0, NULL);
ok(hr == E_FAIL, "D3DStripShader failed, got %x, expected %x\n", hr, E_FAIL);
/* D3DCOMPILER_STRIP_DEBUG_INFO */
hr = D3DStripShader(test_blob_part, test_blob_part[6], D3DCOMPILER_STRIP_DEBUG_INFO, &blob);
hr = pD3DStripShader(test_blob_part, test_blob_part[6], D3DCOMPILER_STRIP_DEBUG_INFO, &blob);
ok(hr == S_OK, "D3DStripShader failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -374,14 +378,14 @@ static void test_get_blob_part(void)
ok(TAG_ISGN == *(dword+149), "ISGN got %#x, expected %#x.\n", *(dword+149), TAG_ISGN);
ok(TAG_OSGN == *(dword+171), "OSGN got %#x, expected %#x.\n", *(dword+171), TAG_OSGN);
hr = D3DGetBlobPart(dword, size, D3D_BLOB_DEBUG_INFO, 0, &blob2);
hr = pD3DGetBlobPart(dword, size, D3D_BLOB_DEBUG_INFO, 0, &blob2);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
refcount = ID3D10Blob_Release(blob);
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3DCOMPILER_STRIP_REFLECTION_DATA */
hr = D3DStripShader(test_blob_part, test_blob_part[6], D3DCOMPILER_STRIP_REFLECTION_DATA, &blob);
hr = pD3DStripShader(test_blob_part, test_blob_part[6], D3DCOMPILER_STRIP_REFLECTION_DATA, &blob);
ok(hr == S_OK, "D3DStripShader failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -596,7 +600,7 @@ static void test_get_blob_part2(void)
UINT i;
/* D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB */
hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -608,7 +612,7 @@ static void test_get_blob_part2(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
if (parts[i] == D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB)
{
......@@ -627,7 +631,7 @@ static void test_get_blob_part2(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_ALL_SIGNATURE_BLOB */
hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_ALL_SIGNATURE_BLOB, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_ALL_SIGNATURE_BLOB, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -641,7 +645,7 @@ static void test_get_blob_part2(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
if (parts[i] == D3D_BLOB_ALL_SIGNATURE_BLOB
|| parts[i] == D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB
......@@ -664,7 +668,7 @@ static void test_get_blob_part2(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_DEBUG_INFO */
hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_DEBUG_INFO, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_DEBUG_INFO, 0, &blob);
ok(hr == S_OK, "D3DGetBlobPart failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -676,7 +680,7 @@ static void test_get_blob_part2(void)
for (i = 0; i < ARRAY_SIZE(parts); i++)
{
/* There isn't a full DXBC blob returned for D3D_BLOB_DEBUG_INFO */
hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
hr = pD3DGetBlobPart(dword, size, parts[i], 0, &blob2);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
}
......@@ -684,19 +688,19 @@ static void test_get_blob_part2(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3D_BLOB_LEGACY_SHADER */
hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_LEGACY_SHADER, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_LEGACY_SHADER, 0, &blob);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
/* D3D_BLOB_XNA_PREPASS_SHADER */
hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_XNA_PREPASS_SHADER, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_XNA_PREPASS_SHADER, 0, &blob);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
/* D3D_BLOB_XNA_SHADER */
hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_XNA_SHADER, 0, &blob);
hr = pD3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_XNA_SHADER, 0, &blob);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
/* D3DCOMPILER_STRIP_DEBUG_INFO */
hr = D3DStripShader(test_blob_part2, test_blob_part2[6], D3DCOMPILER_STRIP_DEBUG_INFO, &blob);
hr = pD3DStripShader(test_blob_part2, test_blob_part2[6], D3DCOMPILER_STRIP_DEBUG_INFO, &blob);
ok(hr == S_OK, "D3DStripShader failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -711,14 +715,14 @@ static void test_get_blob_part2(void)
ok(TAG_SHEX == *(dword+119), "SHEX got %#x, expected %#x.\n", *(dword+119), TAG_SHEX);
ok(TAG_STAT == *(dword+199), "STAT got %#x, expected %#x.\n", *(dword+199), TAG_STAT);
hr = D3DGetBlobPart(dword, size, D3D_BLOB_DEBUG_INFO, 0, &blob2);
hr = pD3DGetBlobPart(dword, size, D3D_BLOB_DEBUG_INFO, 0, &blob2);
ok(hr == E_FAIL, "D3DGetBlobPart failed, got %x, expected %x\n", hr, E_FAIL);
refcount = ID3D10Blob_Release(blob);
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
/* D3DCOMPILER_STRIP_REFLECTION_DATA */
hr = D3DStripShader(test_blob_part2, test_blob_part2[6], D3DCOMPILER_STRIP_REFLECTION_DATA, &blob);
hr = pD3DStripShader(test_blob_part2, test_blob_part2[6], D3DCOMPILER_STRIP_REFLECTION_DATA, &blob);
ok(hr == S_OK, "D3DStripShader failed, got %x, expected %x\n", hr, S_OK);
size = ID3D10Blob_GetBufferSize(blob);
......@@ -736,8 +740,26 @@ static void test_get_blob_part2(void)
ok(!refcount, "ID3DBlob has %u references left\n", refcount);
}
static BOOL load_d3dcompiler(void)
{
HMODULE module;
if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
pD3DCreateBlob = (void*)GetProcAddress(module, "D3DCreateBlob");
pD3DGetBlobPart = (void*)GetProcAddress(module, "D3DGetBlobPart");
pD3DStripShader = (void*)GetProcAddress(module, "D3DStripShader");
return TRUE;
}
START_TEST(blob)
{
if (!load_d3dcompiler())
{
win_skip("Could not load d3dcompiler_43.dll\n");
return;
}
test_create_blob();
test_get_blob_part();
test_get_blob_part2();
......
......@@ -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