Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/tests/d3d11.c | 42 +++++++++++++++++----------------------- dlls/wined3d/cs.c | 21 +++++++++++++++++++- 2 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index df1d5a35c6e..fcbe4f4a740 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -33134,38 +33134,32 @@ static void test_deferred_context_map(void) ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc); - todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- if (hr == S_OK) + map_data = map_desc.pData; + for (i = 0; i < ARRAY_SIZE(data); ++i) { - map_data = map_desc.pData; - for (i = 0; i < ARRAY_SIZE(data); ++i) - { - ok(map_data[i] == 2 * i, "Got unexpected value %.8e at %u.\n", map_data[i], i); - if (i % 2) - map_data[i] = 3 * i; - } - memcpy(data, map_data, sizeof(data)); - - ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0); + ok(map_data[i] == 2 * i, "Got unexpected value %.8e at %u.\n", map_data[i], i); + if (i % 2) + map_data[i] = 3 * i; } + memcpy(data, map_data, sizeof(data)); + + ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc); - todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- if (hr == S_OK) + map_data = map_desc.pData; + for (i = 0; i < ARRAY_SIZE(data); ++i) { - map_data = map_desc.pData; - for (i = 0; i < ARRAY_SIZE(data); ++i) - { - ok(map_data[i] == data[i], "Got unexpected value %.8e at %u.\n", map_data[i], i); - if (i % 3) - map_data[i] = 4 * i; - } - memcpy(data, map_data, sizeof(data)); - - ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0); + ok(map_data[i] == data[i], "Got unexpected value %.8e at %u.\n", map_data[i], i); + if (i % 3) + map_data[i] = 4 * i; } + memcpy(data, map_data, sizeof(data)); + + ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
hr = ID3D11DeviceContext_FinishCommandList(deferred, FALSE, &list); ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr); diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index c70606ad036..51fb4eefcd9 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -3452,12 +3452,31 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co return NULL; }
- if (flags & ~(WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD)) + if (flags & ~(WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) { FIXME("Unhandled flags %#x.\n", flags); return NULL; }
+ if (flags & WINED3D_MAP_NOOVERWRITE) + { + int i = deferred->upload_count; + + while (i--) + { + struct wined3d_deferred_upload *upload = &deferred->uploads[i]; + + if (upload->resource == resource && upload->sub_resource_idx == sub_resource_idx) + { + address->buffer_object = 0; + address->addr = upload->sysmem; + return upload->sysmem; + } + } + + return NULL; + } + if (!wined3d_array_reserve((void **)&deferred->uploads, &deferred->uploads_capacity, deferred->upload_count + 1, sizeof(*deferred->uploads))) return NULL;