Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/d3d10core/tests/device.c | 16 ++++++++--------
dlls/d3d11/buffer.c | 4 +---
dlls/d3d11/d3d11_private.h | 1 +
dlls/d3d11/tests/d3d11.c | 8 ++++----
dlls/d3d11/texture.c | 8 ++++----
dlls/d3d11/utils.c | 15 +++++++++++++++
dlls/d3d8/volume.c | 2 ++
dlls/d3d9/volume.c | 2 ++
dlls/wined3d/resource.c | 2 +-
9 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 103b670..9b512f9 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -8199,28 +8199,28 @@ static void check_buffer_cpu_access_(unsigned int line, ID3D10Buffer *buffer,
expected_hr = cpu_read ? S_OK : E_INVALIDARG;
hr = ID3D10Buffer_Map(buffer, D3D10_MAP_READ, 0, &data);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ.\n", hr);
if (SUCCEEDED(hr))
ID3D10Buffer_Unmap(buffer);
expected_hr = !dynamic && cpu_write ? S_OK : E_INVALIDARG;
hr = ID3D10Buffer_Map(buffer, D3D10_MAP_WRITE, 0, &data);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE.\n", hr);
if (SUCCEEDED(hr))
ID3D10Buffer_Unmap(buffer);
expected_hr = cpu_read && cpu_write ? S_OK : E_INVALIDARG;
hr = ID3D10Buffer_Map(buffer, D3D10_MAP_READ_WRITE, 0, &data);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ_WRITE.\n", hr);
if (SUCCEEDED(hr))
ID3D10Buffer_Unmap(buffer);
expected_hr = dynamic ? S_OK : E_INVALIDARG;
hr = ID3D10Buffer_Map(buffer, D3D10_MAP_WRITE_DISCARD, 0, &data);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE_DISCARD.\n", hr);
if (SUCCEEDED(hr))
ID3D10Buffer_Unmap(buffer);
@@ -8254,28 +8254,28 @@ static void check_texture_cpu_access_(unsigned int line, ID3D10Texture2D *textur
expected_hr = cpu_read ? S_OK : E_INVALIDARG;
hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_READ, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ.\n", hr);
if (SUCCEEDED(hr))
ID3D10Texture2D_Unmap(texture, 0);
expected_hr = !dynamic && cpu_write ? S_OK : E_INVALIDARG;
hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_WRITE, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE.\n", hr);
if (SUCCEEDED(hr))
ID3D10Texture2D_Unmap(texture, 0);
expected_hr = cpu_read && cpu_write ? S_OK : E_INVALIDARG;
hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_READ_WRITE, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ_WRITE.\n", hr);
if (SUCCEEDED(hr))
ID3D10Texture2D_Unmap(texture, 0);
expected_hr = dynamic ? S_OK : E_INVALIDARG;
hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_WRITE_DISCARD, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE_DISCARD.\n", hr);
if (SUCCEEDED(hr))
ID3D10Texture2D_Unmap(texture, 0);
diff --git a/dlls/d3d11/buffer.c b/dlls/d3d11/buffer.c
index ba49d6d..09778e2 100644
--- a/dlls/d3d11/buffer.c
+++ b/dlls/d3d11/buffer.c
@@ -452,9 +452,7 @@ static HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *dev
wined3d_desc.byte_width = buffer->desc.ByteWidth;
wined3d_desc.usage = wined3d_usage_from_d3d11(0, buffer->desc.Usage);
wined3d_desc.bind_flags = buffer->desc.BindFlags;
- if (~buffer->desc.CPUAccessFlags & (D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ))
- FIXME("Ignoring CPU access flags %#x.\n", buffer->desc.CPUAccessFlags);
- wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
+ wined3d_desc.access = wined3d_access_from_d3d11(buffer->desc.Usage, buffer->desc.CPUAccessFlags);
wined3d_desc.misc_flags = buffer->desc.MiscFlags;
wined3d_desc.structure_byte_stride = buffer->desc.StructureByteStride;
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index 52496d8..f9cfd6c 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -74,6 +74,7 @@ struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *re
struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN;
DWORD wined3d_map_flags_from_d3d11_map_type(D3D11_MAP map_type) DECLSPEC_HIDDEN;
DWORD wined3d_clear_flags_from_d3d11_clear_flags(UINT clear_flags) DECLSPEC_HIDDEN;
+unsigned int wined3d_access_from_d3d11(D3D11_USAGE usage, UINT cpu_access) DECLSPEC_HIDDEN;
enum D3D11_USAGE d3d11_usage_from_d3d10_usage(enum D3D10_USAGE usage) DECLSPEC_HIDDEN;
enum D3D10_USAGE d3d10_usage_from_d3d11_usage(enum D3D11_USAGE usage) DECLSPEC_HIDDEN;
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 6267eaf..af8fc7b 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -11029,7 +11029,7 @@ static void check_resource_cpu_access_(unsigned int line, ID3D11DeviceContext *c
expected_hr = cpu_read ? S_OK : E_INVALIDARG;
hr = ID3D11DeviceContext_Map(context, resource, 0, D3D11_MAP_READ, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ.\n", hr);
if (SUCCEEDED(hr))
ID3D11DeviceContext_Unmap(context, resource, 0);
@@ -11037,21 +11037,21 @@ static void check_resource_cpu_access_(unsigned int line, ID3D11DeviceContext *c
/* WRITE_DISCARD and WRITE_NO_OVERWRITE are the only allowed options for dynamic resources. */
expected_hr = !dynamic && cpu_write ? S_OK : E_INVALIDARG;
hr = ID3D11DeviceContext_Map(context, resource, 0, D3D11_MAP_WRITE, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE.\n", hr);
if (SUCCEEDED(hr))
ID3D11DeviceContext_Unmap(context, resource, 0);
expected_hr = cpu_read && cpu_write ? S_OK : E_INVALIDARG;
hr = ID3D11DeviceContext_Map(context, resource, 0, D3D11_MAP_READ_WRITE, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ_WRITE.\n", hr);
if (SUCCEEDED(hr))
ID3D11DeviceContext_Unmap(context, resource, 0);
expected_hr = dynamic ? S_OK : E_INVALIDARG;
hr = ID3D11DeviceContext_Map(context, resource, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc);
- todo_wine_if(expected_hr != S_OK)
+ todo_wine_if(expected_hr != S_OK && cpu_access)
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE_DISCARD.\n", hr);
if (SUCCEEDED(hr))
ID3D11DeviceContext_Unmap(context, resource, 0);
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c
index 4315284..2bcbe96 100644
--- a/dlls/d3d11/texture.c
+++ b/dlls/d3d11/texture.c
@@ -517,7 +517,8 @@ HRESULT d3d_texture2d_create(struct d3d_device *device, const D3D11_TEXTURE2D_DE
wined3d_desc.multisample_type = desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3D_MULTISAMPLE_NONE;
wined3d_desc.multisample_quality = desc->SampleDesc.Quality;
wined3d_desc.usage = wined3d_usage_from_d3d11(desc->BindFlags, desc->Usage);
- wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP;
+ wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage,
+ desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags);
wined3d_desc.width = desc->Width;
wined3d_desc.height = desc->Height;
wined3d_desc.depth = 1;
@@ -974,9 +975,8 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi
wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
wined3d_desc.multisample_quality = 0;
wined3d_desc.usage = wined3d_usage_from_d3d11(desc->BindFlags, desc->Usage);
- wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
- if (desc->Usage == D3D11_USAGE_STAGING)
- wined3d_desc.access |= WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
+ wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage,
+ desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags);
wined3d_desc.width = desc->Width;
wined3d_desc.height = desc->Height;
wined3d_desc.depth = desc->Depth;
diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c
index b3894bb..3885078 100644
--- a/dlls/d3d11/utils.c
+++ b/dlls/d3d11/utils.c
@@ -791,6 +791,21 @@ DWORD wined3d_clear_flags_from_d3d11_clear_flags(UINT clear_flags)
return wined3d_clear_flags;
}
+unsigned int wined3d_access_from_d3d11(D3D11_USAGE usage, UINT cpu_access)
+{
+ unsigned int access;
+
+ access = usage == D3D11_USAGE_STAGING ? WINED3D_RESOURCE_ACCESS_CPU : WINED3D_RESOURCE_ACCESS_GPU;
+ if (cpu_access)
+ {
+ if (~cpu_access & (D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ))
+ FIXME("Ignoring CPU access flags %#x.\n", cpu_access);
+ access |= WINED3D_RESOURCE_ACCESS_MAP;
+ }
+
+ return access;
+}
+
HRESULT d3d_get_private_data(struct wined3d_private_store *store,
REFGUID guid, UINT *data_size, void *data)
{
diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c
index 2e14a59..e8ff74b 100644
--- a/dlls/d3d8/volume.c
+++ b/dlls/d3d8/volume.c
@@ -155,6 +155,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
locked_box->SlicePitch = map_desc.slice_pitch;
locked_box->pBits = map_desc.data;
+ if (hr == E_INVALIDARG)
+ return D3DERR_INVALIDCALL;
return hr;
}
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c
index 0fcc2a4..6c61b99 100644
--- a/dlls/d3d9/volume.c
+++ b/dlls/d3d9/volume.c
@@ -155,6 +155,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface,
locked_box->SlicePitch = map_desc.slice_pitch;
locked_box->pBits = map_desc.data;
+ if (hr == E_INVALIDARG)
+ return D3DERR_INVALIDCALL;
return hr;
}
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index ca6b2b6..ddc157b 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -346,7 +346,7 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i
if (!(resource->access & WINED3D_RESOURCE_ACCESS_MAP))
{
WARN("Resource is not mappable.\n");
- return WINED3DERR_INVALIDCALL;
+ return E_INVALIDARG;
}
flags = wined3d_resource_sanitise_map_flags(resource, flags);
--
2.1.4