Commit 032bac17 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Store the viewport in the wined3d_stateblock_state structure.

parent 88d017aa
...@@ -1926,10 +1926,7 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned ...@@ -1926,10 +1926,7 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned
} }
if (viewport_count) if (viewport_count)
memcpy(device->update_state->viewports, viewports, viewport_count * sizeof(*viewports)); device->update_stateblock_state->viewport = viewports[0];
else
memset(device->update_state->viewports, 0, sizeof(device->update_state->viewports));
device->update_state->viewport_count = viewport_count;
/* Handle recording of state blocks */ /* Handle recording of state blocks */
if (device->recording) if (device->recording)
...@@ -1939,6 +1936,12 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned ...@@ -1939,6 +1936,12 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned
return; 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); 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 ...@@ -4523,6 +4526,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device
state->viewports[0].max_z = 1.0f; state->viewports[0].max_z = 1.0f;
state->viewport_count = 1; state->viewport_count = 1;
wined3d_cs_emit_set_viewports(device->cs, 1, state->viewports); 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); SetRect(&state->scissor_rects[0], 0, 0, view->width, view->height);
state->scissor_rect_count = 1; state->scissor_rect_count = 1;
......
...@@ -830,19 +830,12 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) ...@@ -830,19 +830,12 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
stateblock->stateblock_state.material = state->material; stateblock->stateblock_state.material = state->material;
} }
assert(src_state->viewport_count <= 1);
if (stateblock->changed.viewport if (stateblock->changed.viewport
&& (src_state->viewport_count != stateblock->state.viewport_count && memcmp(&state->viewport, &stateblock->stateblock_state.viewport, sizeof(state->viewport)))
|| memcmp(src_state->viewports, stateblock->state.viewports,
src_state->viewport_count * sizeof(*stateblock->state.viewports))))
{ {
TRACE("Updating viewports.\n"); TRACE("Updating viewport.\n");
if ((stateblock->state.viewport_count = src_state->viewport_count)) stateblock->stateblock_state.viewport = state->viewport;
memcpy(stateblock->state.viewports, src_state->viewports, sizeof(src_state->viewports));
else
memset(stateblock->state.viewports, 0, sizeof(*stateblock->state.viewports));
} }
if (stateblock->changed.scissorRect if (stateblock->changed.scissorRect
...@@ -1134,7 +1127,11 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) ...@@ -1134,7 +1127,11 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
} }
if (stateblock->changed.viewport) 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) if (stateblock->changed.scissorRect)
wined3d_device_set_scissor_rects(device, stateblock->state.scissor_rect_count, wined3d_device_set_scissor_rects(device, stateblock->state.scissor_rect_count,
......
...@@ -2989,6 +2989,7 @@ struct wined3d_stateblock_state ...@@ -2989,6 +2989,7 @@ struct wined3d_stateblock_state
struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1]; struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES]; struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES];
struct wined3d_material material; struct wined3d_material material;
struct wined3d_viewport viewport;
}; };
struct wined3d_device struct wined3d_device
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment