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

Zebediah Figura z.figura12 at gmail.com
Tue Dec 10 21:43:52 CST 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
v2: Expose a common helper in wined3d to be used for d3d9 and d3d8, and also
move the check for format support to d3d9_CheckDeviceFormat().

 dlls/d3d9/device.c        |  2 ++
 dlls/d3d9/directx.c       | 14 ++++++++++++--
 dlls/wined3d/device.c     |  4 ++--
 dlls/wined3d/wined3d.spec |  1 +
 include/wine/wined3d.h    |  1 +
 5 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index be9c2a9d5a..d949fd89b2 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2319,6 +2319,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)
+        wined3d_device_resolve_depth_buffer(device->wined3d_device);
     wined3d_mutex_unlock();
 
     return D3D_OK;
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 1d3754adf8..d7fb30729d 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_NONE, &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/dlls/wined3d/device.c b/dlls/wined3d/device.c
index acc915eb55..74dc21046b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1784,7 +1784,7 @@ void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, uns
         *viewport_count = device->state.viewport_count;
 }
 
-static void resolve_depth_buffer(struct wined3d_device *device)
+void CDECL wined3d_device_resolve_depth_buffer(struct wined3d_device *device)
 {
     const struct wined3d_state *state = &device->state;
     struct wined3d_rendertarget_view *src_view;
@@ -1883,7 +1883,7 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
     if (state == WINED3D_RS_POINTSIZE && value == WINED3D_RESZ_CODE)
     {
         TRACE("RESZ multisampled depth buffer resolve triggered.\n");
-        resolve_depth_buffer(device);
+        wined3d_device_resolve_depth_buffer(device);
     }
 }
 
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index c8ef442c72..f42d2762c5 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -126,6 +126,7 @@
 @ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
 @ cdecl wined3d_device_release_focus_window(ptr)
 @ cdecl wined3d_device_reset(ptr ptr ptr ptr long)
+@ cdecl wined3d_device_resolve_depth_buffer(ptr)
 @ cdecl wined3d_device_resolve_sub_resource(ptr ptr long ptr long long)
 @ cdecl wined3d_device_set_base_vertex_index(ptr long)
 @ cdecl wined3d_device_set_blend_state(ptr ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 8951f92d14..218e5e99f1 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2435,6 +2435,7 @@ void __cdecl wined3d_device_release_focus_window(struct wined3d_device *device);
 HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device,
         const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode,
         wined3d_device_reset_cb callback, BOOL reset_state);
+void __cdecl wined3d_device_resolve_depth_buffer(struct wined3d_device *device);
 void __cdecl wined3d_device_resolve_sub_resource(struct wined3d_device *device,
         struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx,
         struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx,
-- 
2.24.0




More information about the wine-devel mailing list