From fec925b4517cc16ac478927a361a3260a917a898 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 3 Jan 2015 00:25:08 +0100
Subject: nvcuda: Emulate two d3d9 initialization functions.

---
 dlls/nvcuda/nvcuda.c    | 30 ++++++++++++++++++++++++++++++
 dlls/nvcuda/nvcuda.spec |  4 ++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/dlls/nvcuda/nvcuda.c b/dlls/nvcuda/nvcuda.c
index bd39547..826c30b 100644
--- a/dlls/nvcuda/nvcuda.c
+++ b/dlls/nvcuda/nvcuda.c
@@ -29,6 +29,7 @@
 #include "wine/wgl.h"
 #include "cuda.h"
 #include "nvcuda.h"
+#include "d3d9.h"
 
 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
 #define DEV_PTR "%llu"
@@ -2214,6 +2215,35 @@ CUresult WINAPI wine_cuOccupancyMaxPotentialBlockSize(int *minGridSize, int *blo
 }
 */
 
+/*
+ * Direct3D emulated functions
+ */
+
+CUresult WINAPI wine_cuD3D9CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, IDirect3DDevice9 *pD3DDevice)
+{
+    CUresult ret;
+    CUdevice dev;
+
+    FIXME("(%p, %p, %u, %p) - semi-stub\n", pCtx, pCudaDevice, Flags, pD3DDevice);
+
+    ret = pcuDeviceGet(&dev, 0);
+    if (ret) return ret;
+
+    ret = pcuCtxCreate(pCtx, Flags, dev);
+    if (ret) return ret;
+
+    if (pCudaDevice)
+        *pCudaDevice = dev;
+
+    return CUDA_SUCCESS;
+}
+
+CUresult WINAPI wine_cuD3D9GetDevice(CUdevice *pCudaDevice, const char *pszAdapterName)
+{
+    FIXME("(%p, %s) - semi-stub\n", pCudaDevice, pszAdapterName);
+    return pcuDeviceGet(pCudaDevice, 0);
+}
+
 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
 {
     TRACE("(%p, %u, %p)\n", instance, reason, reserved);
diff --git a/dlls/nvcuda/nvcuda.spec b/dlls/nvcuda/nvcuda.spec
index c23faa4..5ca921e 100644
--- a/dlls/nvcuda/nvcuda.spec
+++ b/dlls/nvcuda/nvcuda.spec
@@ -58,11 +58,11 @@
 @ stub cuD3D11GetDevices
 @ stub cuD3D11GetDirect3DDevice
 @ stub cuD3D9Begin
-@ stub cuD3D9CtxCreate
+@ stdcall cuD3D9CtxCreate(ptr ptr long ptr) wine_cuD3D9CtxCreate
 @ stub cuD3D9CtxCreateOnDevice
 @ stub cuD3D9CtxCreate_v2
 @ stub cuD3D9End
-@ stub cuD3D9GetDevice
+@ stdcall cuD3D9GetDevice(ptr str) wine_cuD3D9GetDevice
 @ stub cuD3D9GetDevices
 @ stub cuD3D9GetDirect3DDevice
 @ stub cuD3D9MapResources
-- 
2.2.1

