Commit 4ecf938d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d11: Do not return uninitialized values on Map() failure.

parent d95780ba
......@@ -799,18 +799,21 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_context_Map(ID3D11DeviceContext1 *
if (map_flags)
FIXME("Ignoring map_flags %#x.\n", map_flags);
mapped_subresource->pData = NULL;
if (context->type != D3D11_DEVICE_CONTEXT_IMMEDIATE
&& map_type != D3D11_MAP_WRITE_DISCARD && map_type != D3D11_MAP_WRITE_NO_OVERWRITE)
return E_INVALIDARG;
wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
hr = wined3d_device_context_map(context->wined3d_context, wined3d_resource, subresource_idx,
&map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type));
mapped_subresource->pData = map_desc.data;
mapped_subresource->RowPitch = map_desc.row_pitch;
mapped_subresource->DepthPitch = map_desc.slice_pitch;
if (SUCCEEDED(hr = wined3d_device_context_map(context->wined3d_context, wined3d_resource, subresource_idx,
&map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type))))
{
mapped_subresource->pData = map_desc.data;
mapped_subresource->RowPitch = map_desc.row_pitch;
mapped_subresource->DepthPitch = map_desc.slice_pitch;
}
return hr;
}
......
......@@ -14934,8 +14934,14 @@ static void test_resource_map(void)
hr = ID3D11Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
mapped_subresource.pData = (void *)0xdeadbeef;
mapped_subresource.RowPitch = 0xabab;
mapped_subresource.DepthPitch = 0xcdcd;
hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)buffer, 1, D3D11_MAP_READ, 0, &mapped_subresource);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
ok(!mapped_subresource.pData, "Unexpected pointer %p.\n", mapped_subresource.pData);
ok(mapped_subresource.RowPitch == 0xabab, "Unexpected row pitch value %u.\n", mapped_subresource.RowPitch);
ok(mapped_subresource.DepthPitch == 0xcdcd, "Unexpected depth pitch value %u.\n", mapped_subresource.DepthPitch);
memset(&mapped_subresource, 0, sizeof(mapped_subresource));
hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE, 0, &mapped_subresource);
......@@ -14972,8 +14978,14 @@ static void test_resource_map(void)
hr = ID3D11Device_CreateTexture2D(device, &texture2d_desc, NULL, &texture2d);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
mapped_subresource.pData = (void *)0xdeadbeef;
mapped_subresource.RowPitch = 0xabab;
mapped_subresource.DepthPitch = 0xcdcd;
hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)texture2d, 1, D3D11_MAP_READ, 0, &mapped_subresource);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
ok(!mapped_subresource.pData, "Unexpected pointer %p.\n", mapped_subresource.pData);
ok(mapped_subresource.RowPitch == 0xabab, "Unexpected row pitch value %u.\n", mapped_subresource.RowPitch);
ok(mapped_subresource.DepthPitch == 0xcdcd, "Unexpected depth pitch value %u.\n", mapped_subresource.DepthPitch);
memset(&mapped_subresource, 0, sizeof(mapped_subresource));
hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)texture2d, 0, D3D11_MAP_WRITE, 0, &mapped_subresource);
......@@ -33285,8 +33297,14 @@ static void test_deferred_context_map(void)
hr = ID3D11Device_CreateBuffer(device, &buffer_desc, &resource_data, &buffer2);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
map_desc.pData = (void *)0xdeadbeef;
map_desc.RowPitch = 0xabab;
map_desc.DepthPitch = 0xcdcd;
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_READ, 0, &map_desc);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
ok(!map_desc.pData, "Unexpected pointer %p.\n", map_desc.pData);
ok(map_desc.RowPitch == 0xabab, "Unexpected row pitch value %u.\n", map_desc.RowPitch);
ok(map_desc.DepthPitch == 0xcdcd, "Unexpected depth pitch value %u.\n", map_desc.DepthPitch);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_READ_WRITE, 0, &map_desc);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment