[PATCH 3/5] d3d9: Handle multisample depth resolve in d3d9_device_SetRenderState().

Zebediah Figura z.figura12 at gmail.com
Wed Jan 22 16:55:44 CST 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d9/device.c     | 30 ++++++++++++++++++++++++++++++
 dlls/d3d9/directx.c    | 14 ++++++++++++--
 include/wine/wined3d.h |  2 ++
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index be9c2a9d5a..14d2a0cc25 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2299,6 +2299,34 @@ static HRESULT WINAPI d3d9_device_GetClipPlane(IDirect3DDevice9Ex *iface, DWORD
     return hr;
 }
 
+static void resolve_depth_buffer(struct d3d9_device *device)
+{
+    const struct wined3d_stateblock_state *state = wined3d_stateblock_get_state(device->state);
+    struct wined3d_rendertarget_view *wined3d_dsv;
+    struct wined3d_resource *dst_resource;
+    struct wined3d_texture *dst_texture;
+    struct wined3d_resource_desc desc;
+    struct d3d9_surface *d3d9_dsv;
+
+    if (!(dst_texture = state->textures[0]))
+        return;
+    dst_resource = wined3d_texture_get_resource(dst_texture);
+    wined3d_resource_get_desc(dst_resource, &desc);
+    if (desc.format != WINED3DFMT_D24_UNORM_S8_UINT
+            && desc.format != WINED3DFMT_X8D24_UNORM
+            && desc.format != WINED3DFMT_DF16
+            && desc.format != WINED3DFMT_DF24
+            && desc.format != WINED3DFMT_INTZ)
+        return;
+
+    if (!(wined3d_dsv = wined3d_device_get_depth_stencil_view(device->wined3d_device)))
+        return;
+    d3d9_dsv = wined3d_rendertarget_view_get_sub_resource_parent(wined3d_dsv);
+
+    wined3d_device_resolve_sub_resource(device->wined3d_device, dst_resource, 0,
+            wined3d_rendertarget_view_get_resource(wined3d_dsv), d3d9_dsv->sub_resource_idx, desc.format);
+}
+
 static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevice9Ex *iface,
         D3DRENDERSTATETYPE state, DWORD value)
 {
@@ -2319,6 +2347,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi
         else
             wined3d_device_set_render_state(device->wined3d_device, state, value);
     }
+    if (state == D3DRS_POINTSIZE && value == WINED3D_RESZ_CODE)
+        resolve_depth_buffer(device);
     wined3d_mutex_unlock();
 
     return D3D_OK;
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 1d3754adf8..fd22259e17 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -289,8 +289,18 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter,
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format),
-            usage, bind_flags, wined3d_rtype, wined3dformat_from_d3dformat(format));
+    if ((enum wined3d_format_id)format == WINED3DFMT_RESZ)
+    {
+        DWORD levels;
+        hr = wined3d_check_device_multisample_type(d3d9->wined3d, adapter, device_type,
+                WINED3DFMT_D24_UNORM_S8_UINT, FALSE, WINED3D_MULTISAMPLE_NON_MASKABLE, &levels);
+        if (SUCCEEDED(hr) && !levels)
+            hr = D3DERR_NOTAVAILABLE;
+    }
+    else
+        hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type,
+                wined3dformat_from_d3dformat(adapter_format), usage, bind_flags,
+                wined3d_rtype, wined3dformat_from_d3dformat(format));
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 4306f5ae21..d313c7aec8 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -267,6 +267,8 @@ enum wined3d_format_id
     WINED3DFMT_R16                          = WINEMAKEFOURCC(' ','R','1','6'),
     WINED3DFMT_AL16                         = WINEMAKEFOURCC('A','L','1','6'),
     WINED3DFMT_NV12                         = WINEMAKEFOURCC('N','V','1','2'),
+    WINED3DFMT_DF16                         = WINEMAKEFOURCC('D','F','1','6'),
+    WINED3DFMT_DF24                         = WINEMAKEFOURCC('D','F','2','4'),
 
     WINED3DFMT_FORCE_DWORD = 0xffffffff
 };
-- 
2.25.0




More information about the wine-devel mailing list