d3d11: Add support for returning multiple viewports.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-04-18 12:50:46 +03:00 committed by Alexandre Julliard
parent b67870b7a7
commit be106e5d80
2 changed files with 29 additions and 21 deletions

View File

@ -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,

View File

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