Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 12 ++++++++---- dlls/wined3d/stateblock.c | 21 +++++++++------------ dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 6472697d08..c2f2d462be 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1926,10 +1926,7 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned }
if (viewport_count) - memcpy(device->update_state->viewports, viewports, viewport_count * sizeof(*viewports)); - else - memset(device->update_state->viewports, 0, sizeof(device->update_state->viewports)); - device->update_state->viewport_count = viewport_count; + device->update_stateblock_state->viewport = viewports[0];
/* Handle recording of state blocks */ if (device->recording) @@ -1939,6 +1936,12 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned return; }
+ if (viewport_count) + memcpy(device->state.viewports, viewports, viewport_count * sizeof(*viewports)); + else + memset(device->state.viewports, 0, sizeof(device->state.viewports)); + device->state.viewport_count = viewport_count; + wined3d_cs_emit_set_viewports(device->cs, viewport_count, viewports); }
@@ -4523,6 +4526,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device state->viewports[0].max_z = 1.0f; state->viewport_count = 1; wined3d_cs_emit_set_viewports(device->cs, 1, state->viewports); + device->stateblock_state.viewport = state->viewports[0];
SetRect(&state->scissor_rects[0], 0, 0, view->width, view->height); state->scissor_rect_count = 1; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 75f2883197..4a0b0466e7 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -830,19 +830,12 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) stateblock->stateblock_state.material = state->material; }
- assert(src_state->viewport_count <= 1); - - if (stateblock->changed.viewport - && (src_state->viewport_count != stateblock->state.viewport_count - || memcmp(src_state->viewports, stateblock->state.viewports, - src_state->viewport_count * sizeof(*stateblock->state.viewports)))) + if (stateblock->changed.viewport && + memcmp(&state->viewport, &stateblock->stateblock_state.viewport, sizeof(state->viewport))) { - TRACE("Updating viewports.\n"); + TRACE("Updating viewport.\n");
- if ((stateblock->state.viewport_count = src_state->viewport_count)) - memcpy(stateblock->state.viewports, src_state->viewports, sizeof(src_state->viewports)); - else - memset(stateblock->state.viewports, 0, sizeof(*stateblock->state.viewports)); + stateblock->stateblock_state.viewport = state->viewport; }
if (stateblock->changed.scissorRect @@ -1134,7 +1127,11 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) }
if (stateblock->changed.viewport) - wined3d_device_set_viewports(device, stateblock->state.viewport_count, stateblock->state.viewports); + { + state->viewport = stateblock->stateblock_state.viewport; + + wined3d_device_set_viewports(device, 1, &stateblock->stateblock_state.viewport); + }
if (stateblock->changed.scissorRect) wined3d_device_set_scissor_rects(device, stateblock->state.scissor_rect_count, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d4cbeaa194..52c15af1b9 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2989,6 +2989,7 @@ struct wined3d_stateblock_state struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1]; struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES]; struct wined3d_material material; + struct wined3d_viewport viewport; };
struct wined3d_device