Commit d073d3ea authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

mfplat: Only upload surface data to GPU for DXGI buffers when writing.

parent 49b8e55b
......@@ -936,7 +936,7 @@ static HRESULT dxgi_surface_buffer_map(struct buffer *buffer, MF2DBuffer_LockFla
return hr;
}
static void dxgi_surface_buffer_unmap(struct buffer *buffer)
static void dxgi_surface_buffer_unmap(struct buffer *buffer, MF2DBuffer_LockFlags flags)
{
ID3D11DeviceContext *immediate_context;
ID3D11Device *device;
......@@ -946,8 +946,11 @@ static void dxgi_surface_buffer_unmap(struct buffer *buffer)
ID3D11DeviceContext_Unmap(immediate_context, (ID3D11Resource *)buffer->dxgi_surface.rb_texture, 0);
memset(&buffer->dxgi_surface.map_desc, 0, sizeof(buffer->dxgi_surface.map_desc));
ID3D11DeviceContext_CopySubresourceRegion(immediate_context, (ID3D11Resource *)buffer->dxgi_surface.texture,
buffer->dxgi_surface.sub_resource_idx, 0, 0, 0, (ID3D11Resource *)buffer->dxgi_surface.rb_texture, 0, NULL);
if (flags == MF2DBuffer_LockFlags_Write || flags == MF2DBuffer_LockFlags_ReadWrite)
{
ID3D11DeviceContext_CopySubresourceRegion(immediate_context, (ID3D11Resource *)buffer->dxgi_surface.texture,
buffer->dxgi_surface.sub_resource_idx, 0, 0, 0, (ID3D11Resource *)buffer->dxgi_surface.rb_texture, 0, NULL);
}
ID3D11DeviceContext_Release(immediate_context);
ID3D11Device_Release(device);
......@@ -1014,7 +1017,7 @@ static HRESULT WINAPI dxgi_surface_buffer_Unlock(IMFMediaBuffer *iface)
{
copy_image(buffer, buffer->dxgi_surface.map_desc.pData, buffer->dxgi_surface.map_desc.RowPitch,
buffer->_2d.linear_buffer, buffer->_2d.width, buffer->_2d.width, buffer->_2d.height);
dxgi_surface_buffer_unmap(buffer);
dxgi_surface_buffer_unmap(buffer, MF2DBuffer_LockFlags_ReadWrite);
free(buffer->_2d.linear_buffer);
buffer->_2d.linear_buffer = NULL;
......@@ -1052,6 +1055,8 @@ static HRESULT dxgi_surface_buffer_lock(struct buffer *buffer, MF2DBuffer_LockFl
{
if (!buffer->_2d.locks)
buffer->_2d.lock_flags = flags;
else
buffer->_2d.lock_flags |= flags;
buffer->_2d.locks++;
*scanline0 = buffer->dxgi_surface.map_desc.pData;
*pitch = buffer->dxgi_surface.map_desc.RowPitch;
......@@ -1096,7 +1101,7 @@ static HRESULT WINAPI dxgi_surface_buffer_Unlock2D(IMF2DBuffer2 *iface)
{
if (!--buffer->_2d.locks)
{
dxgi_surface_buffer_unmap(buffer);
dxgi_surface_buffer_unmap(buffer, buffer->_2d.lock_flags);
buffer->_2d.lock_flags = 0;
}
}
......
......@@ -7452,7 +7452,6 @@ static void test_d3d11_surface_buffer(void)
IMF2DBuffer2_Unlock2D(_2dbuffer2);
color = get_d3d11_texture_color(texture, 0, 0);
todo_wine
ok(color == 0xcdcdcdcd, "Unexpected leading dword %#lx.\n", color);
put_d3d11_texture_color(texture, 0, 0, 0xefefefef);
......
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