Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d11/device.c | 4 ++-- dlls/d3d8/device.c | 2 +- dlls/d3d9/device.c | 2 +- dlls/ddraw/device.c | 2 +- dlls/wined3d/device.c | 15 +++++++++++---- dlls/wined3d/wined3d.spec | 2 +- include/wine/wined3d.h | 3 ++- 7 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 248cac69f8..0ee756dfa2 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2107,7 +2107,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11Devic return;
wined3d_mutex_lock(); - wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp); + wined3d_device_get_viewports(device->wined3d_device, NULL, &wined3d_vp); wined3d_mutex_unlock();
viewports[0].TopLeftX = wined3d_vp.x; @@ -4909,7 +4909,7 @@ static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface, return;
wined3d_mutex_lock(); - wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp); + wined3d_device_get_viewports(device->wined3d_device, NULL, &wined3d_vp); wined3d_mutex_unlock();
viewports[0].TopLeftX = wined3d_vp.x; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 3bdb278ec5..616886bcaf 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1664,7 +1664,7 @@ static HRESULT WINAPI d3d8_device_GetViewport(IDirect3DDevice8 *iface, D3DVIEWPO TRACE("iface %p, viewport %p.\n", iface, viewport);
wined3d_mutex_lock(); - wined3d_device_get_viewport(device->wined3d_device, &wined3d_viewport); + wined3d_device_get_viewports(device->wined3d_device, NULL, &wined3d_viewport); wined3d_mutex_unlock();
viewport->X = wined3d_viewport.x; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 5c0d6779c5..0a77b3e316 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2082,7 +2082,7 @@ static HRESULT WINAPI d3d9_device_GetViewport(IDirect3DDevice9Ex *iface, D3DVIEW TRACE("iface %p, viewport %p.\n", iface, viewport);
wined3d_mutex_lock(); - wined3d_device_get_viewport(device->wined3d_device, &wined3d_viewport); + wined3d_device_get_viewports(device->wined3d_device, NULL, &wined3d_viewport); wined3d_mutex_unlock();
viewport->X = wined3d_viewport.x; diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 23c61c5d80..5db0b81a81 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -5367,7 +5367,7 @@ static HRESULT d3d_device7_GetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *vi return DDERR_INVALIDPARAMS;
wined3d_mutex_lock(); - wined3d_device_get_viewport(device->wined3d_device, &wined3d_viewport); + wined3d_device_get_viewports(device->wined3d_device, NULL, &wined3d_viewport); wined3d_mutex_unlock();
viewport->dwX = wined3d_viewport.x; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 4ee948019b..8d4f4cde0e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1940,11 +1940,18 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned wined3d_cs_emit_set_viewports(device->cs, viewport_count, viewports); }
-void CDECL wined3d_device_get_viewport(const struct wined3d_device *device, struct wined3d_viewport *viewport) +void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, unsigned int *viewport_count, + struct wined3d_viewport *viewports) { - TRACE("device %p, viewport %p.\n", device, viewport); + unsigned int count;
- *viewport = device->state.viewports[0]; + TRACE("device %p, viewport_count %p, viewports %p.\n", device, viewport_count, viewports); + + count = viewport_count ? min(*viewport_count, device->state.viewport_count) : 1; + if (count && viewports) + memcpy(viewports, device->state.viewports, count * sizeof(*viewports)); + if (viewport_count) + *viewport_count = device->state.viewport_count; }
static void resolve_depth_buffer(struct wined3d_device *device) @@ -3139,7 +3146,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO TRACE("%.8e %.8e %.8e %.8e\n", world_mat._41, world_mat._42, world_mat._43, world_mat._44);
/* Get the viewport */ - wined3d_device_get_viewport(device, &vp); + wined3d_device_get_viewports(device, NULL, &vp); TRACE("viewport x %.8e, y %.8e, width %.8e, height %.8e, min_z %.8e, max_z %.8e.\n", vp.x, vp.y, vp.width, vp.height, vp.min_z, vp.max_z);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index b4c41cc59a..1b59178296 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -114,7 +114,7 @@ @ cdecl wined3d_device_get_unordered_access_view(ptr long) @ cdecl wined3d_device_get_vertex_declaration(ptr) @ cdecl wined3d_device_get_vertex_shader(ptr) -@ cdecl wined3d_device_get_viewport(ptr ptr) +@ cdecl wined3d_device_get_viewports(ptr ptr ptr) @ cdecl wined3d_device_get_vs_cb(ptr long) @ cdecl wined3d_device_get_vs_consts_b(ptr long long ptr) @ cdecl wined3d_device_get_vs_consts_f(ptr long long ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 3539b4eb06..ccda987405 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2324,7 +2324,8 @@ struct wined3d_unordered_access_view * __cdecl wined3d_device_get_unordered_acce const struct wined3d_device *device, unsigned int idx); struct wined3d_vertex_declaration * __cdecl wined3d_device_get_vertex_declaration(const struct wined3d_device *device); struct wined3d_shader * __cdecl wined3d_device_get_vertex_shader(const struct wined3d_device *device); -void __cdecl wined3d_device_get_viewport(const struct wined3d_device *device, struct wined3d_viewport *viewport); +void __cdecl wined3d_device_get_viewports(const struct wined3d_device *device, unsigned int *viewport_count, + struct wined3d_viewport *viewports); struct wined3d_buffer * __cdecl wined3d_device_get_vs_cb(const struct wined3d_device *device, UINT idx); HRESULT __cdecl wined3d_device_get_vs_consts_b(const struct wined3d_device *device, unsigned int start_idx, unsigned int count, BOOL *constants);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d11/device.c | 39 ++++++++++++++++++++++----------------- dlls/d3d11/tests/d3d11.c | 11 +++++++---- 2 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 0ee756dfa2..d47dfc9e9b 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2093,32 +2093,37 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11Devic UINT *viewport_count, D3D11_VIEWPORT *viewports) { struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - struct wined3d_viewport wined3d_vp; + struct wined3d_viewport wined3d_vp[WINED3D_MAX_VIEWPORTS]; + unsigned int actual_count = ARRAY_SIZE(wined3d_vp), i;
TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
- if (!viewports) - { - *viewport_count = 1; - return; - } - - if (!*viewport_count) + if (!viewport_count) return;
wined3d_mutex_lock(); - wined3d_device_get_viewports(device->wined3d_device, NULL, &wined3d_vp); + wined3d_device_get_viewports(device->wined3d_device, &actual_count, viewports ? wined3d_vp : NULL); wined3d_mutex_unlock();
- viewports[0].TopLeftX = wined3d_vp.x; - viewports[0].TopLeftY = wined3d_vp.y; - viewports[0].Width = wined3d_vp.width; - viewports[0].Height = wined3d_vp.height; - viewports[0].MinDepth = wined3d_vp.min_z; - viewports[0].MaxDepth = wined3d_vp.max_z; + if (!viewports) + { + *viewport_count = actual_count; + return; + }
- if (*viewport_count > 1) - memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports)); + if (*viewport_count > actual_count) + memset(&viewports[actual_count], 0, (*viewport_count - actual_count) * sizeof(*viewports)); + + *viewport_count = min(actual_count, *viewport_count); + for (i = 0; i < *viewport_count; ++i) + { + viewports[i].TopLeftX = wined3d_vp[i].x; + viewports[i].TopLeftY = wined3d_vp[i].y; + viewports[i].Width = wined3d_vp[i].width; + viewports[i].Height = wined3d_vp[i].height; + viewports[i].MinDepth = wined3d_vp[i].min_z; + viewports[i].MaxDepth = wined3d_vp[i].max_z; + } }
static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext *iface, diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index b917dcf728..e59145292e 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -9821,7 +9821,7 @@ static void test_clear_state(void) "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect[i]), i); } ID3D11DeviceContext_RSGetViewports(context, &count, NULL); - todo_wine ok(!count, "Got unexpected viewport count %u.\n", count); + ok(!count, "Got unexpected viewport count %u.\n", count); memset(tmp_viewport, 0x55, sizeof(tmp_viewport)); count = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ID3D11DeviceContext_RSGetViewports(context, &count, tmp_viewport); @@ -10353,7 +10353,7 @@ static void test_clear_state(void) "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect[i]), i); } ID3D11DeviceContext_RSGetViewports(context, &count, NULL); - todo_wine ok(count == D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE, + ok(count == D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE, "Got unexpected viewport count %u.\n", count); memset(tmp_viewport, 0x55, sizeof(tmp_viewport)); ID3D11DeviceContext_RSGetViewports(context, &count, tmp_viewport); @@ -10572,7 +10572,7 @@ static void test_clear_state(void) wine_dbgstr_rect(&tmp_rect[i]), i); } ID3D11DeviceContext_RSGetViewports(context, &count, NULL); - todo_wine ok(!count, "Got unexpected viewport count %u.\n", count); + ok(!count, "Got unexpected viewport count %u.\n", count); memset(tmp_viewport, 0x55, sizeof(tmp_viewport)); count = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ID3D11DeviceContext_RSGetViewports(context, &count, tmp_viewport); @@ -26068,6 +26068,10 @@ static void test_multiple_viewports(void) vp[1].Width = width; ID3D11DeviceContext_RSSetViewports(context, 2, vp);
+ count = ARRAY_SIZE(vp); + ID3D11DeviceContext_RSGetViewports(context, &count, vp); + ok(count == 2, "Unexpected viewport count %d.\n", count); + constant.draw_id = 0; ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0); draw_quad(&test_context); @@ -26117,7 +26121,6 @@ static void test_multiple_viewports(void) count = ARRAY_SIZE(vp); memset(vp, 0, sizeof(vp)); ID3D11DeviceContext_RSGetViewports(context, &count, vp); -todo_wine ok(count == 1, "Unexpected viewport count %d.\n", count); ok(vp[0].TopLeftX == 0.0f && vp[0].Width == width, "Unexpected viewport.\n");
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10core/tests/device.c | 11 ++++++---- dlls/d3d11/device.c | 39 ++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 140ffe6b3a..26218bf8e0 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -4934,7 +4934,7 @@ float4 main(float4 color : COLOR) : SV_TARGET "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect[i]), i); } ID3D10Device_RSGetViewports(device, &count, NULL); - todo_wine ok(!count, "Got unexpected viewport count %u.\n", count); + ok(!count, "Got unexpected viewport count %u.\n", count); memset(tmp_viewport, 0x55, sizeof(tmp_viewport)); count = D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ID3D10Device_RSGetViewports(device, &count, tmp_viewport); @@ -5329,7 +5329,7 @@ float4 main(float4 color : COLOR) : SV_TARGET "Got unexpected scissor rect %s in slot %u.\n", wine_dbgstr_rect(&tmp_rect[i]), i); } ID3D10Device_RSGetViewports(device, &count, NULL); - todo_wine ok(count == D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE, + ok(count == D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE, "Got unexpected viewport count %u.\n", count); memset(tmp_viewport, 0x55, sizeof(tmp_viewport)); ID3D10Device_RSGetViewports(device, &count, tmp_viewport); @@ -5467,7 +5467,7 @@ float4 main(float4 color : COLOR) : SV_TARGET wine_dbgstr_rect(&tmp_rect[i]), i); } ID3D10Device_RSGetViewports(device, &count, NULL); - todo_wine ok(!count, "Got unexpected viewport count %u.\n", count); + ok(!count, "Got unexpected viewport count %u.\n", count); memset(tmp_viewport, 0x55, sizeof(tmp_viewport)); count = D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ID3D10Device_RSGetViewports(device, &count, tmp_viewport); @@ -16330,6 +16330,10 @@ static void test_multiple_viewports(void) vp[1].Width = width; ID3D10Device_RSSetViewports(device, 2, vp);
+ count = ARRAY_SIZE(vp); + ID3D10Device_RSGetViewports(device, &count, vp); + ok(count == 2, "Unexpected viewport count %d.\n", count); + constant.draw_id = 0; ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0); draw_quad(&test_context); @@ -16379,7 +16383,6 @@ static void test_multiple_viewports(void) count = ARRAY_SIZE(vp); memset(vp, 0, sizeof(vp)); ID3D10Device_RSGetViewports(device, &count, vp); -todo_wine ok(count == 1, "Unexpected viewport count %d.\n", count); ok(vp[0].TopLeftX == 0.0f && vp[0].Width == width, "Unexpected viewport.\n");
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index d47dfc9e9b..7377952036 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -4900,32 +4900,37 @@ static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface, UINT *viewport_count, D3D10_VIEWPORT *viewports) { struct d3d_device *device = impl_from_ID3D10Device(iface); - struct wined3d_viewport wined3d_vp; + struct wined3d_viewport wined3d_vp[WINED3D_MAX_VIEWPORTS]; + unsigned int actual_count = ARRAY_SIZE(wined3d_vp), i;
TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports);
- if (!viewports) - { - *viewport_count = 1; - return; - } - - if (!*viewport_count) + if (!viewport_count) return;
wined3d_mutex_lock(); - wined3d_device_get_viewports(device->wined3d_device, NULL, &wined3d_vp); + wined3d_device_get_viewports(device->wined3d_device, &actual_count, viewports ? wined3d_vp : NULL); wined3d_mutex_unlock();
- viewports[0].TopLeftX = wined3d_vp.x; - viewports[0].TopLeftY = wined3d_vp.y; - viewports[0].Width = wined3d_vp.width; - viewports[0].Height = wined3d_vp.height; - viewports[0].MinDepth = wined3d_vp.min_z; - viewports[0].MaxDepth = wined3d_vp.max_z; + if (!viewports) + { + *viewport_count = actual_count; + return; + }
- if (*viewport_count > 1) - memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports)); + if (*viewport_count > actual_count) + memset(&viewports[actual_count], 0, (*viewport_count - actual_count) * sizeof(*viewports)); + + *viewport_count = min(actual_count, *viewport_count); + for (i = 0; i < *viewport_count; ++i) + { + viewports[i].TopLeftX = wined3d_vp[i].x; + viewports[i].TopLeftY = wined3d_vp[i].y; + viewports[i].Width = wined3d_vp[i].width; + viewports[i].Height = wined3d_vp[i].height; + viewports[i].MinDepth = wined3d_vp[i].min_z; + viewports[i].MaxDepth = wined3d_vp[i].max_z; + } }
static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com