Signed-off-by: Pablo Martin pmart-wine@riseup.net --- Prepares wined3d_device_copy_sub_resource_region so the flags parameter can be sent from CopySubresourceRegion1 in the next patch.
After this series is done and I'm sure about the way we want to do this, I will prepare a similar one for adding flags to wined3d_device_update_sub_resource for UpdateSubresource1.
Some remarks: - touches on d3d11, d3d9, ddraw modules, but I set 'wined3d:' in the subject since the patch is about one modification in wined3d that needs small adaptations in other places. Please let me know if this is not the best way. - I named the parameter in wined3d_device_update_sub_resource 'flags', but it might be better to call it 'copy_flags'.
Tested on Ubuntu 17.10.
dlls/d3d11/device.c | 4 ++-- dlls/d3d9/device.c | 2 +- dlls/ddraw/executebuffer.c | 2 +- dlls/wined3d/device.c | 9 ++++++--- dlls/wined3d/wined3d.spec | 2 +- include/wine/wined3d.h | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index c930248e54..495ddc139f 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -1021,7 +1021,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); wined3d_mutex_lock(); wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, - dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL); + dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, 0); wined3d_mutex_unlock(); }
@@ -4514,7 +4514,7 @@ static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 * wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource); wined3d_mutex_lock(); wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, - dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL); + dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, 0); wined3d_mutex_unlock(); }
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index e3562c7c57..2f3ad2880d 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1536,7 +1536,7 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface, hr = wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_texture_get_resource(dst->wined3d_texture), dst->sub_resource_idx, dst_point ? dst_point->x : 0, dst_point ? dst_point->y : 0, 0, wined3d_texture_get_resource(src->wined3d_texture), - src->sub_resource_idx, &src_box); + src->sub_resource_idx, &src_box, 0); if (SUCCEEDED(hr) && dst->texture) d3d9_texture_flag_auto_gen_mipmap(dst->texture);
diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c index b20b9eda71..2ba29a7ed7 100644 --- a/dlls/ddraw/executebuffer.c +++ b/dlls/ddraw/executebuffer.c @@ -345,7 +345,7 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_buffer_get_resource(buffer->dst_vertex_buffer), 0, ci->wDest * sizeof(D3DTLVERTEX), 0, 0, - wined3d_buffer_get_resource(buffer->src_vertex_buffer), 0, &box); + wined3d_buffer_get_resource(buffer->src_vertex_buffer), 0, &box, 0); break;
default: diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c853b43440..97f9049379 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4154,14 +4154,17 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device, HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *device, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_resource *src_resource, - unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) + unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, unsigned int flags) { struct wined3d_box dst_box, b;
TRACE("device %p, dst_resource %p, dst_sub_resource_idx %u, dst_x %u, dst_y %u, dst_z %u, " - "src_resource %p, src_sub_resource_idx %u, src_box %s.\n", + "src_resource %p, src_sub_resource_idx %u, src_box %s, flags %#x.\n", device, dst_resource, dst_sub_resource_idx, dst_x, dst_y, dst_z, - src_resource, src_sub_resource_idx, debug_box(src_box)); + src_resource, src_sub_resource_idx, debug_box(src_box), flags); + + if (flags) + FIXME("Ignoring flags %#x.\n", flags);
if (src_resource == dst_resource && src_sub_resource_idx == dst_sub_resource_idx) { diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index bf29e206b5..7a8cf20381 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -40,7 +40,7 @@ @ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr long ptr float long) @ cdecl wined3d_device_clear_unordered_access_view_uint(ptr ptr ptr) @ cdecl wined3d_device_copy_resource(ptr ptr ptr) -@ cdecl wined3d_device_copy_sub_resource_region(ptr ptr long long long long ptr long ptr) +@ cdecl wined3d_device_copy_sub_resource_region(ptr ptr long long long long ptr long ptr long) @ cdecl wined3d_device_copy_uav_counter(ptr ptr long ptr) @ cdecl wined3d_device_create(ptr long long ptr long long ptr ptr) @ cdecl wined3d_device_decref(ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 15e14e5c5f..3393014baf 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2214,7 +2214,7 @@ void __cdecl wined3d_device_copy_resource(struct wined3d_device *device, HRESULT __cdecl wined3d_device_copy_sub_resource_region(struct wined3d_device *device, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_resource *src_resource, - unsigned int src_sub_resource_idx, const struct wined3d_box *src_box); + unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, unsigned int flags); void __cdecl wined3d_device_copy_uav_counter(struct wined3d_device *device, struct wined3d_buffer *dst_buffer, unsigned int offset, struct wined3d_unordered_access_view *uav); HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx,
Signed-off-by: Pablo Martin pmart-wine@riseup.net --- dlls/d3d11/device.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 495ddc139f..d2eb96e4bc 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2609,16 +2609,25 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion1(ID3 ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z, ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box, UINT flags) { + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource; + struct wined3d_box wined3d_src_box; + TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, " "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n", iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, src_resource, src_subresource_idx, src_box, flags);
- if (flags) - FIXME("Ignoring flags %#x.\n", flags); + if (src_box) + wined3d_box_set(&wined3d_src_box, src_box->left, src_box->top, + src_box->right, src_box->bottom, src_box->front, src_box->back);
- d3d11_immediate_context_CopySubresourceRegion(iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, - src_resource, src_subresource_idx, src_box); + wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource); + wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); + wined3d_mutex_lock(); + wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, + dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, flags); + wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource1(ID3D11DeviceContext1 *iface,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Pablo Martin pmart-wine@riseup.net --- This 3rd patch in the series is optional, it forwards the call as otherwise results in some duplicated code that can be avoided this way.
If you prefer to avoid the forwarding as hinted by Józef Kucia and keep direct calls from both CopySubresourceRegion methods you can just reject/ignore this patch.
Also note this way it does result in lots of similar traces (3) for d3d11_immediate_context_CopySubresourceRegion calls, and I believe at least the one in d3d11_immediate_context_CopySubresourceRegion could be safely removed, but I'm not sure about what other people would think so I have kept it.
dlls/d3d11/device.c | 48 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 30 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index d2eb96e4bc..4ab615a2ce 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -1000,18 +1000,18 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11De wined3d_mutex_unlock(); }
-static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext1 *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion1(ID3D11DeviceContext1 *iface, ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z, - ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box) + ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box, UINT flags) { struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource; struct wined3d_box wined3d_src_box;
TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, " - "src_resource %p, src_subresource_idx %u, src_box %p.\n", + "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n", iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, - src_resource, src_subresource_idx, src_box); + src_resource, src_subresource_idx, src_box, flags);
if (src_box) wined3d_box_set(&wined3d_src_box, src_box->left, src_box->top, @@ -1021,10 +1021,23 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); wined3d_mutex_lock(); wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, - dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, 0); + dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, flags); wined3d_mutex_unlock(); }
+static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext1 *iface, + ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z, + ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box) +{ + TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, " + "src_resource %p, src_subresource_idx %u, src_box %p.\n", + iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, + src_resource, src_subresource_idx, src_box); + + d3d11_immediate_context_CopySubresourceRegion1(iface, dst_resource, dst_subresource_idx, dst_x, dst_y, + dst_z, src_resource, src_subresource_idx, src_box, 0); +} + static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceContext1 *iface, ID3D11Resource *dst_resource, ID3D11Resource *src_resource) { @@ -2605,31 +2618,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D1 return E_NOTIMPL; }
-static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion1(ID3D11DeviceContext1 *iface, - ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z, - ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box, UINT flags) -{ - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); - struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource; - struct wined3d_box wined3d_src_box; - - TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, " - "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n", - iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, - src_resource, src_subresource_idx, src_box, flags); - - if (src_box) - wined3d_box_set(&wined3d_src_box, src_box->left, src_box->top, - src_box->right, src_box->bottom, src_box->front, src_box->back); - - wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource); - wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); - wined3d_mutex_lock(); - wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, - dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, flags); - wined3d_mutex_unlock(); -} - static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource1(ID3D11DeviceContext1 *iface, ID3D11Resource *resource, UINT subresource_idx, const D3D11_BOX *box, const void *data, UINT row_pitch, UINT depth_pitch, UINT flags)
On 18 May 2018 at 16:08, Pablo Martin pmart-wine@riseup.net wrote:
This 3rd patch in the series is optional, it forwards the call as otherwise results in some duplicated code that can be avoided this way.
If you prefer to avoid the forwarding as hinted by Józef Kucia and keep direct calls from both CopySubresourceRegion methods you can just reject/ignore this patch.
In this particular case, I think the amount of duplicated code is small enough for it to be worth calling the wined3d function directly.
For more complicated cases, what you'd typically do would be to introduce a third function, e.g. d3d_copy_sub_resource_region() that handles the shared code, and forward both to that.
On 18 May 2018 at 16:08, Pablo Martin pmart-wine@riseup.net wrote:
Some remarks:
- touches on d3d11, d3d9, ddraw modules, but I set 'wined3d:' in the subject since the patch is about one modification in wined3d that needs small adaptations in other places. Please let me know if this is not the best way.
- I named the parameter in wined3d_device_update_sub_resource 'flags', but it might be better to call it 'copy_flags'.
I think both of those points are fine.