Update existing nvapi patch and add new stubs.

This commit is contained in:
Michael Müller 2015-01-07 23:31:32 +01:00
parent ac1ffc70f8
commit 0868bcbade
3 changed files with 224 additions and 27 deletions

View File

@ -1,4 +1,4 @@
From d66a88dca92c1e409b6a51781f8b0330eae61623 Mon Sep 17 00:00:00 2001
From bf2433b8c878cfeb86a2822d799bb1975edb36e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 5 Jan 2015 18:11:53 +0100
Subject: nvapi: First implementation.
@ -6,15 +6,15 @@ Subject: nvapi: First implementation.
---
configure.ac | 3 +
dlls/nvapi/Makefile.in | 4 +
dlls/nvapi/nvapi.c | 460 +++++++++++++++++++++++++++++++++++++++++++
dlls/nvapi/nvapi.c | 459 +++++++++++++++++++++++++++++++++++++++++++
dlls/nvapi/nvapi.spec | 5 +
dlls/nvapi/tests/Makefile.in | 5 +
dlls/nvapi/tests/nvapi.c | 265 +++++++++++++++++++++++++
dlls/nvapi/tests/nvapi.c | 276 ++++++++++++++++++++++++++
dlls/nvapi64/Makefile.in | 5 +
dlls/nvapi64/nvapi64.spec | 5 +
include/Makefile.in | 1 +
include/nvapi.h | 74 +++++++
10 files changed, 827 insertions(+)
include/nvapi.h | 76 +++++++
10 files changed, 839 insertions(+)
create mode 100644 dlls/nvapi/Makefile.in
create mode 100644 dlls/nvapi/nvapi.c
create mode 100644 dlls/nvapi/nvapi.spec
@ -50,10 +50,10 @@ index 0000000..606177f
+ nvapi.c
diff --git a/dlls/nvapi/nvapi.c b/dlls/nvapi/nvapi.c
new file mode 100644
index 0000000..fdaf21d
index 0000000..7b352d8
--- /dev/null
+++ b/dlls/nvapi/nvapi.c
@@ -0,0 +1,460 @@
@@ -0,0 +1,459 @@
+/*
+ * Copyright (C) 2015 Michael Müller
+ * Copyright (C) 2015 Sebastian Lackner
@ -295,11 +295,10 @@ index 0000000..fdaf21d
+ if (param->version != NV_UNKNOWN_1_VER)
+ return NVAPI_INCOMPATIBLE_STRUCT_VERSION;
+
+ param->unknown1 = 1;
+ param->gpuHandle = (void *)0xdead0001;
+ param->unknown2 = 11;
+ param->gpu_count = 1;
+ param->gpus[0].gpuHandle = (void *)0xdead0001;
+ param->gpus[0].unknown2 = 11;
+
+ memset(param->zeros, 0, sizeof(param->zeros));
+ return NVAPI_OK;
+}
+
@ -538,10 +537,10 @@ index 0000000..a94df01
+ nvapi.c
diff --git a/dlls/nvapi/tests/nvapi.c b/dlls/nvapi/tests/nvapi.c
new file mode 100644
index 0000000..0e0fd2a
index 0000000..d760a18
--- /dev/null
+++ b/dlls/nvapi/tests/nvapi.c
@@ -0,0 +1,265 @@
@@ -0,0 +1,276 @@
+/*
+ * Copyright (C) 2015 Michael Müller
+ *
@ -681,6 +680,7 @@ index 0000000..0e0fd2a
+{
+ NV_UNKNOWN_1 test;
+ NvAPI_Status status;
+ int i;
+
+ if (!pNvAPI_unknown1)
+ {
@ -696,9 +696,19 @@ index 0000000..0e0fd2a
+ status = pNvAPI_unknown1(&test);
+
+ ok(!status, "Expected status NVAPI_OK, got %d\n", status);
+ ok(test.unknown1 == 1, "Expected unknown1 == 1, got %d\n", test.unknown1);
+ ok(test.gpuHandle != NULL, "Expected gpuHandle != 0, got %p\n", test.gpuHandle);
+ ok(test.unknown2 == 11, "Expected unknown2 == 11, got %d\n", test.unknown2);
+ ok(test.gpu_count > 0, "Expected gpu_count > 0, got %d\n", test.gpu_count);
+
+ for (i = 0; i < test.gpu_count; i++)
+ {
+ ok(test.gpus[i].gpuHandle != NULL, "Expected gpus[%d].gpuHandle != 0, got %p\n", i, test.gpus[i].gpuHandle);
+ ok(test.gpus[i].unknown2 != 0, "Expected gpus[%d].unknown2 != 0, got %d\n", i, test.gpus[i].unknown2);
+ }
+
+ for (; i < sizeof(test.gpus) / sizeof(test.gpus[0]); i++)
+ {
+ ok(test.gpus[i].gpuHandle == NULL, "Expected gpus[%d].gpuHandle == NULL, got %p\n", i, test.gpus[i].gpuHandle);
+ ok(test.gpus[i].unknown2 == 0, "Expected gpus[%d].unknown2 == 0, got %d\n", i, test.gpus[i].unknown2);
+ }
+}
+
+static void test_unknown2(void)
@ -727,7 +737,7 @@ index 0000000..0e0fd2a
+ status = pNvAPI_unknown1(&test);
+ ok(!status, "Expected status NVAPI_OK, got %d\n", status);
+
+ status = pNvAPI_unknown2(test.gpuHandle, NULL);
+ status = pNvAPI_unknown2(test.gpus[0].gpuHandle, NULL);
+ ok(status == NVAPI_INVALID_ARGUMENT, "Expected status NVAPI_INVALID_ARGUMENT, got %d\n", status);
+
+ status = pNvAPI_unknown2(NULL, &test2);
@ -739,9 +749,9 @@ index 0000000..0e0fd2a
+ ok(test2 == (void*)0xffffffff, "Expected handle 0xffffffff, got %p\n", test2);
+
+ test2 = NULL;
+ status = pNvAPI_unknown2(test.gpuHandle, &test2);
+ status = pNvAPI_unknown2(test.gpus[0].gpuHandle, &test2);
+ ok(!status, "Expected status NVAPI_OK, got %d\n", status);
+ ok(test2 == test.gpuHandle, "Expected handle %p, got %p\n", test.gpuHandle, test2);
+ ok(test2 == test.gpus[0].gpuHandle, "Expected handle %p, got %p\n", test.gpus[0].gpuHandle, test2);
+}
+
+static void test_unknown3(void)
@ -777,7 +787,7 @@ index 0000000..0e0fd2a
+ status = pNvAPI_unknown1(&test);
+ ok(!status, "Expected status NVAPI_OK, got %d\n", status);
+
+ status = pNvAPI_unknown2(test.gpuHandle, &test2);
+ status = pNvAPI_unknown2(test.gpus[0].gpuHandle, &test2);
+ ok(!status, "Expected status NVAPI_OK, got %d\n", status);
+
+ status = pNvAPI_unknown3(test2, NULL);
@ -843,10 +853,10 @@ index 84c3ea7..f9eaf44 100644
odbcinst.h \
diff --git a/include/nvapi.h b/include/nvapi.h
new file mode 100644
index 0000000..1980895
index 0000000..4204256
--- /dev/null
+++ b/include/nvapi.h
@@ -0,0 +1,74 @@
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2015 Michael Müller
+ *
@ -910,10 +920,12 @@ index 0000000..1980895
+typedef struct
+{
+ NvU32 version;
+ NvU32 unknown1;
+ NvPhysicalGpuHandle gpuHandle;
+ NvU32 unknown2;
+ void* zeros[14];
+ NvU32 gpu_count;
+ struct
+ {
+ NvPhysicalGpuHandle gpuHandle;
+ NvU32 unknown2;
+ } gpus[8];
+}NV_UNKNOWN_1;
+
+#define NV_UNKNOWN_1_VER MAKE_NVAPI_VERSION(NV_UNKNOWN_1, 1)
@ -922,5 +934,5 @@ index 0000000..1980895
+
+#endif /* __WINE_NVAPI_H */
--
2.2.1
1.9.1

