Add more nvapi stub patches.

This commit is contained in:
Michael Müller 2015-01-14 22:24:14 +01:00
parent fce30bb8f1
commit 93764fd3d4
4 changed files with 293 additions and 0 deletions

View File

@ -0,0 +1,94 @@
From 8a87b993e11b00c4e78bf11cc424534957b48aac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 14 Jan 2015 21:30:53 +0100
Subject: nvapi/tests: Use structure to list imports.
---
dlls/nvapi/tests/nvapi.c | 55 +++++++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 29 deletions(-)
diff --git a/dlls/nvapi/tests/nvapi.c b/dlls/nvapi/tests/nvapi.c
index f4edcab..4db576e 100644
--- a/dlls/nvapi/tests/nvapi.c
+++ b/dlls/nvapi/tests/nvapi.c
@@ -29,21 +29,6 @@
#include "wine/test.h"
-#define NvAPI_Initialize_Offset 0x0150E828
-#define NvAPI_GetDisplayDriverVersion_Offset 0xF951A4D1
-#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
-#define NvAPI_GetPhysicalGPUsFromLogicalGPU_Offset 0xaea3fa32
-#define NvAPI_EnumPhysicalGPUs_Offset 0xe5ac921f
-#define NvAPI_GPU_GetFullName_Offset 0xceee8e9f
-#define NvAPI_DISP_GetGDIPrimaryDisplayId_Offset 0x1e9d8a31
-#define NvAPI_EnumNvidiaDisplayHandle_Offset 0x9abdd40d
-#define NvAPI_SYS_GetDriverAndBranchVersion_Offset 0x2926aaad
-#define NvAPI_D3D_GetCurrentSLIState_Offset 0x4b708b54
-
static void* (CDECL *pnvapi_QueryInterface)(unsigned int offset);
static NvAPI_Status (CDECL *pNvAPI_Initialize)(void);
static NvAPI_Status (CDECL *pNvAPI_GetDisplayDriverVersion)(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion);
@@ -60,8 +45,32 @@ static NvAPI_Status (CDECL* pNvAPI_EnumNvidiaDisplayHandle)(NvU32 thisEnum, NvDi
static NvAPI_Status (CDECL* pNvAPI_SYS_GetDriverAndBranchVersion)(NvU32* pDriverVersion, NvAPI_ShortString szBuildBranchString);
static NvAPI_Status (CDECL* pNvAPI_D3D_GetCurrentSLIState)(IUnknown *pDevice, NV_GET_CURRENT_SLI_STATE *pSliState);
+static const struct
+{
+ unsigned int offset;
+ void **function;
+}
+function_list[] =
+{
+ {0x0150E828, (void**) &pNvAPI_Initialize},
+ {0xF951A4D1, (void**) &pNvAPI_GetDisplayDriverVersion},
+ {0x5786cc6e, (void**) &pNvAPI_unknown1},
+ {0x6533ea3e, (void**) &pNvAPI_unknown2},
+ {0x5380ad1a, (void**) &pNvAPI_unknown3},
+ {0xfb9bc2ab, (void**) &pNvAPI_EnumLogicalGPUs_unknown},
+ {0x48b3ea59, (void**) &pNvAPI_EnumLogicalGPUs},
+ {0xaea3fa32, (void**) &pNvAPI_GetPhysicalGPUsFromLogicalGPU},
+ {0xe5ac921f, (void**) &pNvAPI_EnumPhysicalGPUs},
+ {0xceee8e9f, (void**) &pNvAPI_GPU_GetFullName},
+ {0x1e9d8a31, (void**) &pNvAPI_DISP_GetGDIPrimaryDisplayId},
+ {0x9abdd40d, (void**) &pNvAPI_EnumNvidiaDisplayHandle},
+ {0x2926aaad, (void**) &pNvAPI_SYS_GetDriverAndBranchVersion},
+ {0x4b708b54, (void**) &pNvAPI_D3D_GetCurrentSLIState}
+};
+
static BOOL init(void)
{
+ int i;
#ifdef __x86_64__
HMODULE nvapi = LoadLibraryA("nvapi64.dll");
#else
@@ -81,20 +90,8 @@ static BOOL init(void)
return FALSE;
}
- pNvAPI_Initialize = pnvapi_QueryInterface(NvAPI_Initialize_Offset);
- pNvAPI_GetDisplayDriverVersion = pnvapi_QueryInterface(NvAPI_GetDisplayDriverVersion_Offset);
- 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);
- pNvAPI_GetPhysicalGPUsFromLogicalGPU = pnvapi_QueryInterface(NvAPI_GetPhysicalGPUsFromLogicalGPU_Offset);
- pNvAPI_EnumPhysicalGPUs = pnvapi_QueryInterface(NvAPI_EnumPhysicalGPUs_Offset);
- pNvAPI_GPU_GetFullName = pnvapi_QueryInterface(NvAPI_GPU_GetFullName_Offset);
- pNvAPI_DISP_GetGDIPrimaryDisplayId = pnvapi_QueryInterface(NvAPI_DISP_GetGDIPrimaryDisplayId_Offset);
- pNvAPI_EnumNvidiaDisplayHandle = pnvapi_QueryInterface(NvAPI_EnumNvidiaDisplayHandle_Offset);
- pNvAPI_SYS_GetDriverAndBranchVersion = pnvapi_QueryInterface(NvAPI_SYS_GetDriverAndBranchVersion_Offset);
- pNvAPI_D3D_GetCurrentSLIState = pnvapi_QueryInterface(NvAPI_D3D_GetCurrentSLIState_Offset);
+ for (i = 0; i < sizeof(function_list) / sizeof(function_list[0]); i++)
+ *function_list[i].function = pnvapi_QueryInterface(function_list[i].offset);
if (!pNvAPI_Initialize)
{
--
1.9.1

View File

@ -0,0 +1,141 @@
From 40f42d36dac8ea38381f05158daa97346059a61f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 14 Jan 2015 21:48:53 +0100
Subject: nvapi: Add stub for NvAPI_GetLogicalGPUFromDisplay.
---
dlls/nvapi/nvapi.c | 17 ++++++++++++++++-
dlls/nvapi/tests/nvapi.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
include/nvapi.h | 1 +
3 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/dlls/nvapi/nvapi.c b/dlls/nvapi/nvapi.c
index 6852e24..98658a6 100644
--- a/dlls/nvapi/nvapi.c
+++ b/dlls/nvapi/nvapi.c
@@ -550,6 +550,20 @@ static NvAPI_Status CDECL NvAPI_D3D_GetCurrentSLIState(IUnknown *pDevice, NV_GET
return NVAPI_NO_ACTIVE_SLI_TOPOLOGY;
}
+static NvAPI_Status CDECL NvAPI_GetLogicalGPUFromDisplay(NvDisplayHandle hNvDisp, NvLogicalGpuHandle *pLogicalGPU)
+{
+ TRACE("(%p, %p)\n", hNvDisp, pLogicalGPU);
+
+ if (!pLogicalGPU)
+ return NVAPI_INVALID_POINTER;
+
+ if (hNvDisp && hNvDisp != FAKE_DISPLAY)
+ return NVAPI_NVIDIA_DEVICE_NOT_FOUND;
+
+ *pLogicalGPU = FAKE_LOGICAL_GPU;
+ return NVAPI_OK;
+}
+
void* CDECL nvapi_QueryInterface(unsigned int offset)
{
static const struct
@@ -588,7 +602,8 @@ void* CDECL nvapi_QueryInterface(unsigned int offset)
{0x9abdd40d, NvAPI_EnumNvidiaDisplayHandle},
{0x2926aaad, NvAPI_SYS_GetDriverAndBranchVersion},
{0xd22bdd7e, NvAPI_Unload},
- {0x4b708b54, NvAPI_D3D_GetCurrentSLIState}
+ {0x4b708b54, NvAPI_D3D_GetCurrentSLIState},
+ {0xee1370cf, NvAPI_GetLogicalGPUFromDisplay}
};
unsigned int i;
TRACE("(%x)\n", offset);
diff --git a/dlls/nvapi/tests/nvapi.c b/dlls/nvapi/tests/nvapi.c
index 4db576e..297a335 100644
--- a/dlls/nvapi/tests/nvapi.c
+++ b/dlls/nvapi/tests/nvapi.c
@@ -44,6 +44,7 @@ static NvAPI_Status (CDECL* pNvAPI_DISP_GetGDIPrimaryDisplayId)(NvU32* displayId
static NvAPI_Status (CDECL* pNvAPI_EnumNvidiaDisplayHandle)(NvU32 thisEnum, NvDisplayHandle *pNvDispHandle);
static NvAPI_Status (CDECL* pNvAPI_SYS_GetDriverAndBranchVersion)(NvU32* pDriverVersion, NvAPI_ShortString szBuildBranchString);
static NvAPI_Status (CDECL* pNvAPI_D3D_GetCurrentSLIState)(IUnknown *pDevice, NV_GET_CURRENT_SLI_STATE *pSliState);
+static NvAPI_Status (CDECL* pNvAPI_GetLogicalGPUFromDisplay)(NvDisplayHandle hNvDisp, NvLogicalGpuHandle *pLogicalGPU);
static const struct
{
@@ -65,7 +66,8 @@ function_list[] =
{0x1e9d8a31, (void**) &pNvAPI_DISP_GetGDIPrimaryDisplayId},
{0x9abdd40d, (void**) &pNvAPI_EnumNvidiaDisplayHandle},
{0x2926aaad, (void**) &pNvAPI_SYS_GetDriverAndBranchVersion},
- {0x4b708b54, (void**) &pNvAPI_D3D_GetCurrentSLIState}
+ {0x4b708b54, (void**) &pNvAPI_D3D_GetCurrentSLIState},
+ {0xee1370cf, (void**) &pNvAPI_GetLogicalGPUFromDisplay}
};
static BOOL init(void)
@@ -565,6 +567,49 @@ static void test_NvAPI_SYS_GetDriverAndBranchVersion(void)
trace("Branch: %s\n", branch);
}
+static void test_NvAPI_GetLogicalGPUFromDisplay(void)
+{
+ NvAPI_Status status;
+ NvDisplayHandle disp;
+ NvLogicalGpuHandle gpuHandle;
+
+ if (!pNvAPI_GetLogicalGPUFromDisplay)
+ {
+ win_skip("NvAPI_SYS_GetDriverAndBranchVersion export not found.\n");
+ return;
+ }
+
+ if (!pNvAPI_EnumNvidiaDisplayHandle)
+ {
+ win_skip("NvAPI_EnumNvidiaDisplayHandle export not found.\n");
+ return;
+ }
+
+ disp = NULL;
+ status = pNvAPI_EnumNvidiaDisplayHandle(0, &disp);
+ ok(status == NVAPI_OK, "Expected status NVAPI_OK, got %d\n", status);
+ ok(disp != NULL, "Expected disp to be non null");
+
+ status = pNvAPI_GetLogicalGPUFromDisplay(NULL, NULL);
+ ok(status == NVAPI_INVALID_POINTER, "Expected status NVAPI_INVALID_POINTER, got %d\n", status);
+
+ status = pNvAPI_GetLogicalGPUFromDisplay(disp, NULL);
+ ok(status == NVAPI_INVALID_POINTER, "Expected status NVAPI_INVALID_POINTER, got %d\n", status);
+
+ status = pNvAPI_GetLogicalGPUFromDisplay((void*)0xdeadbeef, &gpuHandle);
+ ok(status == NVAPI_NVIDIA_DEVICE_NOT_FOUND, "Expected status NVAPI_NVIDIA_DEVICE_NOT_FOUND, got %d\n", status);
+
+ gpuHandle = NULL;
+ status = pNvAPI_GetLogicalGPUFromDisplay(NULL, &gpuHandle);
+ ok(status == NVAPI_OK, "Expected status NVAPI_OK, got %d\n", status);
+ ok(gpuHandle != NULL, "Expected gpuHandle to be non null");
+
+ gpuHandle = NULL;
+ status = pNvAPI_GetLogicalGPUFromDisplay(disp, &gpuHandle);
+ ok(status == NVAPI_OK, "Expected status NVAPI_OK, got %d\n", status);
+ ok(gpuHandle != NULL, "Expected gpuHandle to be non null");
+}
+
static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
@@ -678,6 +723,7 @@ START_TEST( nvapi )
test_NvAPI_DISP_GetGDIPrimaryDisplayId();
test_NvAPI_EnumNvidiaDisplayHandle();
test_NvAPI_SYS_GetDriverAndBranchVersion();
+ test_NvAPI_GetLogicalGPUFromDisplay();
/* d3d9 tests */
wc.lpfnWndProc = DefWindowProcA;
diff --git a/include/nvapi.h b/include/nvapi.h
index 30c02cd..e52e9b1 100644
--- a/include/nvapi.h
+++ b/include/nvapi.h
@@ -29,6 +29,7 @@ typedef unsigned int NvU32;
#define NVAPI_OK 0
#define NVAPI_ERROR -1
#define NVAPI_INVALID_ARGUMENT -5
+#define NVAPI_NVIDIA_DEVICE_NOT_FOUND -6
#define NVAPI_END_ENUMERATION -7
#define NVAPI_INVALID_HANDLE -8
#define NVAPI_INCOMPATIBLE_STRUCT_VERSION -9
--
1.9.1

View File

@ -0,0 +1,52 @@
From da4f75d39fd091fcd6cdad0b67181bbafae86748 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 14 Jan 2015 22:13:57 +0100
Subject: nvapi: Add stub for NvAPI_D3D_GetObjectHandleForResource.
---
dlls/nvapi/nvapi.c | 9 ++++++++-
include/nvapi.h | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/nvapi/nvapi.c b/dlls/nvapi/nvapi.c
index 98658a6..28483be 100644
--- a/dlls/nvapi/nvapi.c
+++ b/dlls/nvapi/nvapi.c
@@ -564,6 +564,12 @@ static NvAPI_Status CDECL NvAPI_GetLogicalGPUFromDisplay(NvDisplayHandle hNvDisp
return NVAPI_OK;
}
+static NvAPI_Status CDECL NvAPI_D3D_GetObjectHandleForResource(IUnknown *pDevice, IUnknown *pResource, NVDX_ObjectHandle *pHandle)
+{
+ FIXME("(%p, %p, %p): stub\n", pDevice, pResource, pHandle);
+ return NVAPI_ERROR;
+}
+
void* CDECL nvapi_QueryInterface(unsigned int offset)
{
static const struct
@@ -603,7 +609,8 @@ void* CDECL nvapi_QueryInterface(unsigned int offset)
{0x2926aaad, NvAPI_SYS_GetDriverAndBranchVersion},
{0xd22bdd7e, NvAPI_Unload},
{0x4b708b54, NvAPI_D3D_GetCurrentSLIState},
- {0xee1370cf, NvAPI_GetLogicalGPUFromDisplay}
+ {0xee1370cf, NvAPI_GetLogicalGPUFromDisplay},
+ {0xfceac864, NvAPI_D3D_GetObjectHandleForResource}
};
unsigned int i;
TRACE("(%x)\n", offset);
diff --git a/include/nvapi.h b/include/nvapi.h
index e52e9b1..ca95a1a 100644
--- a/include/nvapi.h
+++ b/include/nvapi.h
@@ -55,6 +55,7 @@ typedef void *NvPhysicalGpuHandle;
typedef void *NvLogicalGpuHandle;
typedef void *NvDisplayHandle;
typedef void *StereoHandle;
+typedef void *NVDX_ObjectHandle;
typedef struct
{
--
1.9.1

View File

@ -2191,6 +2191,9 @@ if test "$enable_nvapi_Stub_DLL" -eq 1; then
patch_apply nvapi-Stub_DLL/0010-nvapi-Add-stub-for-NvAPI_Unload.patch
patch_apply nvapi-Stub_DLL/0011-nvapi-Add-stub-for-NvAPI_D3D_GetCurrentSLIState.patch
patch_apply nvapi-Stub_DLL/0012-nvapi-Print-fixme-message-for-NvAPI_D3D9_StretchRect.patch
patch_apply nvapi-Stub_DLL/0013-nvapi-tests-Use-structure-to-list-imports.patch
patch_apply nvapi-Stub_DLL/0014-nvapi-Add-stub-for-NvAPI_GetLogicalGPUFromDisplay.patch
patch_apply nvapi-Stub_DLL/0015-nvapi-Add-stub-for-NvAPI_D3D_GetObjectHandleForResou.patch
(
echo '+ { "Michael Müller", "nvapi: First implementation.", 1 },';
echo '+ { "Michael Müller", "nvapi: Add stubs for NvAPI_EnumLogicalGPUs and undocumented equivalent.", 1 },';
@ -2204,6 +2207,9 @@ if test "$enable_nvapi_Stub_DLL" -eq 1; then
echo '+ { "Michael Müller", "nvapi: Add stub for NvAPI_Unload.", 1 },';
echo '+ { "Michael Müller", "nvapi: Add stub for NvAPI_D3D_GetCurrentSLIState.", 1 },';
echo '+ { "Michael Müller", "nvapi: Print fixme message for NvAPI_D3D9_StretchRectEx.", 1 },';
echo '+ { "Michael Müller", "nvapi/tests: Use structure to list imports.", 1 },';
echo '+ { "Michael Müller", "nvapi: Add stub for NvAPI_GetLogicalGPUFromDisplay.", 1 },';
echo '+ { "Michael Müller", "nvapi: Add stub for NvAPI_D3D_GetObjectHandleForResource.", 1 },';
) >> "$patchlist"
fi