Based largely on a patch by Sebastian Lackner. Adapted from "Improve ValidateVertexShader()" by Henri Verbeet.
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com ---
Native crashes when ps_code is NULL, so those tests were omitted.
dlls/d3d8/d3d8_main.c | 69 +++++++++++++++++++++------------------- dlls/d3d8/tests/device.c | 43 ++++++++++++------------- 2 files changed, 58 insertions(+), 54 deletions(-)
diff --git a/dlls/d3d8/d3d8_main.c b/dlls/d3d8/d3d8_main.c index 17f35c9089..64f951e0bd 100644 --- a/dlls/d3d8/d3d8_main.c +++ b/dlls/d3d8/d3d8_main.c @@ -103,41 +103,46 @@ done: return hr; }
-/*********************************************************************** - * ValidatePixelShader (D3D8.@) - * - * PARAMS - * toto result? - */ -HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL boolean, DWORD* toto) +/* FIXME: We should probably use libvkd3d-shader for validation. */ +HRESULT WINAPI ValidatePixelShader(const DWORD *ps_code, const DWORD *declaration, + 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; - } - - if (!pixelshader) - return E_FAIL; - - if (reserved1) - return E_FAIL; - - switch(*pixelshader) { - case 0xFFFF0100: - case 0xFFFF0101: - case 0xFFFF0102: - case 0xFFFF0103: - case 0xFFFF0104: - ret=S_OK; + const char *message = ""; + SIZE_T message_size; + HRESULT hr = E_FAIL; + + TRACE("ps_code %p, declaration %p, return_error %#x, errors %p.\n", + ps_code, declaration, return_error, errors); + + if (!ps_code) + { + message = "Invalid code pointer.\n"; + goto done; + } + + switch (*ps_code) + { + case D3DPS_VERSION(1, 3): + case D3DPS_VERSION(1, 2): + case D3DPS_VERSION(1, 1): + case D3DPS_VERSION(1, 0): break; + default: - WARN("Invalid shader version token %#x.\n", *pixelshader); - ret=E_FAIL; - } - return ret; + message = "Unsupported shader version.\n"; + goto done; + } + + hr = S_OK; + +done: + if (!return_error) + message = ""; + message_size = strlen(message) + 1; + if (errors && (*errors = heap_alloc(message_size))) + memcpy(*errors, message, message_size); + + 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 a64736913d..41401091ca 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)(const DWORD *, const DWORD *, BOOL, char **);
static BOOL (WINAPI *pGetCursorInfo)(PCURSORINFO);
@@ -4506,7 +4506,7 @@ static void test_validate_vs(void)
static void test_validate_ps(void) { - static DWORD ps[] = + static DWORD ps_code[] = { 0xffff0101, /* ps_1_1 */ 0x00000051, 0xa00f0001, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, /* def c1 = 1.0, 0.0, 0.0, 0.0 */ @@ -4516,33 +4516,32 @@ 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); - hr = ValidatePixelShader(ps, 0, 0, 0); + hr = ValidatePixelShader(ps_code, NULL, FALSE, NULL); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ValidatePixelShader(ps_code, NULL, TRUE, NULL); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ValidatePixelShader(ps_code, NULL, TRUE, &errors); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!*errors, "Got unexpected string "%s".\n", errors); + heap_free(errors);
- hr = ValidatePixelShader(ps, 0, 1, 0); + *ps_code = D3DPS_VERSION(1, 0); + hr = ValidatePixelShader(ps_code, NULL, FALSE, NULL); 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); + *ps_code = D3DPS_VERSION(1, 4); + hr = ValidatePixelShader(ps_code, NULL, TRUE, NULL); 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); + hr = ValidatePixelShader(ps_code, NULL, FALSE, &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(!*errors, "Got unexpected string "%s".\n", errors); + heap_free(errors); + hr = ValidatePixelShader(ps_code, NULL, TRUE, &errors); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(!!*errors, "Got unexpected empty string.\n"); + heap_free(errors); }
static void test_volume_get_container(void)
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=48441
Your paranoid android.
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)