[PATCH 2/2] d3d10: Allow setting multiple viewports
Nikolay Sivov
nsivov at codeweavers.com
Mon Apr 16 18:16:54 CDT 2018
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d3d10core/tests/device.c | 38 ++++++++++++++++++++++++++---------
dlls/d3d11/device.c | 25 ++++++++++++-----------
2 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 6982a4ed14..8e42776a08 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -5472,12 +5472,11 @@ float4 main(float4 color : COLOR) : SV_TARGET
ID3D10Device_RSGetViewports(device, &count, tmp_viewport);
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
- && !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",
- 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);
+ 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,
+ "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].Height, tmp_viewport[i].MinDepth, tmp_viewport[i].MaxDepth, i);
}
ID3D10Device_RSGetState(device, &tmp_rs_state);
ok(!tmp_rs_state, "Got unexpected rasterizer state %p.\n", tmp_rs_state);
@@ -16003,6 +16002,7 @@ static void test_multiple_viewports(void)
unsigned int draw_id;
unsigned int padding[3];
} constant;
+ D3D10_VIEWPORT vp[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE + 1];
struct d3d10core_test_context test_context;
D3D10_TEXTURE2D_DESC texture_desc;
ID3D10RenderTargetView *rtv;
@@ -16089,7 +16089,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},
};
static const float clear_color[] = {0.5f, 0.5f, 0.0f, 0.0f};
- D3D10_VIEWPORT vp[2];
+ unsigned int count, i;
RECT rect;
int width;
@@ -16152,7 +16152,6 @@ static void test_multiple_viewports(void)
SetRect(&rect, 0, 0, width - 1, texture_desc.Height - 1);
check_texture_sub_resource_vec4(texture, 0, &rect, &expected_values[0], 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);
/* One viewport. */
@@ -16172,9 +16171,30 @@ todo_wine
constant.draw_id = 3;
ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0);
draw_quad(&test_context);
-todo_wine
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);
ID3D10Texture2D_Release(texture);
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 9f1533b8df..248cac69f8 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -4150,25 +4150,26 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface,
UINT viewport_count, const D3D10_VIEWPORT *viewports)
{
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);
- if (viewport_count > 1)
- FIXME("Multiple viewports not implemented.\n");
-
- if (!viewport_count)
+ if (viewport_count > ARRAY_SIZE(wined3d_vp))
return;
- wined3d_vp.x = viewports[0].TopLeftX;
- wined3d_vp.y = viewports[0].TopLeftY;
- wined3d_vp.width = viewports[0].Width;
- wined3d_vp.height = viewports[0].Height;
- wined3d_vp.min_z = viewports[0].MinDepth;
- wined3d_vp.max_z = viewports[0].MaxDepth;
+ for (i = 0; i < viewport_count; ++i)
+ {
+ wined3d_vp[i].x = viewports[i].TopLeftX;
+ wined3d_vp[i].y = viewports[i].TopLeftY;
+ wined3d_vp[i].width = viewports[i].Width;
+ 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_device_set_viewports(device->wined3d_device, 1, &wined3d_vp);
+ wined3d_device_set_viewports(device->wined3d_device, viewport_count, wined3d_vp);
wined3d_mutex_unlock();
}
--
2.17.0
More information about the wine-devel
mailing list