View File

@ -0,0 +1,183 @@
From 5eb5136a83fa10e0cd344a49178875ff4c34d5ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 7 Jan 2015 23:26:27 +0100
Subject: nvapi: Add stubs for NvAPI_EnumLogicalGPUs and undocumented
equivalent.
---
dlls/nvapi/nvapi.c | 26 ++++++++++++++++++++-
dlls/nvapi/tests/nvapi.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
include/nvapi.h | 3 +++
3 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/dlls/nvapi/nvapi.c b/dlls/nvapi/nvapi.c
index 7b352d8..b5e7694 100644
--- a/dlls/nvapi/nvapi.c
+++ b/dlls/nvapi/nvapi.c
@@ -401,6 +401,28 @@ static NvAPI_Status CDECL NvAPI_D3D9_StretchRectEx(IDirect3DDevice9 *pDevice, ID
return NVAPI_UNREGISTERED_RESOURCE;
}
+static NvAPI_Status CDECL NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle gpuHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *count)
+{
+ TRACE("(%p, %p)\n", gpuHandle, count);
+
+ if (!gpuHandle)
+ return NVAPI_INVALID_ARGUMENT;
+
+ if (!count)
+ return NVAPI_INVALID_POINTER;
+
+ gpuHandle[0] = (NvLogicalGpuHandle)0xdead0004;
+ *count = 1;
+
+ return NVAPI_OK;
+}
+
+static NvAPI_Status CDECL NvAPI_EnumLogicalGPUs_unknown(NvLogicalGpuHandle gpuHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *count)
+{
+ TRACE("(%p, %p)\n", gpuHandle, count);
+ return NvAPI_EnumLogicalGPUs(gpuHandle, count);
+}
+
void* CDECL nvapi_QueryInterface(unsigned int offset)
{
static const struct
@@ -427,7 +449,9 @@ void* CDECL nvapi_QueryInterface(unsigned int offset)
{0x451f2134, NvAPI_Stereo_GetSeparation},
{0x5c069fa3, NvAPI_Stereo_SetSeparation},
{0x239c4545, NvAPI_Stereo_Enable},
- {0xaeaecd41, NvAPI_D3D9_StretchRectEx}
+ {0xaeaecd41, NvAPI_D3D9_StretchRectEx},
+ {0x48b3ea59, NvAPI_EnumLogicalGPUs},
+ {0xfb9bc2ab, NvAPI_EnumLogicalGPUs_unknown}
};
unsigned int i;
TRACE("(%x)\n", offset);
diff --git a/dlls/nvapi/tests/nvapi.c b/dlls/nvapi/tests/nvapi.c
index d760a18..d563423 100644
--- a/dlls/nvapi/tests/nvapi.c
+++ b/dlls/nvapi/tests/nvapi.c
@@ -33,6 +33,8 @@
#define NvAPI_unknown1_Offset 0x5786cc6e
#define NvAPI_unknown2_Offset 0x6533ea3e
#define NvAPI_unknown3_Offset 0x5380ad1a
+#define NvAPI_EnumLogicalGPUs_unknown_Offset 0xfb9bc2ab
+#define NvAPI_EnumLogicalGPUs_Offset 0x48b3ea59
static void* (CDECL *pnvapi_QueryInterface)(unsigned int offset);
static NvAPI_Status (CDECL *pNvAPI_Initialize)(void);
@@ -40,6 +42,8 @@ static NvAPI_Status (CDECL *pNvAPI_GetDisplayDriverVersion)(NvDisplayHandle hNvD
static NvAPI_Status (CDECL *pNvAPI_unknown1)(void* param0);
static NvAPI_Status (CDECL *pNvAPI_unknown2)(NvPhysicalGpuHandle gpuHandle, void *param1);
static NvAPI_Status (CDECL *pNvAPI_unknown3)(void *param0, void *param1);
+static NvAPI_Status (CDECL *pNvAPI_EnumLogicalGPUs_unknown)(void *buffer, NvU32 *gpu_count);
+static NvAPI_Status (CDECL *pNvAPI_EnumLogicalGPUs)(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount);
static BOOL init(void)
{
@@ -67,6 +71,8 @@ static BOOL init(void)
pNvAPI_unknown1 = pnvapi_QueryInterface(NvAPI_unknown1_Offset);
pNvAPI_unknown2 = pnvapi_QueryInterface(NvAPI_unknown2_Offset);
pNvAPI_unknown3 = pnvapi_QueryInterface(NvAPI_unknown3_Offset);
+ pNvAPI_EnumLogicalGPUs_unknown = pnvapi_QueryInterface(NvAPI_EnumLogicalGPUs_unknown_Offset);
+ pNvAPI_EnumLogicalGPUs = pnvapi_QueryInterface(NvAPI_EnumLogicalGPUs_Offset);
if (!pNvAPI_Initialize)
{
@@ -264,6 +270,60 @@ static void test_unknown3(void)
ok(test2 == test3, "Expected handle %p, got %p\n", test2, test3);
}
+static void test_NvAPI_EnumLogicalGPUs(void)
+{
+ NvLogicalGpuHandle gpuHandle1[NVAPI_MAX_LOGICAL_GPUS];
+ NvLogicalGpuHandle gpuHandle2[NVAPI_MAX_LOGICAL_GPUS];
+ NvAPI_Status status;
+ NvU32 count1, count2;
+ int i;
+
+ if (!pNvAPI_EnumLogicalGPUs_unknown)
+ {
+ win_skip("NvAPI_EnumLogicalGPUs_unknown export not found.\n");
+ return;
+ }
+
+ if (!pNvAPI_EnumLogicalGPUs)
+ {
+ win_skip("NvAPI_EnumLogicalGPUs export not found.\n");
+ return;
+ }
+
+ status = pNvAPI_EnumLogicalGPUs_unknown(NULL, NULL);
+ ok(status == NVAPI_INVALID_ARGUMENT, "Expected status NVAPI_INVALID_ARGUMENT, got %d\n", status);
+
+ status = pNvAPI_EnumLogicalGPUs_unknown((void*)0xdeadbeef, NULL);
+ ok(status == NVAPI_INVALID_POINTER, "Expected status NVAPI_INVALID_POINTER, got %d\n", status);
+
+ status = pNvAPI_EnumLogicalGPUs_unknown(NULL, (void*)0xdeadbeef);
+ ok(status == NVAPI_INVALID_ARGUMENT, "Expected status NVAPI_INVALID_ARGUMENT, got %d\n", status);
+
+ status = pNvAPI_EnumLogicalGPUs(NULL, NULL);
+ ok(status == NVAPI_INVALID_ARGUMENT, "Expected status NVAPI_INVALID_ARGUMENT, got %d\n", status);
+
+ status = pNvAPI_EnumLogicalGPUs((void*)0xdeadbeef, NULL);
+ ok(status == NVAPI_INVALID_POINTER, "Expected status NVAPI_INVALID_POINTER, got %d\n", status);
+
+ status = pNvAPI_EnumLogicalGPUs(NULL, (void*)0xdeadbeef);
+ ok(status == NVAPI_INVALID_ARGUMENT, "Expected status NVAPI_INVALID_ARGUMENT, got %d\n", status);
+
+ memset(gpuHandle1, 0, sizeof(gpuHandle1));
+
+ status = pNvAPI_EnumLogicalGPUs_unknown(&gpuHandle1, &count1);
+ ok(status == NVAPI_OK, "Expected status NVAPI_OK, got %d\n", status);
+ ok(count1 > 0, "Expected count1 > 0, got %d\n", count1);
+ for (i = 0; i < count1; i++)
+ ok(gpuHandle1[i] != NULL, "Expected gpuHandle1[%d] not be NULL, got %p\n", i, gpuHandle1[i]);
+
+ status = pNvAPI_EnumLogicalGPUs(gpuHandle2, &count2);
+ ok(status == NVAPI_OK, "Expected status NVAPI_OK, got %d\n", status);
+ ok(count2 > 0, "Expected count2 > 0, got %d\n", count2);
+ ok(count1 == count2, "Expected count1 == count2, got %d != %d\n", count1, count2);
+ for (i = 0; i < count2; i++)
+ ok(gpuHandle1[i] == gpuHandle2[i], "Expected gpuHandle1[i] == gpuHandle2[i], got %p != %p\n", gpuHandle1[i], gpuHandle2[i]);
+}
+
START_TEST( nvapi )
{
if (!init())
@@ -273,4 +333,5 @@ START_TEST( nvapi )
test_unknown1();
test_unknown2();
test_unknown3();
+ test_NvAPI_EnumLogicalGPUs();
}
diff --git a/include/nvapi.h b/include/nvapi.h
index 4204256..448b0ce 100644
--- a/include/nvapi.h
+++ b/include/nvapi.h
@@ -31,18 +31,21 @@ typedef unsigned int NvU32;
#define NVAPI_INVALID_ARGUMENT -5
#define NVAPI_INVALID_HANDLE -8
#define NVAPI_INCOMPATIBLE_STRUCT_VERSION -9
+#define NVAPI_INVALID_POINTER -14
#define NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE -101
#define NVAPI_STEREO_NOT_INITIALIZED -140
#define NVAPI_UNREGISTERED_RESOURCE -170
#define NVAPI_SHORT_STRING_MAX 64
#define NVAPI_MAX_PHYSICAL_GPUS 64
+#define NVAPI_MAX_LOGICAL_GPUS 64
typedef char NvAPI_ShortString[NVAPI_SHORT_STRING_MAX];
#define MAKE_NVAPI_VERSION(type,version) (NvU32)(sizeof(type) | ((version)<<16))
typedef void *NvPhysicalGpuHandle;
+typedef void *NvLogicalGpuHandle;
typedef void *NvDisplayHandle;
typedef void *StereoHandle;
--
1.9.1

View File

@ -2080,8 +2080,10 @@ fi
# |
if [ "$enable_nvapi_Stub_DLL" -eq 1 ]; then
patch_apply nvapi-Stub_DLL/0001-nvapi-First-implementation.patch
patch_apply nvapi-Stub_DLL/0002-nvapi-Add-stubs-for-NvAPI_EnumLogicalGPUs-and-undocu.patch
(
echo '+ { "Michael Müller", "nvapi: First implementation.", 1 },';
echo '+ { "Michael Müller", "nvapi: Add stubs for NvAPI_EnumLogicalGPUs and undocumented equivalent.", 1 },';
) >> "$patchlist"
fi