d3d9: Handle multisample depth resolve in d3d9_device_SetRenderState().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-01-27 09:23:14 -06:00 committed by Alexandre Julliard
parent 7654d58b04
commit cff0496efb
4 changed files with 47 additions and 2 deletions

View File

@ -47,6 +47,9 @@
#define D3D9_TEXTURE_MIPMAP_DIRTY 0x1
#define D3DFMT_RESZ MAKEFOURCC('R','E','S','Z')
#define D3D9_RESZ_CODE 0x7fa05000
extern const struct wined3d_parent_ops d3d9_null_wined3d_parent_ops DECLSPEC_HIDDEN;
HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN;

View File

@ -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 == D3D9_RESZ_CODE)
resolve_depth_buffer(device);
wined3d_mutex_unlock();
return D3D_OK;

View File

@ -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 (format == D3DFMT_RESZ && resource_type == D3DRTYPE_SURFACE && usage == D3DUSAGE_RENDERTARGET)
{
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;

View File

@ -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
};