Added patch to improve stubs for Validate{Vertex,Pixel}Shader.

This commit is contained in:
Sebastian Lackner 2017-01-14 08:23:44 +01:00
parent b6c5b6240b
commit a90497bdef
4 changed files with 318 additions and 0 deletions

View File

@ -0,0 +1,156 @@
From 3dc821fe683d1e17976ca9367465c1412e1140b4 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 14 Jan 2017 07:50:36 +0100
Subject: d3d8: Improve ValidateVertexShader stub.
---
dlls/d3d8/d3d8_main.c | 43 ++++++++++++++++++++++---------------------
dlls/d3d8/tests/device.c | 40 +++++++++++++++++++++++++---------------
2 files changed, 47 insertions(+), 36 deletions(-)
diff --git a/dlls/d3d8/d3d8_main.c b/dlls/d3d8/d3d8_main.c
index 8ac704c364c..2ab0414b7f2 100644
--- a/dlls/d3d8/d3d8_main.c
+++ b/dlls/d3d8/d3d8_main.c
@@ -58,38 +58,39 @@ 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 28c6af32e0c..1368ce3a2cf 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -50,7 +50,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);
@@ -4238,18 +4238,31 @@ 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);
ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
hr = ValidateVertexShader(0, 0, 0, 1, 0);
ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+
+ errors = (void *)0xdeadbeef;
+ hr = ValidateVertexShader(0, 0, 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 = ValidateVertexShader(0, 0, 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);
+
hr = ValidateVertexShader(vs, 0, 0, 0, 0);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-
hr = ValidateVertexShader(vs, 0, 0, 1, 0);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- /* Seems to do some version checking. */
+
*vs = 0xfffe0100; /* vs_1_0 */
hr = ValidateVertexShader(vs, 0, 0, 0, 0);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@@ -4257,21 +4270,18 @@ static void test_validate_vs(void)
*vs = 0xfffe0102; /* bogus version */
hr = ValidateVertexShader(vs, 0, 0, 1, 0);
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);
+
+ errors = (void *)0xdeadbeef;
+ hr = ValidateVertexShader(vs, 0, 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);
- hr = ValidateVertexShader(vs, 0, vs, 1, 0);
+ errors = (void *)0xdeadbeef;
+ hr = ValidateVertexShader(vs, 0, 0, 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(strstr(errors, "Validation Error") != NULL, "Got unexpected string '%s'.\n", errors);
+ HeapFree(GetProcessHeap(), 0, errors);
}
static void test_validate_ps(void)
--
2.11.0

View File

@ -0,0 +1,140 @@
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

View File

@ -0,0 +1 @@
Fixes: [40036] Improve stubs for Validate{Vertex,Pixel}Shader

View File

@ -111,6 +111,7 @@ patch_enable_all ()
enable_crypt32_CryptUnprotectMemory="$1"
enable_d3d10_1_Forwards="$1"
enable_d3d11_ID3D11Texture1D="$1"
enable_d3d8_ValidateShader="$1"
enable_d3d9_DesktopWindow="$1"
enable_d3d9_Surface_Refcount="$1"
enable_d3d9_Tests="$1"
@ -535,6 +536,9 @@ patch_enable ()
d3d11-ID3D11Texture1D)
enable_d3d11_ID3D11Texture1D="$2"
;;
d3d8-ValidateShader)
enable_d3d8_ValidateShader="$2"
;;
d3d9-DesktopWindow)
enable_d3d9_DesktopWindow="$2"
;;
@ -3308,6 +3312,23 @@ if test "$enable_d3d11_ID3D11Texture1D" -eq 1; then
) >> "$patchlist"
fi
# Patchset d3d8-ValidateShader
# |
# | This patchset fixes the following Wine bugs:
# | * [#40036] Improve stubs for Validate{Vertex,Pixel}Shader
# |
# | Modified files:
# | * dlls/d3d8/d3d8_main.c, dlls/d3d8/tests/device.c
# |
if test "$enable_d3d8_ValidateShader" -eq 1; then
patch_apply d3d8-ValidateShader/0001-d3d8-Improve-ValidateVertexShader-stub.patch
patch_apply d3d8-ValidateShader/0002-d3d8-Improve-ValidatePixelShader-stub.patch
(
echo '+ { "Sebastian Lackner", "d3d8: Improve ValidateVertexShader stub.", 1 },';
echo '+ { "Sebastian Lackner", "d3d8: Improve ValidatePixelShader stub.", 1 },';
) >> "$patchlist"
fi
# Patchset d3d9-DesktopWindow
# |
# | Modified files: