Justin Martin : d3d9: Implement d3d9_device_CreateRenderTargetEx().

Alexandre Julliard julliard at winehq.org
Tue Jun 25 17:25:51 CDT 2019


Module: wine
Branch: master
Commit: 6ad6c1ff4afe290482a5ac566e4d3f41f99b1e34
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6ad6c1ff4afe290482a5ac566e4d3f41f99b1e34

Author: Justin Martin <jaming at protonmail.com>
Date:   Tue Jun 25 16:48:24 2019 +0430

d3d9: Implement d3d9_device_CreateRenderTargetEx().

Signed-off-by: Justin Martin <jaming at protonmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d9/device.c       | 21 ++++++++++++++++++---
 dlls/d3d9/tests/d3d9ex.c |  5 ++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 9fbdceb..e2da02b 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -4059,16 +4059,31 @@ static HRESULT WINAPI d3d9_device_CreateRenderTargetEx(IDirect3DDevice9Ex *iface
         UINT width, UINT height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality,
         BOOL lockable, IDirect3DSurface9 **surface, HANDLE *shared_handle, DWORD usage)
 {
-    FIXME("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u, "
-            "lockable %#x, surface %p, shared_handle %p, usage %#x stub!\n",
+    struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
+    unsigned int access = WINED3D_RESOURCE_ACCESS_GPU;
+
+    TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u, "
+            "lockable %#x, surface %p, shared_handle %p, usage %#x.\n",
             iface, width, height, format, multisample_type, multisample_quality,
             lockable, surface, shared_handle, usage);
 
     *surface = NULL;
+
+    if (usage & (D3DUSAGE_DEPTHSTENCIL | D3DUSAGE_RENDERTARGET))
+    {
+        WARN("Invalid usage %#x.\n", usage);
+        return D3DERR_INVALIDCALL;
+    }
+
     if (shared_handle)
         FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
 
-    return E_NOTIMPL;
+    if (lockable)
+        access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
+
+    return d3d9_device_create_surface(device, 0, wined3dformat_from_d3dformat(format),
+            multisample_type, multisample_quality, usage & WINED3DUSAGE_MASK,
+            WINED3D_BIND_RENDER_TARGET, access, width, height, NULL, surface);
 }
 
 static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurfaceEx(IDirect3DDevice9Ex *iface,
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 306241a..354a51d 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -3932,7 +3932,7 @@ static void test_format_unknown(void)
     iface = (void *)0xdeadbeef;
     hr = IDirect3DDevice9Ex_CreateRenderTargetEx(device, 64, 64,
             D3DFMT_UNKNOWN, D3DMULTISAMPLE_NONE, 0, FALSE, (IDirect3DSurface9 **)&iface, NULL, 0);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
     ok(!iface, "Got unexpected iface %p.\n", iface);
 
     iface = (void *)0xdeadbeef;
@@ -4372,8 +4372,7 @@ static void test_resource_access(void)
                 case SURFACE_RT_EX:
                     hr = IDirect3DDevice9Ex_CreateRenderTargetEx(device, 16, 16, format, D3DMULTISAMPLE_NONE,
                             0, tests[j].pool != D3DPOOL_DEFAULT, &surface, NULL, tests[j].usage);
-                    todo_wine
-                        ok(hr == (tests[j].format == FORMAT_COLOUR && !tests[j].usage ? D3D_OK : D3DERR_INVALIDCALL),
+                    ok(hr == (tests[j].format == FORMAT_COLOUR && !tests[j].usage ? D3D_OK : D3DERR_INVALIDCALL),
                                 "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
                     if (FAILED(hr))
                         continue;




More information about the wine-cvs mailing list