Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10core/tests/device.c | 79 ++++++++++++++++++++++++++++++++--- dlls/d3d11/device.c | 14 ++----- dlls/d3d11/tests/d3d11.c | 73 +++++++++++++++++++++++++++++++- 3 files changed, 149 insertions(+), 17 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 26218bf8e0..7e79d06c7f 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -5461,10 +5461,9 @@ float4 main(float4 color : COLOR) : SV_TARGET ID3D10Device_RSGetScissorRects(device, &count, tmp_rect); for (i = 0; i < D3D10_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); + 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); } ID3D10Device_RSGetViewports(device, &count, NULL); ok(!count, "Got unexpected viewport count %u.\n", count); @@ -16274,10 +16273,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.5f, 0.5f}, {0.0f, 6.0f}, {0.5f, 0.5f}, {1.0f, 6.0f}, {0.5f, 0.5f}, }; static const float clear_color[] = {0.5f, 0.5f, 0.0f, 0.0f}; + ID3D10RasterizerState *rasterizer_state; + D3D10_RASTERIZER_DESC rasterizer_desc; unsigned int count, i; + D3D10_RECT rects[2]; RECT rect; int width;
@@ -16365,6 +16368,71 @@ static void test_multiple_viewports(void) draw_quad(&test_context); check_texture_sub_resource_vec4(texture, 0, NULL, &expected_values[4], 1);
+ /* Two viewports, empty second scissor rectangle. */ + memset(&rasterizer_desc, 0, sizeof(rasterizer_desc)); + rasterizer_desc.FillMode = D3D10_FILL_SOLID; + rasterizer_desc.CullMode = D3D10_CULL_BACK; + rasterizer_desc.DepthClipEnable = TRUE; + rasterizer_desc.ScissorEnable = TRUE; + hr = ID3D10Device_CreateRasterizerState(device, &rasterizer_desc, &rasterizer_state); + ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr); + + ID3D10Device_RSSetState(device, rasterizer_state); + + ID3D10Device_ClearRenderTargetView(device, rtv, clear_color); + ID3D10Device_RSSetViewports(device, 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)); + ID3D10Device_RSSetScissorRects(device, 1, rects); + constant.draw_id = 4; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)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 scissor count to zero. */ + ID3D10Device_ClearRenderTargetView(device, rtv, clear_color); + ID3D10Device_RSSetScissorRects(device, 0, rects); + constant.draw_id = 5; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + SetRect(&rect, 0, 0, texture_desc.Width - 1, texture_desc.Height - 1); + check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[8], 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; + ID3D10Device_ClearRenderTargetView(device, rtv, clear_color); + ID3D10Device_RSSetScissorRects(device, 2, rects); + constant.draw_id = 6; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)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[9], 1); + SetRect(&rect, 0, texture_desc.Height / 2, width - 1, texture_desc.Height - 1); + check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[10], 1); + + SetRect(&rect, width, 0, 2 * width - 1, texture_desc.Height / 2 - 1); + check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[11], 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[12], 1); + /* Viewport count exceeding maximum value. */ ID3D10Device_RSSetViewports(device, 1, vp);
@@ -16386,6 +16454,7 @@ static void test_multiple_viewports(void) ok(count == 1, "Unexpected viewport count %d.\n", count); ok(vp[0].TopLeftX == 0.0f && vp[0].Width == width, "Unexpected viewport.\n");
+ ID3D10RasterizerState_Release(rasterizer_state); ID3D10RenderTargetView_Release(rtv); ID3D10Texture2D_Release(texture);
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index a8251aad27..c6a7218fb7 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -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(); }
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index e59145292e..96521016c2 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -10566,7 +10566,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); @@ -26011,10 +26010,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.5f, 0.5f}, {0.0f, 6.0f}, {0.5f, 0.5f}, {1.0f, 6.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;
@@ -26103,6 +26106,72 @@ 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 scissor count to zero. */ + ID3D11DeviceContext_ClearRenderTargetView(context, rtv, clear_color); + ID3D11DeviceContext_RSSetScissorRects(context, 0, rects); + constant.draw_id = 5; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + SetRect(&rect, 0, 0, texture_desc.Width - 1, texture_desc.Height - 1); + check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[8], 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 = 6; + 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[9], 1); + SetRect(&rect, 0, texture_desc.Height / 2, width - 1, texture_desc.Height - 1); + check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[10], 1); + + SetRect(&rect, width, 0, 2 * width - 1, texture_desc.Height / 2 - 1); + check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[11], 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[12], 1); + /* Viewport count exceeding maximum value. */ ID3D11DeviceContext_RSSetViewports(context, 1, vp);