2009-09-16 00:41:33 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Stefan Dösinger
|
|
|
|
* Copyright (C) 2009 Matteo Bruni
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#define COBJMACROS
|
2011-01-26 00:27:49 +01:00
|
|
|
#define CONST_VTABLE
|
2009-09-16 00:41:33 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#include <d3dx9.h>
|
|
|
|
|
|
|
|
#include "resources.h"
|
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
static char temp_path[MAX_PATH];
|
|
|
|
|
|
|
|
static BOOL create_file(const char *filename, const char *data, const unsigned int size, char *out_path)
|
2009-09-16 00:41:33 +02:00
|
|
|
{
|
2014-08-25 20:36:54 +02:00
|
|
|
DWORD written;
|
2009-09-16 00:41:33 +02:00
|
|
|
HANDLE hfile;
|
2014-08-25 20:36:54 +02:00
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
if (!*temp_path)
|
|
|
|
GetTempPathA(sizeof(temp_path), temp_path);
|
2009-09-16 00:41:33 +02:00
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
strcpy(path, temp_path);
|
|
|
|
strcat(path, filename);
|
|
|
|
hfile = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
|
|
|
if (hfile == INVALID_HANDLE_VALUE)
|
|
|
|
return FALSE;
|
2009-09-16 00:41:33 +02:00
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
if (WriteFile(hfile, data, size, &written, NULL))
|
2009-09-16 00:41:33 +02:00
|
|
|
{
|
|
|
|
CloseHandle(hfile);
|
2014-08-25 20:36:54 +02:00
|
|
|
|
|
|
|
if (out_path)
|
|
|
|
strcpy(out_path, path);
|
|
|
|
return TRUE;
|
2009-09-16 00:41:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(hfile);
|
2014-08-25 20:36:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_file(const char *filename)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
strcpy(path, temp_path);
|
|
|
|
strcat(path, filename);
|
|
|
|
DeleteFileA(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL create_directory(const char *name)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
strcpy(path, temp_path);
|
|
|
|
strcat(path, name);
|
|
|
|
return CreateDirectoryA(path, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_directory(const char *name)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
strcpy(path, temp_path);
|
|
|
|
strcat(path, name);
|
|
|
|
RemoveDirectoryA(path);
|
2009-09-16 00:41:33 +02:00
|
|
|
}
|
|
|
|
|
2013-09-02 09:45:44 +02:00
|
|
|
static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE include_type,
|
|
|
|
const char *filename, const void *parent_data, const void **data, UINT *bytes)
|
|
|
|
{
|
2009-09-16 00:41:33 +02:00
|
|
|
char *buffer;
|
2013-09-03 16:29:44 +02:00
|
|
|
static const char shader[] =
|
|
|
|
"#include \"incl.vsh\"\n"
|
|
|
|
"mov REGISTER, v0\n";
|
|
|
|
static const char include[] = "#define REGISTER r0\nvs.1.1\n";
|
|
|
|
static const char include2[] = "#include \"incl3.vsh\"\n";
|
|
|
|
static const char include3[] = "vs.1.1\n";
|
2009-09-16 00:41:33 +02:00
|
|
|
|
2013-09-03 16:29:44 +02:00
|
|
|
trace("filename %s.\n", filename);
|
|
|
|
trace("parent_data %p: %s.\n", parent_data, parent_data ? (char *)parent_data : "(null)");
|
2009-09-16 00:41:33 +02:00
|
|
|
|
2013-09-03 16:29:44 +02:00
|
|
|
if (!strcmp(filename, "shader.vsh"))
|
|
|
|
{
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(shader));
|
|
|
|
memcpy(buffer, shader, sizeof(shader));
|
|
|
|
*bytes = sizeof(shader);
|
|
|
|
}
|
|
|
|
else if (!strcmp(filename, "incl.vsh"))
|
|
|
|
{
|
2010-07-28 17:32:42 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include));
|
2013-09-03 16:29:44 +02:00
|
|
|
memcpy(buffer, include, sizeof(include));
|
2010-07-28 17:32:42 +02:00
|
|
|
*bytes = sizeof(include);
|
2013-09-03 16:29:44 +02:00
|
|
|
/* This is included from the first D3DXAssembleShader with non-null ID3DXInclude test
|
|
|
|
* (parent_data == NULL) and from shader.vsh / shader[] (with matching parent_data).
|
|
|
|
* Allow both cases. */
|
|
|
|
ok(parent_data == NULL || !strncmp(shader, parent_data, strlen(shader)), "wrong parent_data value\n");
|
2010-07-28 17:32:42 +02:00
|
|
|
}
|
2013-09-03 16:29:44 +02:00
|
|
|
else if (!strcmp(filename, "incl2.vsh"))
|
|
|
|
{
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2));
|
|
|
|
memcpy(buffer, include2, sizeof(include2));
|
|
|
|
*bytes = sizeof(include2);
|
|
|
|
}
|
|
|
|
else if (!strcmp(filename, "incl3.vsh"))
|
|
|
|
{
|
2010-07-28 17:32:42 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include3));
|
2013-09-03 16:29:44 +02:00
|
|
|
memcpy(buffer, include3, sizeof(include3));
|
2010-07-28 17:32:42 +02:00
|
|
|
*bytes = sizeof(include3);
|
|
|
|
/* Also check for the correct parent_data content */
|
|
|
|
ok(parent_data != NULL && !strncmp(include2, parent_data, strlen(include2)), "wrong parent_data value\n");
|
|
|
|
}
|
2014-08-25 20:36:52 +02:00
|
|
|
else if (!strcmp(filename, "include/incl3.vsh"))
|
|
|
|
{
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include));
|
|
|
|
memcpy(buffer, include, sizeof(include));
|
|
|
|
*bytes = sizeof(include);
|
|
|
|
ok(!parent_data, "wrong parent_data value\n");
|
|
|
|
}
|
2013-09-03 16:29:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected #include for file %s.\n", filename);
|
|
|
|
return D3DERR_INVALIDCALL;
|
2010-07-28 17:32:42 +02:00
|
|
|
}
|
2009-09-16 00:41:33 +02:00
|
|
|
*data = buffer;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-03 09:47:25 +02:00
|
|
|
static HRESULT WINAPI testD3DXInclude_close(ID3DXInclude *iface, const void *data)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, (void *)data);
|
2009-09-16 00:41:33 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID3DXIncludeVtbl D3DXInclude_Vtbl = {
|
|
|
|
testD3DXInclude_open,
|
|
|
|
testD3DXInclude_close
|
|
|
|
};
|
|
|
|
|
|
|
|
struct D3DXIncludeImpl {
|
2011-01-26 00:27:49 +01:00
|
|
|
ID3DXInclude ID3DXInclude_iface;
|
2009-09-16 00:41:33 +02:00
|
|
|
};
|
|
|
|
|
2013-09-03 16:29:44 +02:00
|
|
|
static void assembleshader_test(void)
|
|
|
|
{
|
|
|
|
static const char test1[] =
|
2009-09-16 00:41:33 +02:00
|
|
|
"vs.1.1\n"
|
2013-09-03 16:29:44 +02:00
|
|
|
"mov DEF2, v0\n";
|
|
|
|
static const char testincl[] =
|
2009-09-16 00:41:33 +02:00
|
|
|
"#define REGISTER r0\n"
|
2013-09-03 16:29:44 +02:00
|
|
|
"vs.1.1\n";
|
|
|
|
static const char testshader[] =
|
2009-09-16 00:41:33 +02:00
|
|
|
"#include \"incl.vsh\"\n"
|
2013-09-03 16:29:44 +02:00
|
|
|
"mov REGISTER, v0\n";
|
|
|
|
static const char testshader2[] =
|
2010-07-28 17:32:42 +02:00
|
|
|
"#include \"incl2.vsh\"\n"
|
2013-09-03 16:29:44 +02:00
|
|
|
"mov REGISTER, v0\n";
|
|
|
|
static const char testshader3[] =
|
2010-07-28 17:32:42 +02:00
|
|
|
"#include \"include/incl3.vsh\"\n"
|
2013-09-03 16:29:44 +02:00
|
|
|
"mov REGISTER, v0\n";
|
|
|
|
static const char testincl3[] =
|
|
|
|
"#include \"incl4.vsh\"\n";
|
|
|
|
static const char testincl4_ok[] =
|
2010-09-03 15:25:23 +02:00
|
|
|
"#define REGISTER r0\n"
|
2013-09-03 16:29:44 +02:00
|
|
|
"vs.1.1\n";
|
|
|
|
static const char testincl4_wrong[] =
|
|
|
|
"#error \"wrong include\"\n";
|
2009-09-16 00:41:33 +02:00
|
|
|
HRESULT hr;
|
2012-12-02 18:53:17 +01:00
|
|
|
ID3DXBuffer *shader, *messages;
|
2013-09-03 16:29:44 +02:00
|
|
|
static const D3DXMACRO defines[] = {
|
2009-09-16 00:41:33 +02:00
|
|
|
{
|
|
|
|
"DEF1", "10 + 15"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"DEF2", "r0"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL, NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
struct D3DXIncludeImpl include;
|
2014-08-25 20:36:54 +02:00
|
|
|
char shader_vsh_path[MAX_PATH], shader3_vsh_path[MAX_PATH];
|
2009-09-16 00:41:33 +02:00
|
|
|
|
|
|
|
/* pDefines test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShader(test1, strlen(test1),
|
|
|
|
defines, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "pDefines test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
2010-06-05 17:12:14 +02:00
|
|
|
/* NULL messages test */
|
|
|
|
shader = NULL;
|
|
|
|
hr = D3DXAssembleShader(test1, strlen(test1),
|
|
|
|
defines, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, NULL);
|
|
|
|
ok(hr == D3D_OK, "NULL messages test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
/* NULL shader test */
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShader(test1, strlen(test1),
|
|
|
|
defines, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
NULL, &messages);
|
|
|
|
ok(hr == D3D_OK, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
|
2009-09-16 00:41:33 +02:00
|
|
|
/* pInclude test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2011-01-26 00:27:49 +01:00
|
|
|
include.ID3DXInclude_iface.lpVtbl = &D3DXInclude_Vtbl;
|
|
|
|
hr = D3DXAssembleShader(testshader, strlen(testshader), NULL, &include.ID3DXInclude_iface,
|
|
|
|
D3DXSHADER_SKIPVALIDATION, &shader, &messages);
|
2009-09-16 00:41:33 +02:00
|
|
|
ok(hr == D3D_OK, "pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
2010-07-28 17:32:42 +02:00
|
|
|
/* "unexpected #include file from memory" test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShader(testshader, strlen(testshader),
|
|
|
|
NULL, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3DXERR_INVALIDDATA, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
/* recursive #include test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2011-01-26 00:27:49 +01:00
|
|
|
hr = D3DXAssembleShader(testshader2, strlen(testshader2), NULL, &include.ID3DXInclude_iface,
|
|
|
|
D3DXSHADER_SKIPVALIDATION, &shader, &messages);
|
2010-07-28 17:32:42 +02:00
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("recursive D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
2014-08-25 20:36:52 +02:00
|
|
|
/* #include with a path. */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShader(testshader3, strlen(testshader3), NULL, &include.ID3DXInclude_iface,
|
|
|
|
D3DXSHADER_SKIPVALIDATION, &shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000ffff);
|
|
|
|
if (messages)
|
|
|
|
{
|
|
|
|
trace("Path search D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if (shader)
|
|
|
|
ID3DXBuffer_Release(shader);
|
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
if (create_file("shader.vsh", testshader, sizeof(testshader) - 1, shader_vsh_path))
|
|
|
|
{
|
|
|
|
create_file("incl.vsh", testincl, sizeof(testincl) - 1, NULL);
|
2010-07-28 17:32:42 +02:00
|
|
|
|
|
|
|
/* D3DXAssembleShaderFromFile + #include test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2014-08-25 20:36:54 +02:00
|
|
|
hr = D3DXAssembleShaderFromFileA(shader_vsh_path,
|
2010-07-28 17:32:42 +02:00
|
|
|
NULL, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShaderFromFile test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
2009-09-16 00:41:33 +02:00
|
|
|
|
|
|
|
/* D3DXAssembleShaderFromFile + pInclude test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2011-01-26 00:27:49 +01:00
|
|
|
hr = D3DXAssembleShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface,
|
|
|
|
D3DXSHADER_SKIPVALIDATION, &shader, &messages);
|
2009-09-16 00:41:33 +02:00
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShaderFromFile + pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
create_file("shader3.vsh", testshader3, sizeof(testshader3) - 1, shader3_vsh_path);
|
|
|
|
create_file("incl4.vsh", testincl4_wrong, sizeof(testincl4_wrong) - 1, NULL);
|
|
|
|
if (create_directory("include"))
|
|
|
|
{
|
|
|
|
create_file("include\\incl3.vsh", testincl3, sizeof(testincl3) - 1, NULL);
|
|
|
|
create_file("include\\incl4.vsh", testincl4_ok, sizeof(testincl4_ok) - 1, NULL);
|
2010-07-28 17:32:42 +02:00
|
|
|
|
|
|
|
/* path search #include test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2014-08-25 20:36:54 +02:00
|
|
|
hr = D3DXAssembleShaderFromFileA(shader3_vsh_path, NULL, NULL,
|
2010-07-28 17:32:42 +02:00
|
|
|
D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShaderFromFile path search test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShaderFromFile path search messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
} else skip("Couldn't create \"include\" directory\n");
|
2013-09-03 16:29:44 +02:00
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
delete_file("shader.vsh");
|
|
|
|
delete_file("incl.vsh");
|
|
|
|
delete_file("shader3.vsh");
|
|
|
|
delete_file("incl4.vsh");
|
|
|
|
delete_file("include\\incl3.vsh");
|
|
|
|
delete_file("include\\incl4.vsh");
|
|
|
|
delete_directory("include");
|
2013-09-03 16:29:44 +02:00
|
|
|
|
|
|
|
/* The main shader is also to be loaded through the ID3DXInclude object. */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface,
|
|
|
|
D3DXSHADER_SKIPVALIDATION, &shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n",
|
|
|
|
hr, hr & 0x0000ffff);
|
|
|
|
if (messages)
|
|
|
|
{
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if (shader)
|
|
|
|
ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2020-09-30 23:14:53 +02:00
|
|
|
hr = D3DXAssembleShaderFromFileW(L"shader.vsh", NULL, &include.ID3DXInclude_iface,
|
2013-09-03 16:29:44 +02:00
|
|
|
D3DXSHADER_SKIPVALIDATION, &shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n",
|
|
|
|
hr, hr & 0x0000ffff);
|
|
|
|
if (messages)
|
|
|
|
{
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if (shader)
|
|
|
|
ID3DXBuffer_Release(shader);
|
2010-07-28 17:32:42 +02:00
|
|
|
} else skip("Couldn't create \"shader.vsh\"\n");
|
2010-03-28 21:16:09 +02:00
|
|
|
|
2009-09-16 00:41:33 +02:00
|
|
|
/* NULL shader tests */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShader(NULL, 0,
|
|
|
|
NULL, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3DXERR_INVALIDDATA, "NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShaderFromFileA("nonexistent.vsh",
|
|
|
|
NULL, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3DXERR_INVALIDDATA || hr == E_FAIL, /* I get this on WinXP */
|
|
|
|
"D3DXAssembleShaderFromFile nonexistent file test failed with error 0x%x - %d\n",
|
|
|
|
hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
/* D3DXAssembleShaderFromResource test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShaderFromResourceA(NULL, MAKEINTRESOURCEA(IDB_ASMSHADER),
|
|
|
|
NULL, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXAssembleShaderFromResource test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
/* D3DXAssembleShaderFromResource with missing shader resource test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXAssembleShaderFromResourceA(NULL, "notexisting",
|
|
|
|
NULL, NULL, D3DXSHADER_SKIPVALIDATION,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3DXERR_INVALIDDATA, "D3DXAssembleShaderFromResource NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXAssembleShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
}
|
|
|
|
|
2013-09-03 16:29:44 +02:00
|
|
|
static void d3dxpreprocess_test(void)
|
|
|
|
{
|
|
|
|
static const char testincl[] =
|
|
|
|
"#define REGISTER r0\n"
|
|
|
|
"vs.1.1\n";
|
|
|
|
static const char testshader[] =
|
|
|
|
"#include \"incl.vsh\"\n"
|
|
|
|
"mov REGISTER, v0\n";
|
|
|
|
static const char testshader3[] =
|
|
|
|
"#include \"include/incl3.vsh\"\n"
|
|
|
|
"mov REGISTER, v0\n";
|
|
|
|
static const char testincl3[] =
|
|
|
|
"#include \"incl4.vsh\"\n";
|
|
|
|
static const char testincl4_ok[] =
|
|
|
|
"#define REGISTER r0\n"
|
|
|
|
"vs.1.1\n";
|
|
|
|
static const char testincl4_wrong[] =
|
|
|
|
"#error \"wrong include\"\n";
|
2010-09-09 18:41:39 +02:00
|
|
|
HRESULT hr;
|
2012-12-02 18:53:17 +01:00
|
|
|
ID3DXBuffer *shader, *messages;
|
2014-08-25 20:36:54 +02:00
|
|
|
char shader_vsh_path[MAX_PATH], shader3_vsh_path[MAX_PATH];
|
2013-09-03 16:29:44 +02:00
|
|
|
static struct D3DXIncludeImpl include = {{&D3DXInclude_Vtbl}};
|
2010-09-09 18:41:39 +02:00
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
if (create_file("shader.vsh", testshader, sizeof(testshader) - 1, shader_vsh_path))
|
|
|
|
{
|
|
|
|
create_file("incl.vsh", testincl, sizeof(testincl) - 1, NULL);
|
|
|
|
create_file("shader3.vsh", testshader3, sizeof(testshader3) - 1, shader3_vsh_path);
|
|
|
|
create_file("incl4.vsh", testincl4_wrong, sizeof(testincl4_wrong) - 1, NULL);
|
|
|
|
if (create_directory("include"))
|
|
|
|
{
|
|
|
|
create_file("include\\incl3.vsh", testincl3, sizeof(testincl3) - 1, NULL);
|
|
|
|
create_file("include\\incl4.vsh", testincl4_ok, sizeof(testincl4_ok) - 1, NULL);
|
2010-09-09 18:41:39 +02:00
|
|
|
|
|
|
|
/* path search #include test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2014-08-25 20:36:54 +02:00
|
|
|
hr = D3DXPreprocessShaderFromFileA(shader3_vsh_path, NULL, NULL,
|
2010-09-09 18:41:39 +02:00
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile path search test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXPreprocessShaderFromFile path search messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
} else skip("Couldn't create \"include\" directory\n");
|
|
|
|
|
|
|
|
/* D3DXPreprocessShaderFromFile + #include test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2014-08-25 20:36:54 +02:00
|
|
|
hr = D3DXPreprocessShaderFromFileA(shader_vsh_path,
|
2010-09-09 18:41:39 +02:00
|
|
|
NULL, NULL,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXPreprocessShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
/* D3DXPreprocessShaderFromFile + pInclude test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2011-01-26 00:27:49 +01:00
|
|
|
hr = D3DXPreprocessShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface,
|
2010-09-09 18:41:39 +02:00
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile + pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXPreprocessShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
2013-09-03 16:29:44 +02:00
|
|
|
|
2014-08-25 20:36:54 +02:00
|
|
|
delete_file("shader.vsh");
|
|
|
|
delete_file("incl.vsh");
|
|
|
|
delete_file("shader3.vsh");
|
|
|
|
delete_file("incl4.vsh");
|
|
|
|
delete_file("include\\incl3.vsh");
|
|
|
|
delete_file("include\\incl4.vsh");
|
|
|
|
delete_directory("include");
|
2013-09-03 16:29:44 +02:00
|
|
|
|
|
|
|
/* The main shader is also to be loaded through the ID3DXInclude object. */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXPreprocessShaderFromFileA("shader.vsh", NULL, &include.ID3DXInclude_iface,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n",
|
|
|
|
hr, hr & 0x0000ffff);
|
|
|
|
if (messages)
|
|
|
|
{
|
|
|
|
trace("D3DXPreprocessShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if (shader)
|
|
|
|
ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
2020-09-30 23:14:53 +02:00
|
|
|
hr = D3DXPreprocessShaderFromFileW(L"shader.vsh", NULL, &include.ID3DXInclude_iface,
|
2013-09-03 16:29:44 +02:00
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXPreprocessShaderFromFile + pInclude main shader test failed with error 0x%x - %d\n",
|
|
|
|
hr, hr & 0x0000ffff);
|
|
|
|
if (messages)
|
|
|
|
{
|
|
|
|
trace("D3DXPreprocessShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if (shader)
|
|
|
|
ID3DXBuffer_Release(shader);
|
2010-09-09 18:41:39 +02:00
|
|
|
} else skip("Couldn't create \"shader.vsh\"\n");
|
|
|
|
|
|
|
|
/* NULL shader tests */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXPreprocessShaderFromFileA("nonexistent.vsh",
|
|
|
|
NULL, NULL,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3DXERR_INVALIDDATA || hr == E_FAIL, /* I get this on WinXP */
|
|
|
|
"D3DXPreprocessShaderFromFile nonexistent file test failed with error 0x%x - %d\n",
|
|
|
|
hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXPreprocessShaderFromFile messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
/* D3DXPreprocessShaderFromResource test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXPreprocessShaderFromResourceA(NULL, MAKEINTRESOURCEA(IDB_ASMSHADER),
|
|
|
|
NULL, NULL,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3D_OK, "D3DXPreprocessShaderFromResource test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXPreprocessShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
|
|
|
|
/* D3DXPreprocessShaderFromResource with missing shader resource test */
|
|
|
|
shader = NULL;
|
|
|
|
messages = NULL;
|
|
|
|
hr = D3DXPreprocessShaderFromResourceA(NULL, "notexisting",
|
|
|
|
NULL, NULL,
|
|
|
|
&shader, &messages);
|
|
|
|
ok(hr == D3DXERR_INVALIDDATA, "D3DXPreprocessShaderFromResource NULL shader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
|
|
|
|
if(messages) {
|
|
|
|
trace("D3DXPreprocessShaderFromResource messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
|
|
|
ID3DXBuffer_Release(messages);
|
|
|
|
}
|
|
|
|
if(shader) ID3DXBuffer_Release(shader);
|
|
|
|
}
|
|
|
|
|
2009-09-16 00:41:33 +02:00
|
|
|
START_TEST(asm)
|
|
|
|
{
|
|
|
|
assembleshader_test();
|
2010-09-09 18:41:39 +02:00
|
|
|
|
|
|
|
d3dxpreprocess_test();
|
2009-09-16 00:41:33 +02:00
|
|
|
}
|