d3d10: Allow setting 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-17 02:16:54 +03:00 committed by Alexandre Julliard
parent 5d4b1a85d4
commit 72a04f4b37
2 changed files with 42 additions and 21 deletions

View File

@ -5473,12 +5473,11 @@ float4 main(float4 color : COLOR) : SV_TARGET
ID3D10Device_RSGetViewports(device, &count, tmp_viewport); ID3D10Device_RSGetViewports(device, &count, tmp_viewport);
for (i = 0; i < D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ++i) for (i = 0; i < D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ++i)
{ {
todo_wine_if(!i) ok(!tmp_viewport[i].TopLeftX && !tmp_viewport[i].TopLeftY && !tmp_viewport[i].Width
ok(!tmp_viewport[i].TopLeftX && !tmp_viewport[i].TopLeftY && !tmp_viewport[i].Width && !tmp_viewport[i].Height && !tmp_viewport[i].MinDepth && !tmp_viewport[i].MaxDepth,
&& !tmp_viewport[i].Height && !tmp_viewport[i].MinDepth && !tmp_viewport[i].MaxDepth, "Got unexpected viewport {%d, %d, %u, %u, %.8e, %.8e} in slot %u.\n",
"Got unexpected viewport {%d, %d, %u, %u, %.8e, %.8e} in slot %u.\n", tmp_viewport[i].TopLeftX, tmp_viewport[i].TopLeftY, tmp_viewport[i].Width,
tmp_viewport[i].TopLeftX, tmp_viewport[i].TopLeftY, tmp_viewport[i].Width, tmp_viewport[i].Height, tmp_viewport[i].MinDepth, tmp_viewport[i].MaxDepth, i);
tmp_viewport[i].Height, tmp_viewport[i].MinDepth, tmp_viewport[i].MaxDepth, i);
} }
ID3D10Device_RSGetState(device, &tmp_rs_state); ID3D10Device_RSGetState(device, &tmp_rs_state);
ok(!tmp_rs_state, "Got unexpected rasterizer state %p.\n", tmp_rs_state); ok(!tmp_rs_state, "Got unexpected rasterizer state %p.\n", tmp_rs_state);
@ -16191,6 +16190,7 @@ static void test_multiple_viewports(void)
unsigned int draw_id; unsigned int draw_id;
unsigned int padding[3]; unsigned int padding[3];
} constant; } constant;
D3D10_VIEWPORT vp[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE + 1];
struct d3d10core_test_context test_context; struct d3d10core_test_context test_context;
D3D10_TEXTURE2D_DESC texture_desc; D3D10_TEXTURE2D_DESC texture_desc;
ID3D10RenderTargetView *rtv; ID3D10RenderTargetView *rtv;
@ -16277,7 +16277,7 @@ static void test_multiple_viewports(void)
{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},
}; };
static const float clear_color[] = {0.5f, 0.5f, 0.0f, 0.0f}; static const float clear_color[] = {0.5f, 0.5f, 0.0f, 0.0f};
D3D10_VIEWPORT vp[2]; unsigned int count, i;
RECT rect; RECT rect;
int width; int width;
@ -16340,7 +16340,6 @@ static void test_multiple_viewports(void)
SetRect(&rect, 0, 0, width - 1, texture_desc.Height - 1); SetRect(&rect, 0, 0, width - 1, texture_desc.Height - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[0], 1); check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[0], 1);
SetRect(&rect, width, 0, 2 * width - 1, texture_desc.Height - 1); SetRect(&rect, width, 0, 2 * width - 1, texture_desc.Height - 1);
todo_wine
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[1], 1); check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[1], 1);
/* One viewport. */ /* One viewport. */
@ -16360,9 +16359,30 @@ todo_wine
constant.draw_id = 3; constant.draw_id = 3;
ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0); ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0);
draw_quad(&test_context); draw_quad(&test_context);
todo_wine
check_texture_sub_resource_vec4(texture, 0, NULL, &expected_values[4], 1); check_texture_sub_resource_vec4(texture, 0, NULL, &expected_values[4], 1);
/* Viewport count exceeding maximum value. */
ID3D10Device_RSSetViewports(device, 1, vp);
vp[0].TopLeftX = 1.0f;
vp[0].TopLeftY = 0.0f;
vp[0].Width = width;
vp[0].Height = texture_desc.Height;
vp[0].MinDepth = 0.0f;
vp[0].MaxDepth = 1.0f;
for (i = 1; i < ARRAY_SIZE(vp); ++i)
{
vp[i] = vp[0];
}
ID3D10Device_RSSetViewports(device, ARRAY_SIZE(vp), vp);
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");
ID3D10RenderTargetView_Release(rtv); ID3D10RenderTargetView_Release(rtv);
ID3D10Texture2D_Release(texture); ID3D10Texture2D_Release(texture);

View File

@ -4150,25 +4150,26 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
UINT viewport_count, const D3D10_VIEWPORT *viewports) UINT viewport_count, const D3D10_VIEWPORT *viewports)
{ {
struct d3d_device *device = impl_from_ID3D10Device(iface); struct d3d_device *device = impl_from_ID3D10Device(iface);
struct wined3d_viewport wined3d_vp; struct wined3d_viewport wined3d_vp[WINED3D_MAX_VIEWPORTS];
unsigned int i;
TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports); TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
if (viewport_count > 1) if (viewport_count > ARRAY_SIZE(wined3d_vp))
FIXME("Multiple viewports not implemented.\n");
if (!viewport_count)
return; return;
wined3d_vp.x = viewports[0].TopLeftX; for (i = 0; i < viewport_count; ++i)
wined3d_vp.y = viewports[0].TopLeftY; {
wined3d_vp.width = viewports[0].Width; wined3d_vp[i].x = viewports[i].TopLeftX;
wined3d_vp.height = viewports[0].Height; wined3d_vp[i].y = viewports[i].TopLeftY;
wined3d_vp.min_z = viewports[0].MinDepth; wined3d_vp[i].width = viewports[i].Width;
wined3d_vp.max_z = viewports[0].MaxDepth; wined3d_vp[i].height = viewports[i].Height;
wined3d_vp[i].min_z = viewports[i].MinDepth;
wined3d_vp[i].max_z = viewports[i].MaxDepth;
}
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_set_viewports(device->wined3d_device, 1, &wined3d_vp); wined3d_device_set_viewports(device->wined3d_device, viewport_count, wined3d_vp);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }