From 9002468c7b4d7e8a15e536792fe2df2c99ca063c Mon Sep 17 00:00:00 2001 From: "Louis. Lenders" Date: Sun, 10 Sep 2006 12:05:45 +0100 Subject: [PATCH] d3d8: Better stub for ValidateVertexShader + tests. --- dlls/d3d8/d3d8.spec | 2 +- dlls/d3d8/d3d8_main.c | 29 ++++++++++++--- dlls/d3d8/tests/Makefile.in | 1 + dlls/d3d8/tests/d3d8_main.c | 72 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 dlls/d3d8/tests/d3d8_main.c diff --git a/dlls/d3d8/d3d8.spec b/dlls/d3d8/d3d8.spec index bc82cd099da..4bad85023af 100644 --- a/dlls/d3d8/d3d8.spec +++ b/dlls/d3d8/d3d8.spec @@ -2,4 +2,4 @@ @ stdcall DebugSetMute() @ stdcall Direct3DCreate8(long) @ stdcall ValidatePixelShader(ptr long long ptr) -@ stdcall ValidateVertexShader(ptr long long ptr) +@ stdcall ValidateVertexShader(ptr ptr ptr long ptr) diff --git a/dlls/d3d8/d3d8_main.c b/dlls/d3d8/d3d8_main.c index b7627ab95ba..65b8a00957e 100644 --- a/dlls/d3d8/d3d8_main.c +++ b/dlls/d3d8/d3d8_main.c @@ -72,13 +72,32 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) { /*********************************************************************** * ValidateVertexShader (D3D8.@) * - * PARAMS + * I've seen reserved1 and reserved2 always passed as 0's + * bool seems always passed as 0 or 1, but other values work as well.... * toto result? */ -BOOL WINAPI ValidateVertexShader(LPVOID pFunction, int param1, int param2, LPVOID toto) -{ - FIXME("(%p %d %d %p): stub\n", pFunction, param1, param2, toto); - return TRUE; +HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, int bool, DWORD* toto) +{ + HRESULT ret; + FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); + + if (!vertexshader) + return E_FAIL; + + if (reserved1 || reserved2) + return E_FAIL; + + switch(*vertexshader) { + case 0xFFFE0101: + case 0xFFFE0100: + ret=S_OK; + break; + default: + ERR("vertexshader version mismatch\n"); + ret=E_FAIL; + } + + return ret; } /*********************************************************************** diff --git a/dlls/d3d8/tests/Makefile.in b/dlls/d3d8/tests/Makefile.in index 657605816d0..a936043b01f 100644 --- a/dlls/d3d8/tests/Makefile.in +++ b/dlls/d3d8/tests/Makefile.in @@ -7,6 +7,7 @@ IMPORTS = user32 kernel32 EXTRALIBS = -ldxerr8 CTESTS = \ + d3d8_main.c \ device.c @MAKE_TEST_RULES@ diff --git a/dlls/d3d8/tests/d3d8_main.c b/dlls/d3d8/tests/d3d8_main.c new file mode 100644 index 00000000000..e2f03bdce74 --- /dev/null +++ b/dlls/d3d8/tests/d3d8_main.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2006 Louis Lenders + * + * 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 + */ + +#include "wine/test.h" + +static HRESULT (WINAPI *ValidateVertexShader)(DWORD*,DWORD*,DWORD*,int,DWORD*); + +static void test_ValidateVertexShader(void) +{ + HRESULT ret; + static DWORD simple_vs[] = {0xFFFE0101, /* vs_1_1 */ + 0x00000009, 0xC0010000, 0x90E40000, 0xA0E40000, /* dp4 oPos.x, v0, c0 */ + 0x00000009, 0xC0020000, 0x90E40000, 0xA0E40001, /* dp4 oPos.y, v0, c1 */ + 0x00000009, 0xC0040000, 0x90E40000, 0xA0E40002, /* dp4 oPos.z, v0, c2 */ + 0x00000009, 0xC0080000, 0x90E40000, 0xA0E40003, /* dp4 oPos.w, v0, c3 */ + 0x0000FFFF}; + + ret=ValidateVertexShader(0,0,0,0,0); + ok(ret==E_FAIL,"ValidateVertexShader returned %lx but expected E_FAIL\n",ret); + + ret=ValidateVertexShader(0,0,0,1,0); + ok(ret==E_FAIL,"ValidateVertexShader returned %lx but expected E_FAIL\n",ret); + + ret=ValidateVertexShader(simple_vs,0,0,0,0); + ok(ret==S_OK,"ValidateVertexShader returned %lx but expected S_OK\n",ret); + + ret=ValidateVertexShader(simple_vs,0,0,1,0); + ok(ret==S_OK,"ValidateVertexShader returned %lx but expected S_OK\n",ret); + /* seems to do some version checking */ + *simple_vs=0xFFFE0100; /* vs_1_0 */ + ret=ValidateVertexShader(simple_vs,0,0,0,0); + ok(ret==S_OK,"ValidateVertexShader returned %lx but expected S_OK\n",ret); + + *simple_vs=0xFFFE0102; /* bogus version */ + ret=ValidateVertexShader(simple_vs,0,0,1,0); + ok(ret==E_FAIL,"ValidateVertexShader returned %lx but expected E_FAIL\n",ret); + /* I've seen that applications pass 2nd and 3rd parameter always as 0;simple test with non-zero parameters */ + *simple_vs=0xFFFE0101; /* vs_1_1 */ + ret=ValidateVertexShader(simple_vs,simple_vs,0,1,0); + ok(ret==E_FAIL,"ValidateVertexShader returned %lx but expected E_FAIL\n",ret); + + ret=ValidateVertexShader(simple_vs,0,simple_vs,1,0); + ok(ret==E_FAIL,"ValidateVertexShader returned %lx but expected E_FAIL\n",ret); + /* I've seen 4th parameter is always passed as either 0 or 1, but passing other values doesn't seem to hurt*/ + ret=ValidateVertexShader(simple_vs,0,0,12345,0); + ok(ret==S_OK,"ValidateVertexShader returned %lx but expected S_OK\n",ret); + /* What is 5th parameter ???? Following works ok */ + ret=ValidateVertexShader(simple_vs,0,0,1,simple_vs); + ok(ret==S_OK,"ValidateVertexShader returned %lx but expected S_OK\n",ret); +} + +START_TEST(d3d8_main) +{ + HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" ); + ValidateVertexShader = (void*)GetProcAddress (d3d8_handle, "ValidateVertexShader" ); + test_ValidateVertexShader(); +}