Commit 49b8e55b authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

mfplat: Only download surface data from GPU for DXGI buffers when reading.

parent 071eb50f
......@@ -905,7 +905,7 @@ static HRESULT dxgi_surface_buffer_create_readback_texture(struct buffer *buffer
return hr;
}
static HRESULT dxgi_surface_buffer_map(struct buffer *buffer)
static HRESULT dxgi_surface_buffer_map(struct buffer *buffer, MF2DBuffer_LockFlags flags)
{
ID3D11DeviceContext *immediate_context;
ID3D11Device *device;
......@@ -916,8 +916,12 @@ static HRESULT dxgi_surface_buffer_map(struct buffer *buffer)
ID3D11Texture2D_GetDevice(buffer->dxgi_surface.texture, &device);
ID3D11Device_GetImmediateContext(device, &immediate_context);
if (flags == MF2DBuffer_LockFlags_Read || flags == MF2DBuffer_LockFlags_ReadWrite)
{
ID3D11DeviceContext_CopySubresourceRegion(immediate_context, (ID3D11Resource *)buffer->dxgi_surface.rb_texture,
0, 0, 0, 0, (ID3D11Resource *)buffer->dxgi_surface.texture, buffer->dxgi_surface.sub_resource_idx, NULL);
}
memset(&buffer->dxgi_surface.map_desc, 0, sizeof(buffer->dxgi_surface.map_desc));
if (FAILED(hr = ID3D11DeviceContext_Map(immediate_context, (ID3D11Resource *)buffer->dxgi_surface.rb_texture,
......@@ -971,7 +975,7 @@ static HRESULT WINAPI dxgi_surface_buffer_Lock(IMFMediaBuffer *iface, BYTE **dat
if (SUCCEEDED(hr))
{
hr = dxgi_surface_buffer_map(buffer);
hr = dxgi_surface_buffer_map(buffer, MF2DBuffer_LockFlags_ReadWrite);
if (SUCCEEDED(hr))
{
copy_image(buffer, buffer->_2d.linear_buffer, buffer->_2d.width, buffer->dxgi_surface.map_desc.pData,
......@@ -1040,7 +1044,7 @@ static HRESULT dxgi_surface_buffer_lock(struct buffer *buffer, MF2DBuffer_LockFl
if (buffer->_2d.linear_buffer)
hr = MF_E_UNEXPECTED;
else if (!buffer->_2d.locks)
hr = dxgi_surface_buffer_map(buffer);
hr = dxgi_surface_buffer_map(buffer, flags);
else if (buffer->_2d.lock_flags == MF2DBuffer_LockFlags_Write && flags != MF2DBuffer_LockFlags_Write)
hr = HRESULT_FROM_WIN32(ERROR_WAS_LOCKED);
......
......@@ -7458,7 +7458,6 @@ static void test_d3d11_surface_buffer(void)
hr = IMF2DBuffer2_Lock2DSize(_2dbuffer2, MF2DBuffer_LockFlags_Write, &data, &pitch, &data2, &length);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(*(DWORD *)data != 0xefefefef, "Unexpected leading dword.\n");
memset(data, 0x89, 4);
IMF2DBuffer2_Unlock2D(_2dbuffer2);
......
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