From: David Adam Subject: [PATCH]: d3d8: Improve Validatevertexshader stub Message-Id: Date: Fri, 25 Jan 2019 19:03:05 -1000 Hello, this patch is not mine. It is Sebastian Lackner's one. I hope I did everything right to let him the credit of his work.
Hello,
this patch is not mine. It is Sebastian Lackner's one. I hope I did everything right to let him the credit of his work.
From c8d1b0c6cc17c0a6ca014d0a24614ea4025e416a Mon Sep 17 00:00:00 2001 From: David Adam Date: Fri, 25 Jan 2019 18:44:23 -1000 Subject: [PATCH] d3d8: Improve Validatevertexshader stub From: Sebastian Lackner Signed-off-by: David Adam --- dlls/d3d8/d3d8_main.c | 44 ++++++++++++++++++------------------ dlls/d3d8/tests/device.c | 48 ++++++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/dlls/d3d8/d3d8_main.c b/dlls/d3d8/d3d8_main.c index a6c67008ed..5266dfc6af 100644 --- a/dlls/d3d8/d3d8_main.c +++ b/dlls/d3d8/d3d8_main.c @@ -59,38 +59,38 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version) /*********************************************************************** * ValidateVertexShader (D3D8.@) - * - * 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? */ -HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, BOOL bool, DWORD* toto) +HRESULT WINAPI ValidateVertexShader(DWORD *vertexshader, DWORD *reserved1, DWORD *reserved2, + BOOL return_error, char **errors) { - HRESULT ret; - static BOOL warned; - - if (TRACE_ON(d3d8) || !warned) { - FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); - warned = TRUE; - } + const char *message = ""; + HRESULT hr = E_FAIL; - if (!vertexshader) - return E_FAIL; + TRACE("(%p %p %p %d %p): semi-stub\n", vertexshader, reserved1, reserved2, return_error, errors); - if (reserved1 || reserved2) - return E_FAIL; + if (!vertexshader) + { + message = "(Global Validation Error) Version Token: Code pointer cannot be NULL.\n"; + goto done; + } - switch(*vertexshader) { + switch (*vertexshader) + { case 0xFFFE0101: case 0xFFFE0100: - ret=S_OK; + hr = S_OK; break; + default: - WARN("Invalid shader version token %#x.\n", *vertexshader); - ret=E_FAIL; - } + message = "(Global Validation Error) Version Token: Unsupported vertex shader version.\n"; + } - return ret; +done: + if (!return_error) message = ""; + if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, strlen(message) + 1))) + strcpy(*errors, message); + + return hr; } /*********************************************************************** diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 97c2747e12..8336af483b 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -51,7 +51,7 @@ struct device_desc static DEVMODEW registry_mode; -static HRESULT (WINAPI *ValidateVertexShader)(DWORD *, DWORD *, DWORD *, int, DWORD *); +static HRESULT (WINAPI *ValidateVertexShader)(DWORD *, DWORD *, DWORD *, BOOL, char **); static HRESULT (WINAPI *ValidatePixelShader)(DWORD *, DWORD *, int, DWORD *); static BOOL (WINAPI *pGetCursorInfo)(PCURSORINFO); @@ -4369,40 +4369,46 @@ static void test_validate_vs(void) 0x00000009, 0xc0080000, 0x90e40000, 0xa0e40003, /* dp4 oPos.w, v0, c3 */ 0x0000ffff, /* end */ }; + char *errors; HRESULT hr; - hr = ValidateVertexShader(0, 0, 0, 0, 0); + hr = ValidateVertexShader(NULL, NULL, NULL, 0, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - hr = ValidateVertexShader(0, 0, 0, 1, 0); + hr = ValidateVertexShader(NULL, NULL, NULL, 1, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - hr = ValidateVertexShader(vs, 0, 0, 0, 0); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - hr = ValidateVertexShader(vs, 0, 0, 1, 0); + hr = ValidateVertexShader(NULL, NULL, NULL, 0, &errors); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(!strcmp(errors, ""), "Got unexpected string '%s'.\n", errors); + HeapFree(GetProcessHeap(), 0, errors); + + hr = ValidateVertexShader(NULL, NULL, NULL, 1, &errors); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(strcmp(errors, "") != NULL, "Got unexpected string '%s'.\n", errors); + HeapFree(GetProcessHeap(), 0, errors); + + hr = ValidateVertexShader(vs, NULL, NULL, 0, NULL); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - /* Seems to do some version checking. */ + hr = ValidateVertexShader(vs, NULL, NULL, 1, NULL); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + *vs = 0xfffe0100; /* vs_1_0 */ - hr = ValidateVertexShader(vs, 0, 0, 0, 0); + hr = ValidateVertexShader(vs, NULL, NULL, 0, NULL); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); *vs = 0xfffe0102; /* bogus version */ - hr = ValidateVertexShader(vs, 0, 0, 1, 0); + hr = ValidateVertexShader(vs, NULL, NULL, 1, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - /* I've seen that applications always pass the 2nd and 3rd parameter as 0. - * Simple test with non-zero parameters. */ - *vs = 0xfffe0101; /* vs_1_1 */ - hr = ValidateVertexShader(vs, vs, 0, 1, 0); + + hr = ValidateVertexShader(vs, NULL, NULL, 0, &errors); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(!strcmp(errors, ""), "Got unexpected string '%s'.\n", errors); + HeapFree(GetProcessHeap(), 0, errors); - hr = ValidateVertexShader(vs, 0, vs, 1, 0); + hr = ValidateVertexShader(vs, NULL, NULL, 1, &errors); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - /* I've seen the 4th parameter always passed as either 0 or 1, but passing - * other values doesn't seem to hurt. */ - hr = ValidateVertexShader(vs, 0, 0, 12345, 0); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - /* What is the 5th parameter? The following seems to work ok. */ - hr = ValidateVertexShader(vs, 0, 0, 1, vs); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(strcmp(errors, ""), "Got unexpected string '%s'.\n", errors); + HeapFree(GetProcessHeap(), 0, errors); } static void test_validate_ps(void) -- 2.19.1