Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 2 +- dlls/wined3d/stateblock.c | 19 ++++++++++++++++--- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 72e328f630..f23e76f37e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1495,11 +1495,11 @@ void CDECL wined3d_device_set_transform(struct wined3d_device *device, TRACE("%.8e %.8e %.8e %.8e\n", matrix->_41, matrix->_42, matrix->_43, matrix->_44);
/* Handle recording of state blocks. */ + device->update_stateblock_state->transforms[d3dts] = *matrix; if (device->recording) { TRACE("Recording... not performing anything.\n"); device->recording->changed.transform[d3dts >> 5] |= 1u << (d3dts & 0x1f); - device->update_state->transforms[d3dts] = *matrix; return; }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index e6e68b428b..04a15dfbc1 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -787,7 +787,7 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
TRACE("Updating transform %#x.\n", transform);
- stateblock->state.transforms[transform] = src_state->transforms[transform]; + stateblock->stateblock_state.transforms[transform] = state->transforms[transform]; }
if (stateblock->changed.indices @@ -1110,8 +1110,10 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) /* Transform states. */ for (i = 0; i < stateblock->num_contained_transform_states; ++i) { - wined3d_device_set_transform(device, stateblock->contained_transform_states[i], - &stateblock->state.transforms[stateblock->contained_transform_states[i]]); + enum wined3d_transform_state transform = stateblock->contained_transform_states[i]; + + state->transforms[transform] = stateblock->stateblock_state.transforms[transform]; + wined3d_device_set_transform(device, transform, &stateblock->stateblock_state.transforms[transform]); }
if (stateblock->changed.indices) @@ -1424,12 +1426,23 @@ void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb, static void stateblock_state_init_default(struct wined3d_stateblock_state *state, const struct wined3d_d3d_info *d3d_info) { + struct wined3d_matrix identity; unsigned int i;
+ get_identity_matrix(&identity); + + state->transforms[WINED3D_TS_PROJECTION] = identity; + state->transforms[WINED3D_TS_VIEW] = identity; + for (i = 0; i < 256; ++i) + { + state->transforms[WINED3D_TS_WORLD_MATRIX(i)] = identity; + } + init_default_render_states(state->rs, d3d_info);
for (i = 0; i < MAX_TEXTURES; ++i) { + state->transforms[WINED3D_TS_TEXTURE0 + i] = identity; init_default_texture_state(i, state->texture_states[i]); }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 1a461c0dec..ee69549114 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2985,6 +2985,8 @@ struct wined3d_stateblock_state struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS]; DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1]; + + struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1]; };
struct wined3d_device
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 12 ++++++++---- dlls/wined3d/stateblock.c | 7 ++++--- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index f23e76f37e..d7b5bbc000 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1768,19 +1768,23 @@ HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device, return WINED3DERR_INVALIDCALL; }
+ device->update_stateblock_state->clip_planes[plane_idx] = *plane; + if (device->recording) + { device->recording->changed.clipplane |= 1u << plane_idx; + return WINED3D_OK; + }
- if (!memcmp(&device->update_state->clip_planes[plane_idx], plane, sizeof(*plane))) + if (!memcmp(&device->state.clip_planes[plane_idx], plane, sizeof(*plane))) { TRACE("Application is setting old values over, nothing to do.\n"); return WINED3D_OK; }
- device->update_state->clip_planes[plane_idx] = *plane; + device->state.clip_planes[plane_idx] = *plane;
- if (!device->recording) - wined3d_cs_emit_set_clip_plane(device->cs, plane_idx, plane); + wined3d_cs_emit_set_clip_plane(device->cs, plane_idx, plane);
return WINED3D_OK; } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 04a15dfbc1..e1c94aa7e5 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -915,10 +915,10 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) { if (!(map & 1)) continue;
- if (memcmp(&stateblock->state.clip_planes[i], &src_state->clip_planes[i], sizeof(src_state->clip_planes[i]))) + if (memcmp(&stateblock->stateblock_state.clip_planes[i], &state->clip_planes[i], sizeof(state->clip_planes[i]))) { TRACE("Updating clipplane %u.\n", i); - stateblock->state.clip_planes[i] = src_state->clip_planes[i]; + stateblock->stateblock_state.clip_planes[i] = state->clip_planes[i]; } }
@@ -1177,7 +1177,8 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) { if (!(map & 1)) continue;
- wined3d_device_set_clip_plane(device, i, &stateblock->state.clip_planes[i]); + state->clip_planes[i] = stateblock->stateblock_state.clip_planes[i]; + wined3d_device_set_clip_plane(device, i, &stateblock->stateblock_state.clip_planes[i]); }
TRACE("Applied stateblock %p.\n", stateblock); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ee69549114..647ef90e19 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2987,6 +2987,7 @@ struct wined3d_stateblock_state DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1]; + struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES]; };
struct wined3d_device
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 11 +++++++---- dlls/wined3d/stateblock.c | 10 +++++++--- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index d7b5bbc000..6472697d08 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1831,12 +1831,15 @@ void CDECL wined3d_device_set_material(struct wined3d_device *device, const stru { TRACE("device %p, material %p.\n", device, material);
- device->update_state->material = *material; - + device->update_stateblock_state->material = *material; if (device->recording) + { device->recording->changed.material = TRUE; - else - wined3d_cs_emit_set_material(device->cs, material); + return; + } + + device->state.material = *material; + wined3d_cs_emit_set_material(device->cs, material); }
void CDECL wined3d_device_get_material(const struct wined3d_device *device, struct wined3d_material *material) diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index e1c94aa7e5..dce04bd12f 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -822,11 +822,12 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) }
if (stateblock->changed.material - && memcmp(&src_state->material, &stateblock->state.material, sizeof(stateblock->state.material))) + && memcmp(&state->material, &stateblock->stateblock_state.material, + sizeof(stateblock->stateblock_state.material))) { TRACE("Updating material.\n");
- stateblock->state.material = src_state->material; + stateblock->stateblock_state.material = state->material; }
assert(src_state->viewport_count <= 1); @@ -1127,7 +1128,10 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) wined3d_device_set_vertex_declaration(device, stateblock->state.vertex_declaration);
if (stateblock->changed.material) - wined3d_device_set_material(device, &stateblock->state.material); + { + state->material = stateblock->stateblock_state.material; + wined3d_device_set_material(device, &stateblock->stateblock_state.material); + }
if (stateblock->changed.viewport) wined3d_device_set_viewports(device, stateblock->state.viewport_count, stateblock->state.viewports); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 647ef90e19..d4cbeaa194 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2988,6 +2988,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_device
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
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 dce04bd12f..8de12b2134 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
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 23 ++++++++++++----------- dlls/wined3d/stateblock.c | 19 ++++++++----------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c2f2d462be..29808fdf07 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2148,27 +2148,27 @@ void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsig TRACE("%u: %s\n", i, wine_dbgstr_rect(&rects[i])); }
+ if (rect_count) + device->update_stateblock_state->scissor_rect = rects[0]; + if (device->recording) + { device->recording->changed.scissorRect = TRUE; + return; + }
- if (device->update_state->scissor_rect_count == rect_count - && !memcmp(device->update_state->scissor_rects, rects, rect_count * sizeof(*rects))) + if (device->state.scissor_rect_count == rect_count + && !memcmp(device->state.scissor_rects, rects, rect_count * sizeof(*rects))) { TRACE("App is setting the old scissor rectangles over, nothing to do.\n"); return; }
if (rect_count) - memcpy(device->update_state->scissor_rects, rects, rect_count * sizeof(*rects)); + memcpy(device->state.scissor_rects, rects, rect_count * sizeof(*rects)); else - memset(device->update_state->scissor_rects, 0, sizeof(device->update_state->scissor_rects)); - device->update_state->scissor_rect_count = rect_count; - - if (device->recording) - { - TRACE("Recording... not performing anything.\n"); - return; - } + memset(device->state.scissor_rects, 0, sizeof(device->state.scissor_rects)); + device->state.scissor_rect_count = rect_count;
wined3d_cs_emit_set_scissor_rects(device->cs, rect_count, rects); } @@ -4531,6 +4531,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device SetRect(&state->scissor_rects[0], 0, 0, view->width, view->height); state->scissor_rect_count = 1; wined3d_cs_emit_set_scissor_rects(device->cs, 1, state->scissor_rects); + device->stateblock_state.scissor_rect = state->scissor_rects[0]; }
prev = device->fb.render_targets[view_idx]; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 8de12b2134..037357c975 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -839,17 +839,11 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) }
if (stateblock->changed.scissorRect - && (src_state->scissor_rect_count != stateblock->state.scissor_rect_count - || memcmp(src_state->scissor_rects, stateblock->state.scissor_rects, - src_state->scissor_rect_count * sizeof(*stateblock->state.scissor_rects)))) + && memcmp(&state->scissor_rect, &stateblock->stateblock_state.scissor_rect, sizeof(state->scissor_rect))) { - TRACE("Updating scissor rects.\n"); + TRACE("Updating scissor rect.\n");
- if ((stateblock->state.scissor_rect_count = src_state->scissor_rect_count)) - memcpy(stateblock->state.scissor_rects, src_state->scissor_rects, - src_state->scissor_rect_count * sizeof(*src_state->scissor_rects)); - else - SetRectEmpty(stateblock->state.scissor_rects); + stateblock->stateblock_state.scissor_rect = state->scissor_rect; }
if (stateblock->changed.blend_state @@ -1134,8 +1128,11 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) }
if (stateblock->changed.scissorRect) - wined3d_device_set_scissor_rects(device, stateblock->state.scissor_rect_count, - stateblock->state.scissor_rects); + { + state->scissor_rect = stateblock->stateblock_state.scissor_rect; + + wined3d_device_set_scissor_rects(device, 1, &stateblock->stateblock_state.scissor_rect); + }
if (stateblock->changed.blend_state) wined3d_device_set_blend_state(device, stateblock->state.blend_state, &stateblock->state.blend_factor); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 52c15af1b9..f8f7c47e6e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2990,6 +2990,7 @@ struct wined3d_stateblock_state struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES]; struct wined3d_material material; struct wined3d_viewport viewport; + RECT scissor_rect; };
struct wined3d_device