d3d11: Add support for setting multiple scissor rectangles.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Nikolay Sivov 2018-04-26 10:58:38 +03:00 committed by Alexandre Julliard
parent 85d1fb62b3
commit 857756fc68
2 changed files with 66 additions and 12 deletions

View File

@ -991,14 +991,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11De
TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
if (rect_count > 1)
FIXME("Multiple scissor rects not implemented.\n");
if (!rect_count)
if (rect_count > WINED3D_MAX_VIEWPORTS)
return;
wined3d_mutex_lock();
wined3d_device_set_scissor_rects(device->wined3d_device, 1, rects);
wined3d_device_set_scissor_rects(device->wined3d_device, rect_count, rects);
wined3d_mutex_unlock();
}
@ -4185,14 +4182,11 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *ifac
TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
if (rect_count > 1)
FIXME("Multiple scissor rects not implemented.\n");
if (!rect_count)
if (rect_count > WINED3D_MAX_VIEWPORTS)
return;
wined3d_mutex_lock();
wined3d_device_set_scissor_rects(device->wined3d_device, 1, rects);
wined3d_device_set_scissor_rects(device->wined3d_device, rect_count, rects);
wined3d_mutex_unlock();
}

View File

@ -10563,7 +10563,6 @@ static void test_clear_state(void)
ID3D11DeviceContext_RSGetScissorRects(context, &count, tmp_rect);
for (i = 0; i < D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ++i)
{
todo_wine_if(!i)
ok(!tmp_rect[i].left && !tmp_rect[i].top && !tmp_rect[i].right && !tmp_rect[i].bottom,
"Got unexpected scissor rect %s in slot %u.\n",
wine_dbgstr_rect(&tmp_rect[i]), i);
@ -26130,10 +26129,14 @@ static void test_multiple_viewports(void)
};
static const struct vec4 expected_values[] =
{
{0.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 2.0f}, {0.5f, 0.5f}, {0.5f, 0.5f},
{0.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 2.0f}, {0.5f, 0.5f}, {0.5f, 0.5f}, {0.0f, 4.0f}, {0.5f, 0.5f}, {0.5f, 0.5f},
{0.0f, 5.0f}, {0.5f, 0.5f}, {1.0f, 5.0f}, {0.5f, 0.5f},
};
static const float clear_color[] = {0.5f, 0.5f, 0.0f, 0.0f};
ID3D11RasterizerState *rasterizer_state;
D3D11_RASTERIZER_DESC rasterizer_desc;
unsigned int count, i;
D3D11_RECT rects[2];
RECT rect;
int width;
@ -26222,6 +26225,63 @@ static void test_multiple_viewports(void)
draw_quad(&test_context);
check_texture_sub_resource_vec4(texture, 0, NULL, &expected_values[4], 1);
/* Two viewports, only first scissor rectangle set. */
memset(&rasterizer_desc, 0, sizeof(rasterizer_desc));
rasterizer_desc.FillMode = D3D11_FILL_SOLID;
rasterizer_desc.CullMode = D3D11_CULL_BACK;
rasterizer_desc.DepthClipEnable = TRUE;
rasterizer_desc.ScissorEnable = TRUE;
hr = ID3D11Device_CreateRasterizerState(device, &rasterizer_desc, &rasterizer_state);
ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
ID3D11DeviceContext_RSSetState(context, rasterizer_state);
ID3D11RasterizerState_Release(rasterizer_state);
ID3D11DeviceContext_ClearRenderTargetView(context, rtv, clear_color);
ID3D11DeviceContext_RSSetViewports(context, 2, vp);
rects[0].left = 0;
rects[0].top = 0;
rects[0].right = width;
rects[0].bottom = texture_desc.Height / 2;
memset(&rects[1], 0, sizeof(*rects));
ID3D11DeviceContext_RSSetScissorRects(context, 1, rects);
constant.draw_id = 4;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0);
draw_quad(&test_context);
SetRect(&rect, 0, 0, width - 1, texture_desc.Height / 2 - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[5], 1);
SetRect(&rect, 0, texture_desc.Height / 2, width - 1, texture_desc.Height - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[6], 1);
SetRect(&rect, width, 0, 2 * width - 1, texture_desc.Height - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[7], 1);
/* Set both rectangles. */
rects[0].left = 0;
rects[0].top = 0;
rects[0].right = width;
rects[0].bottom = texture_desc.Height / 2;
rects[1].left = width;
rects[1].top = 0;
rects[1].right = width * 2;
rects[1].bottom = texture_desc.Height / 2;
ID3D11DeviceContext_ClearRenderTargetView(context, rtv, clear_color);
ID3D11DeviceContext_RSSetScissorRects(context, 2, rects);
constant.draw_id = 5;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0);
draw_quad(&test_context);
SetRect(&rect, 0, 0, width - 1, texture_desc.Height / 2 - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[8], 1);
SetRect(&rect, 0, texture_desc.Height / 2, width - 1, texture_desc.Height - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[9], 1);
SetRect(&rect, width, 0, 2 * width - 1, texture_desc.Height / 2 - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[10], 1);
SetRect(&rect, width, texture_desc.Height / 2, 2 * width - 1, texture_desc.Height - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[11], 1);
/* Viewport count exceeding maximum value. */
ID3D11DeviceContext_RSSetViewports(context, 1, vp);