ddraw: Explicitly translate resource map flags.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-02-16 09:39:05 +03:30 committed by Alexandre Julliard
parent b6f917b102
commit 72c31c146b
4 changed files with 25 additions and 13 deletions

View File

@ -587,6 +587,7 @@ void ddrawformat_from_wined3dformat(DDPIXELFORMAT *ddraw_format,
BOOL wined3d_colour_from_ddraw_colour(const DDPIXELFORMAT *pf, const struct ddraw_palette *palette,
DWORD colour, struct wined3d_color *wined3d_colour) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_ddrawformat(const DDPIXELFORMAT *format) DECLSPEC_HIDDEN;
unsigned int wined3dmapflags_from_ddrawmapflags(unsigned int flags) DECLSPEC_HIDDEN;
void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd) DECLSPEC_HIDDEN;
void dump_D3DMATRIX(const D3DMATRIX *mat) DECLSPEC_HIDDEN;
void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN;

View File

@ -992,7 +992,8 @@ static HRESULT surface_lock(struct ddraw_surface *surface,
hr = ddraw_surface_update_frontbuffer(surface, rect, TRUE);
if (SUCCEEDED(hr))
hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture),
surface->sub_resource_idx, &map_desc, rect ? &box : NULL, flags);
surface->sub_resource_idx, &map_desc, rect ? &box : NULL,
wined3dmapflags_from_ddrawmapflags(flags));
if (FAILED(hr))
{
wined3d_mutex_unlock();

View File

@ -561,6 +561,26 @@ enum wined3d_format_id wined3dformat_from_ddrawformat(const DDPIXELFORMAT *DDPix
return WINED3DFMT_UNKNOWN;
}
unsigned int wined3dmapflags_from_ddrawmapflags(unsigned int flags)
{
static const unsigned int handled = DDLOCK_READONLY
| DDLOCK_NOSYSLOCK
| DDLOCK_NOOVERWRITE
| DDLOCK_DISCARDCONTENTS
| DDLOCK_DONOTWAIT;
unsigned int wined3d_flags;
wined3d_flags = flags & handled;
if (flags & DDLOCK_NODIRTYUPDATE)
wined3d_flags |= WINED3D_MAP_NO_DIRTY_UPDATE;
flags &= ~(handled | DDLOCK_WAIT | DDLOCK_NODIRTYUPDATE);
if (flags)
FIXME("Unhandled flags %#x.\n", flags);
return wined3d_flags;
}
static float colour_to_float(DWORD colour, DWORD mask)
{
if (!mask)

View File

@ -162,26 +162,16 @@ static HRESULT WINAPI d3d_vertex_buffer7_Lock(IDirect3DVertexBuffer7 *iface,
struct wined3d_resource *wined3d_resource;
struct wined3d_map_desc wined3d_map_desc;
HRESULT hr;
DWORD wined3d_flags = 0;
TRACE("iface %p, flags %#x, data %p, data_size %p.\n", iface, flags, data, data_size);
if (buffer->version != 7)
flags &= ~(DDLOCK_NOOVERWRITE | DDLOCK_DISCARDCONTENTS);
/* Writeonly: Pointless. Event: Unsupported by native according to the sdk
* nosyslock: Not applicable
*/
if (!(flags & DDLOCK_WAIT))
wined3d_flags |= WINED3D_MAP_DONOTWAIT;
if (flags & DDLOCK_READONLY)
wined3d_flags |= WINED3D_MAP_READONLY;
if (flags & DDLOCK_NOOVERWRITE)
wined3d_flags |= WINED3D_MAP_NOOVERWRITE;
flags |= DDLOCK_DONOTWAIT;
if (flags & DDLOCK_DISCARDCONTENTS)
{
wined3d_flags |= WINED3D_MAP_DISCARD;
if (!buffer->dynamic)
{
struct wined3d_buffer *new_buffer;
@ -211,7 +201,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_Lock(IDirect3DVertexBuffer7 *iface,
}
hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer),
0, &wined3d_map_desc, NULL, wined3d_flags);
0, &wined3d_map_desc, NULL, wined3dmapflags_from_ddrawmapflags(flags));
*data = wined3d_map_desc.data;
wined3d_mutex_unlock();