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");