wine-staging/patches/d3d8-ValidateShader/0002-d3d8-Improve-ValidatePixelShader-stub.patch

141 lines
5.1 KiB
Diff

From 29d2dd7606178f391c8802f8d5767a7bd83c4e30 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 14 Jan 2017 07:54:39 +0100
Subject: 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 a562c1c7e30..41f411c30a8 100644
--- a/dlls/d3d8/d3d8_main.c
+++ b/dlls/d3d8/d3d8_main.c
@@ -101,39 +101,36 @@ done:
/***********************************************************************
* ValidatePixelShader (D3D8.@)
- *
- * PARAMS
- * toto result?
*/
-HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL bool, 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, bool, 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 1368ce3a2cf..9ff3be71776 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 *, BOOL, char **);
-static HRESULT (WINAPI *ValidatePixelShader)(DWORD *, DWORD *, int, DWORD *);
+static HRESULT (WINAPI *ValidatePixelShader)(DWORD *, DWORD *, BOOL, char **);
static BOOL (WINAPI *pGetCursorInfo)(PCURSORINFO);
@@ -4296,33 +4296,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);
+ 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);
- /* 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(strstr(errors, "Validation Error") != NULL, "Got unexpected string '%s'.\n", errors);
+ HeapFree(GetProcessHeap(), 0, errors);
}
static void test_volume_get_container(void)
--
2.11.0