Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/d3d11/utils.c | 12 +++++++-----
dlls/d3d8/device.c | 17 +++++++++++------
dlls/d3d9/device.c | 17 +++++++++++------
dlls/ddraw/device.c | 14 +++++++-------
dlls/ddraw/executebuffer.c | 7 +++----
dlls/ddraw/surface.c | 4 ++--
dlls/ddraw/utils.c | 11 ++++++++---
dlls/wined3d/buffer.c | 8 ++++----
dlls/wined3d/context.c | 4 ++--
dlls/wined3d/device.c | 8 ++++----
dlls/wined3d/resource.c | 38 +++++++++++++++++++++++++-------------
dlls/wined3d/surface.c | 17 +++++++++--------
dlls/wined3d/texture.c | 5 +++--
include/wine/wined3d.h | 13 +++++++------
14 files changed, 103 insertions(+), 72 deletions(-)
diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c
index 3a48907..5c6add7 100644
--- a/dlls/d3d11/utils.c
+++ b/dlls/d3d11/utils.c
@@ -758,21 +758,23 @@ DWORD wined3d_map_flags_from_d3d11_map_type(D3D11_MAP map_type)
switch (map_type)
{
case D3D11_MAP_WRITE:
+ return WINED3D_MAP_WRITE;
+
case D3D11_MAP_READ_WRITE:
- return 0;
+ return WINED3D_MAP_READ | WINED3D_MAP_WRITE;
case D3D11_MAP_READ:
- return WINED3D_MAP_READONLY;
+ return WINED3D_MAP_READ;
case D3D11_MAP_WRITE_DISCARD:
- return WINED3D_MAP_DISCARD;
+ return WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD;
case D3D11_MAP_WRITE_NO_OVERWRITE:
- return WINED3D_MAP_NOOVERWRITE;
+ return WINED3D_MAP_WRITE | WINED3D_MAP_NOOVERWRITE;
default:
FIXME("Unhandled map_type %#x.\n", map_type);
- return 0;
+ return WINED3D_MAP_READ | WINED3D_MAP_WRITE;
}
}
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index fc40026..090d196 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -143,15 +143,20 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format)
unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags)
{
- static const unsigned int handled = D3DLOCK_READONLY
- | D3DLOCK_NOSYSLOCK
+ static const unsigned int handled = D3DLOCK_NOSYSLOCK
| D3DLOCK_NOOVERWRITE
| D3DLOCK_DISCARD
| D3DLOCK_NO_DIRTY_UPDATE;
unsigned int wined3d_flags;
wined3d_flags = flags & handled;
- flags &= ~handled;
+ if (!(flags & (D3DLOCK_NOOVERWRITE | D3DLOCK_DISCARD)))
+ wined3d_flags |= WINED3D_MAP_READ;
+ if (!(flags & D3DLOCK_READONLY))
+ wined3d_flags |= WINED3D_MAP_WRITE;
+ if (!(wined3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE)))
+ wined3d_flags |= WINED3D_MAP_READ | WINED3D_MAP_WRITE;
+ flags &= ~(handled | D3DLOCK_READONLY);
if (flags)
FIXME("Unhandled flags %#x.\n", flags);
@@ -2225,7 +2230,7 @@ static HRESULT WINAPI d3d8_device_DrawPrimitiveUP(IDirect3DDevice8 *iface,
wined3d_box.right = vb_pos + size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, data, size);
wined3d_resource_unmap(vb, 0);
@@ -2326,7 +2331,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
wined3d_box.right = vb_pos + vtx_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, (char *)vertex_data + min_vertex_idx * vertex_stride, vtx_size);
wined3d_resource_unmap(vb, 0);
@@ -2348,7 +2353,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, index_data, idx_size);
wined3d_resource_unmap(ib, 0);
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index c057c77..b278d6d 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -162,8 +162,7 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format)
unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags)
{
- static const unsigned int handled = D3DLOCK_READONLY
- | D3DLOCK_NOSYSLOCK
+ static const unsigned int handled = D3DLOCK_NOSYSLOCK
| D3DLOCK_NOOVERWRITE
| D3DLOCK_DISCARD
| D3DLOCK_DONOTWAIT
@@ -171,7 +170,13 @@ unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags)
unsigned int wined3d_flags;
wined3d_flags = flags & handled;
- flags &= ~handled;
+ if (!(flags & (D3DLOCK_NOOVERWRITE | D3DLOCK_DISCARD)))
+ wined3d_flags |= WINED3D_MAP_READ;
+ if (!(flags & D3DLOCK_READONLY))
+ wined3d_flags |= WINED3D_MAP_WRITE;
+ if (!(wined3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE)))
+ wined3d_flags |= WINED3D_MAP_READ | WINED3D_MAP_WRITE;
+ flags &= ~(handled | D3DLOCK_READONLY);
if (flags)
FIXME("Unhandled flags %#x.\n", flags);
@@ -2737,7 +2742,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface,
wined3d_box.right = vb_pos + size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, data, size);
wined3d_resource_unmap(vb, 0);
@@ -2848,7 +2853,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
wined3d_box.right = vb_pos + vtx_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, (char *)vertex_data + min_vertex_idx * vertex_stride, vtx_size);
wined3d_resource_unmap(vb, 0);
@@ -2870,7 +2875,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, index_data, idx_size);
wined3d_resource_unmap(ib, 0);
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index d31d598..463d036 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -3533,7 +3533,7 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface,
wined3d_box.right = vb_pos + size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, vertices, size);
wined3d_resource_unmap(vb, 0);
@@ -3725,7 +3725,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
wined3d_box.right = vb_pos + vtx_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, vertices, vtx_size);
wined3d_resource_unmap(vb, 0);
@@ -3742,7 +3742,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, indices, idx_size);
wined3d_resource_unmap(ib, 0);
@@ -4056,7 +4056,7 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIM
wined3d_box.right = vb_pos + dst_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
pack_strided_data(wined3d_map_desc.data, vertex_count, strided_data, fvf);
wined3d_resource_unmap(vb, 0);
@@ -4172,7 +4172,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
wined3d_box.right = vb_pos + vtx_dst_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
pack_strided_data(wined3d_map_desc.data, vertex_count, strided_data, fvf);
wined3d_resource_unmap(vb, 0);
@@ -4189,7 +4189,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, indices, idx_size);
wined3d_resource_unmap(ib, 0);
@@ -4409,7 +4409,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
wined3d_box.right = ib_pos + index_count * sizeof(WORD);
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
{
ERR("Failed to map buffer, hr %#x.\n", hr);
wined3d_mutex_unlock();
diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c
index b47606a..19ef9c0 100644
--- a/dlls/ddraw/executebuffer.c
+++ b/dlls/ddraw/executebuffer.c
@@ -152,9 +152,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer,
box.left = index_pos * sizeof(*indices);
box.right = (index_pos + index_count) * sizeof(*indices);
- hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0,
- &map_desc, &box, index_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD);
- if (FAILED(hr))
+ if (FAILED(hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0, &map_desc,
+ &box, WINED3D_MAP_WRITE | (index_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
return hr;
indices = map_desc.data;
@@ -661,7 +660,7 @@ static HRESULT WINAPI d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer *
box.left = buffer->src_vertex_pos * sizeof(D3DVERTEX);
box.right = box.left + data->dwVertexCount * sizeof(D3DVERTEX);
if (FAILED(hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->src_vertex_buffer),
- 0, &map_desc, &box, 0)))
+ 0, &map_desc, &box, WINED3D_MAP_WRITE)))
return hr;
memcpy(map_desc.data, ((BYTE *)buffer->desc.lpData) + data->dwVertexOffset,
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index f09aaba..8280990 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -5281,7 +5281,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
}
if (FAILED(hr = wined3d_resource_map(src_resource,
- src_surface->sub_resource_idx, &src_map_desc, NULL, 0)))
+ src_surface->sub_resource_idx, &src_map_desc, NULL, WINED3D_MAP_READ)))
{
ERR("Failed to lock source surface, hr %#x.\n", hr);
wined3d_mutex_unlock();
@@ -5289,7 +5289,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
}
if (FAILED(hr = wined3d_resource_map(dst_resource,
- dst_surface->sub_resource_idx, &dst_map_desc, NULL, 0)))
+ dst_surface->sub_resource_idx, &dst_map_desc, NULL, WINED3D_MAP_WRITE)))
{
ERR("Failed to lock destination surface, hr %#x.\n", hr);
wined3d_resource_unmap(src_resource, src_surface->sub_resource_idx);
diff --git a/dlls/ddraw/utils.c b/dlls/ddraw/utils.c
index bb75666..0170fcd 100644
--- a/dlls/ddraw/utils.c
+++ b/dlls/ddraw/utils.c
@@ -563,17 +563,22 @@ enum wined3d_format_id wined3dformat_from_ddrawformat(const DDPIXELFORMAT *DDPix
unsigned int wined3dmapflags_from_ddrawmapflags(unsigned int flags)
{
- static const unsigned int handled = DDLOCK_READONLY
- | DDLOCK_NOSYSLOCK
+ static const unsigned int handled = DDLOCK_NOSYSLOCK
| DDLOCK_NOOVERWRITE
| DDLOCK_DISCARDCONTENTS
| DDLOCK_DONOTWAIT;
unsigned int wined3d_flags;
wined3d_flags = flags & handled;
+ if (!(flags & (DDLOCK_NOOVERWRITE | DDLOCK_DISCARDCONTENTS)))
+ wined3d_flags |= WINED3D_MAP_READ;
+ if (!(flags & DDLOCK_READONLY))
+ wined3d_flags |= WINED3D_MAP_WRITE;
+ if (!(wined3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE)))
+ wined3d_flags |= WINED3D_MAP_READ | WINED3D_MAP_WRITE;
if (flags & DDLOCK_NODIRTYUPDATE)
wined3d_flags |= WINED3D_MAP_NO_DIRTY_UPDATE;
- flags &= ~(handled | DDLOCK_WAIT | DDLOCK_NODIRTYUPDATE);
+ flags &= ~(handled | DDLOCK_WAIT | DDLOCK_READONLY | DDLOCK_NODIRTYUPDATE);
if (flags)
FIXME("Unhandled flags %#x.\n", flags);
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index c1dfc56..1055326 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1024,8 +1024,8 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
dirty_size = 0;
}
- if (!(flags & (WINED3D_MAP_NOOVERWRITE | WINED3D_MAP_DISCARD | WINED3D_MAP_READONLY))
- || ((flags & WINED3D_MAP_READONLY) && (buffer->locations & WINED3D_LOCATION_SYSMEM))
+ if (((flags & WINED3D_MAP_WRITE) && !(flags & (WINED3D_MAP_NOOVERWRITE | WINED3D_MAP_DISCARD)))
+ || (!(flags & WINED3D_MAP_WRITE) && (buffer->locations & WINED3D_LOCATION_SYSMEM))
|| buffer->flags & WINED3D_BUFFER_PIN_SYSMEM)
{
if (!(buffer->locations & WINED3D_LOCATION_SYSMEM))
@@ -1035,7 +1035,7 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
context_release(context);
}
- if (!(flags & WINED3D_MAP_READONLY))
+ if (flags & WINED3D_MAP_WRITE)
wined3d_buffer_invalidate_range(buffer, WINED3D_LOCATION_BUFFER, dirty_offset, dirty_size);
}
else
@@ -1050,7 +1050,7 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
else
wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER);
- if (!(flags & WINED3D_MAP_READONLY))
+ if (flags & WINED3D_MAP_WRITE)
buffer_invalidate_bo_range(buffer, dirty_offset, dirty_size);
if ((flags & WINED3D_MAP_DISCARD) && buffer->resource.heap_memory)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index b97dff5..9b6c19e 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2837,8 +2837,8 @@ void context_copy_bo_address(struct wined3d_context *context,
}
else
{
- src_ptr = context_map_bo_address(context, src, size, src_binding, WINED3D_MAP_READONLY);
- dst_ptr = context_map_bo_address(context, dst, size, dst_binding, 0);
+ src_ptr = context_map_bo_address(context, src, size, src_binding, WINED3D_MAP_READ);
+ dst_ptr = context_map_bo_address(context, dst, size, dst_binding, WINED3D_MAP_WRITE);
memcpy(dst_ptr, src_ptr, size);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 17103cc..6e275e1 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3078,7 +3078,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
vertex_size = get_flexible_vertex_size(DestFVF);
box.left = dwDestIndex * vertex_size;
box.right = box.left + dwCount * vertex_size;
- if (FAILED(hr = wined3d_resource_map(&dest->resource, 0, &map_desc, &box, 0)))
+ if (FAILED(hr = wined3d_resource_map(&dest->resource, 0, &map_desc, &box, WINED3D_MAP_WRITE)))
{
WARN("Failed to map buffer, hr %#x.\n", hr);
return hr;
@@ -3342,7 +3342,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
resource = &state->streams[e->stream_idx].buffer->resource;
box.left = src_start_idx * e->stride;
box.right = box.left + vertex_count * e->stride;
- if (FAILED(wined3d_resource_map(resource, 0, &map_desc, &box, WINED3D_MAP_READONLY)))
+ if (FAILED(wined3d_resource_map(resource, 0, &map_desc, &box, WINED3D_MAP_READ)))
ERR("Failed to map resource.\n");
e->data.buffer_object = 0;
e->data.addr += (ULONG_PTR)map_desc.data;
@@ -4499,7 +4499,7 @@ static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined
struct wined3d_texture *texture;
HRESULT hr;
- if (FAILED(wined3d_resource_map(&cursor_image->resource, sub_resource_idx, &map_desc, NULL, WINED3D_MAP_READONLY)))
+ if (FAILED(wined3d_resource_map(&cursor_image->resource, sub_resource_idx, &map_desc, NULL, WINED3D_MAP_READ)))
{
ERR("Failed to map source texture.\n");
return NULL;
@@ -4603,7 +4603,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
memset(mask_bits, 0xff, mask_size);
wined3d_resource_map(&texture->resource, sub_resource_idx, &map_desc, NULL,
- WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY);
+ WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READ);
cursor_info.fIcon = FALSE;
cursor_info.xHotspot = x_hotspot;
cursor_info.yHotspot = y_hotspot;
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index ddc157b..ac36183 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -306,17 +306,17 @@ static DWORD wined3d_resource_sanitise_map_flags(const struct wined3d_resource *
{
/* Not all flags make sense together, but Windows never returns an error.
* Catch the cases that could cause issues. */
- if (flags & WINED3D_MAP_READONLY)
+ if (flags & WINED3D_MAP_READ)
{
if (flags & WINED3D_MAP_DISCARD)
{
- WARN("WINED3D_MAP_READONLY combined with WINED3D_MAP_DISCARD, ignoring flags.\n");
- return 0;
+ WARN("WINED3D_MAP_READ combined with WINED3D_MAP_DISCARD, ignoring flags.\n");
+ return flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE);
}
if (flags & WINED3D_MAP_NOOVERWRITE)
{
- WARN("WINED3D_MAP_READONLY combined with WINED3D_MAP_NOOVERWRITE, ignoring flags.\n");
- return 0;
+ WARN("WINED3D_MAP_READ combined with WINED3D_MAP_NOOVERWRITE, ignoring flags.\n");
+ return flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE);
}
}
else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
@@ -324,7 +324,7 @@ static DWORD wined3d_resource_sanitise_map_flags(const struct wined3d_resource *
if (!(resource->usage & WINED3DUSAGE_DYNAMIC))
{
WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n");
- return 0;
+ return flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE);
}
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
== (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
@@ -343,6 +343,12 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i
TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
resource, sub_resource_idx, map_desc, debug_box(box), flags);
+ if (!(flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE)))
+ {
+ WARN("No read/write flags specified.\n");
+ return E_INVALIDARG;
+ }
+
if (!(resource->access & WINED3D_RESOURCE_ACCESS_MAP))
{
WARN("Resource is not mappable.\n");
@@ -399,9 +405,9 @@ GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags)
{
GLbitfield ret = 0;
- if (!(d3d_flags & WINED3D_MAP_READONLY))
+ if (d3d_flags & WINED3D_MAP_WRITE)
ret |= GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
- if (!(d3d_flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)))
+ if (d3d_flags & WINED3D_MAP_READ)
ret |= GL_MAP_READ_BIT;
if (d3d_flags & WINED3D_MAP_DISCARD)
@@ -414,11 +420,17 @@ GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags)
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags)
{
- if (d3d_flags & WINED3D_MAP_READONLY)
- return GL_READ_ONLY_ARB;
- if (d3d_flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
- return GL_WRITE_ONLY_ARB;
- return GL_READ_WRITE_ARB;
+ switch (d3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE))
+ {
+ case WINED3D_MAP_READ:
+ return GL_READ_ONLY_ARB;
+
+ case WINED3D_MAP_WRITE:
+ return GL_WRITE_ONLY_ARB;
+
+ default:
+ return GL_READ_WRITE_ARB;
+ }
}
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 5cb9cda..7cf9c21 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1369,9 +1369,9 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
wined3d_texture_get_memory(dst_texture, 0, &dst_data, map_binding);
src = context_map_bo_address(context, &src_data,
- src_texture->sub_resources[sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, 0);
+ src_texture->sub_resources[sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
dst = context_map_bo_address(context,
- &dst_data, dst_texture->sub_resources[0].size, GL_PIXEL_UNPACK_BUFFER, 0);
+ &dst_data, dst_texture->sub_resources[0].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
conv->convert(src, dst, src_row_pitch, dst_row_pitch, desc.width, desc.height);
@@ -2325,7 +2325,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
wined3d_format_calculate_pitch(&format, 1, width, height, &dst_row_pitch, &dst_slice_pitch);
src_mem = context_map_bo_address(context, &data, src_slice_pitch,
- GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READONLY);
+ GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
if (!(dst_mem = heap_alloc(dst_slice_pitch)))
{
ERR("Out of memory (%u).\n", dst_slice_pitch);
@@ -2349,7 +2349,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
width, height, &dst_row_pitch, &dst_slice_pitch);
src_mem = context_map_bo_address(context, &data, src_slice_pitch,
- GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READONLY);
+ GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
if (!(dst_mem = heap_alloc(dst_slice_pitch)))
{
ERR("Out of memory (%u).\n", dst_slice_pitch);
@@ -3113,7 +3113,8 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, &dst_data, map_binding);
dst_map.data = context_map_bo_address(context, &dst_data,
- dst_texture->sub_resources[dst_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, 0);
+ dst_texture->sub_resources[dst_sub_resource_idx].size,
+ GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ | WINED3D_MAP_WRITE);
src_map = dst_map;
src_format = dst_texture->resource.format;
@@ -3149,7 +3150,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
wined3d_texture_get_pitch(src_texture, texture_level, &src_map.row_pitch, &src_map.slice_pitch);
wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &src_data, map_binding);
src_map.data = context_map_bo_address(context, &src_data,
- src_texture->sub_resources[src_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, 0);
+ src_texture->sub_resources[src_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
map_binding = dst_texture->resource.map_binding;
texture_level = dst_sub_resource_idx % dst_texture->level_count;
@@ -3159,7 +3160,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, &dst_data, map_binding);
dst_map.data = context_map_bo_address(context, &dst_data,
- dst_texture->sub_resources[dst_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, 0);
+ dst_texture->sub_resources[dst_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
}
flags &= ~WINED3D_BLT_RAW;
@@ -3600,7 +3601,7 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
&map.row_pitch, &map.slice_pitch);
wined3d_texture_get_memory(texture, view->sub_resource_idx, &data, map_binding);
map.data = context_map_bo_address(context, &data,
- texture->sub_resources[view->sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, 0);
+ texture->sub_resources[view->sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
map.data = (BYTE *)map.data
+ (box->front * map.slice_pitch)
+ ((box->top / view->format->block_height) * map.row_pitch)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 57e6427..77ba007 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1224,7 +1224,8 @@ static void texture2d_create_dc(void *object)
wined3d_texture_get_pitch(texture, surface->texture_level, &row_pitch, &slice_pitch);
wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
desc.pMemory = context_map_bo_address(context, &data,
- texture->sub_resources[sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, 0);
+ texture->sub_resources[sub_resource_idx].size,
+ GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ | WINED3D_MAP_WRITE);
if (context)
context_release(context);
@@ -1903,7 +1904,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
return E_OUTOFMEMORY;
}
- if (!(flags & WINED3D_MAP_READONLY)
+ if (flags & WINED3D_MAP_WRITE
&& (!(flags & WINED3D_MAP_NO_DIRTY_UPDATE) || (resource->usage & WINED3DUSAGE_DYNAMIC)))
wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 1e3c08b..f329c6f 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -912,12 +912,13 @@ enum wined3d_shader_byte_code_format
#define WINED3DUSAGE_QUERY_WRAPANDMIP 0x00200000
#define WINED3DUSAGE_QUERY_MASK 0x003f8400
-#define WINED3D_MAP_READONLY 0x0010
-#define WINED3D_MAP_NOSYSLOCK 0x0800
-#define WINED3D_MAP_NOOVERWRITE 0x1000
-#define WINED3D_MAP_DISCARD 0x2000
-#define WINED3D_MAP_DONOTWAIT 0x4000
-#define WINED3D_MAP_NO_DIRTY_UPDATE 0x8000
+#define WINED3D_MAP_NOSYSLOCK 0x00000800
+#define WINED3D_MAP_NOOVERWRITE 0x00001000
+#define WINED3D_MAP_DISCARD 0x00002000
+#define WINED3D_MAP_DONOTWAIT 0x00004000
+#define WINED3D_MAP_NO_DIRTY_UPDATE 0x00008000
+#define WINED3D_MAP_WRITE 0x40000000
+#define WINED3D_MAP_READ 0x80000000
#define WINED3DPRESENT_RATE_DEFAULT 0x00000000
--
2.1.4