From a26d43a10fb5de70732970b20a29ce4437b33076 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 14 Jan 2017 07:54:39 +0100 Subject: [PATCH] d3d8: Improve ValidatePixelShader stub. --- dlls/d3d8/d3d8_main.c | 37 +++++++++++++++++-------------------- dlls/d3d8/tests/device.c | 34 ++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/dlls/d3d8/d3d8_main.c b/dlls/d3d8/d3d8_main.c index 17f35c90..7b28bdf1 100644 --- a/dlls/d3d8/d3d8_main.c +++ b/dlls/d3d8/d3d8_main.c @@ -105,39 +105,36 @@ done: /*********************************************************************** * ValidatePixelShader (D3D8.@) - * - * PARAMS - * toto result? */ -HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL boolean, DWORD* toto) +HRESULT WINAPI ValidatePixelShader(DWORD *pixelshader, DWORD *reserved1, BOOL return_error, char **errors) { - HRESULT ret; - static BOOL warned; - - if (TRACE_ON(d3d8) || !warned) { - FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, boolean, toto); - warned = TRUE; - } + const char *message = ""; + HRESULT hr = E_FAIL; - if (!pixelshader) - return E_FAIL; + TRACE("(%p %p %d %p): semi-stub\n", pixelshader, reserved1, return_error, errors); - if (reserved1) - return E_FAIL; + if (!pixelshader) + return E_FAIL; - switch(*pixelshader) { + switch (*pixelshader) + { case 0xFFFF0100: case 0xFFFF0101: case 0xFFFF0102: case 0xFFFF0103: case 0xFFFF0104: - ret=S_OK; + hr = S_OK; break; default: WARN("Invalid shader version token %#x.\n", *pixelshader); - ret=E_FAIL; - } - return ret; + message = "(Global Validation Error) Version Token: Unsupported pixel shader version.\n"; + } + + if (!return_error) message = ""; + if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, strlen(message) + 1))) + strcpy(*errors, message); + + return hr; } void d3d8_resource_cleanup(struct d3d8_resource *resource) diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 315640d3..6f8354f4 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -53,7 +53,7 @@ struct device_desc static DEVMODEW registry_mode; static HRESULT (WINAPI *ValidateVertexShader)(const DWORD *, const DWORD *, const D3DCAPS8 *, BOOL, char **); -static HRESULT (WINAPI *ValidatePixelShader)(DWORD *, DWORD *, int, DWORD *); +static HRESULT (WINAPI *ValidatePixelShader)(DWORD *, DWORD *, BOOL, char **); static BOOL (WINAPI *pGetCursorInfo)(PCURSORINFO); @@ -4474,33 +4474,39 @@ static void test_validate_ps(void) 0x00000005, 0x800f0000, 0xb0e40000, 0x80e40000, /* mul r0, t0, r0 */ 0x0000ffff, /* end */ }; + char *errors; HRESULT hr; hr = ValidatePixelShader(0, 0, 0, 0); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = ValidatePixelShader(0, 0, 1, 0); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + + errors = (void *)0xdeadbeef; + hr = ValidatePixelShader(0, 0, 1, &errors); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(errors == (void *)0xdeadbeef, "Expected 0xdeadbeef, got %p.\n", errors); + hr = ValidatePixelShader(ps, 0, 0, 0); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - hr = ValidatePixelShader(ps, 0, 1, 0); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - /* Seems to do some version checking. */ + *ps = 0xffff0105; /* bogus version */ hr = ValidatePixelShader(ps, 0, 1, 0); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - /* I've seen that applications always pass the 2nd parameter as 0. - * Simple test with a non-zero parameter. */ - *ps = 0xffff0101; /* ps_1_1 */ - hr = ValidatePixelShader(ps, ps, 1, 0); + + errors = (void *)0xdeadbeef; + hr = ValidatePixelShader(ps, 0, 0, &errors); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); - /* I've seen the 3rd parameter always passed as either 0 or 1, but passing - * other values doesn't seem to hurt. */ - hr = ValidatePixelShader(ps, 0, 12345, 0); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - /* What is the 4th parameter? The following seems to work ok. */ - hr = ValidatePixelShader(ps, 0, 1, ps); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!strcmp(errors, ""), "Got unexpected string '%s'.\n", errors); + HeapFree(GetProcessHeap(), 0, errors); + + errors = (void *)0xdeadbeef; + hr = ValidatePixelShader(ps, 0, 1, &errors); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(strstr(errors, "Validation Error") != NULL, "Got unexpected string '%s'.\n", errors); + HeapFree(GetProcessHeap(), 0, errors); } static void test_volume_get_container(void) -- 2.20.1