Module: wine Branch: master Commit: a8c44bd94c9e4ff7cbbe07eed071f4413227f31e URL: https://source.winehq.org/git/wine.git/?a=commit;h=a8c44bd94c9e4ff7cbbe07eed... Author: Matteo Bruni <mbruni(a)codeweavers.com> Date: Mon Mar 2 14:02:46 2020 +0100 wined3d: Introduce a global stateblock flag for transforms. Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/device.c | 15 +++++++++------ dlls/wined3d/stateblock.c | 26 ++++++++++++++++---------- dlls/wined3d/wined3d_private.h | 3 ++- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 639e94a624..99fbf21ada 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3977,14 +3977,17 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, } } - for (i = 0; i < ARRAY_SIZE(changed->transform); ++i) + if (changed->transforms) { - map = changed->transform[i]; - while (map) + for (i = 0; i < ARRAY_SIZE(changed->transform); ++i) { - j = wined3d_bit_scan(&map); - idx = i * word_bit_count + j; - wined3d_device_set_transform(device, idx, &state->transforms[idx]); + map = changed->transform[i]; + while (map) + { + j = wined3d_bit_scan(&map); + idx = i * word_bit_count + j; + wined3d_device_set_transform(device, idx, &state->transforms[idx]); + } } } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index c47a7323b1..6e3a473782 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -210,6 +210,7 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, states->scissorRect = 1; states->blend_state = 1; states->lights = 1; + states->transforms = 1; states->streamSource = 0xffff; states->streamFreq = 0xffff; @@ -807,14 +808,16 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, stateblock->stateblock_state.ps_consts_b[idx] = state->ps_consts_b[idx]; } - /* Others + Render & Texture */ - for (i = 0; i < stateblock->num_contained_transform_states; ++i) + if (stateblock->changed.transforms) { - enum wined3d_transform_state transform = stateblock->contained_transform_states[i]; + for (i = 0; i < stateblock->num_contained_transform_states; ++i) + { + enum wined3d_transform_state transform = stateblock->contained_transform_states[i]; - TRACE("Updating transform %#x.\n", transform); + TRACE("Updating transform %#x.\n", transform); - stateblock->stateblock_state.transforms[transform] = state->transforms[transform]; + stateblock->stateblock_state.transforms[transform] = state->transforms[transform]; + } } if (stateblock->changed.indices @@ -1177,13 +1180,15 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, wined3d_device_set_sampler_state(device, stage, sampler_state, value); } - /* Transform states. */ - for (i = 0; i < stateblock->num_contained_transform_states; ++i) + if (stateblock->changed.transforms) { - enum wined3d_transform_state transform = stateblock->contained_transform_states[i]; + for (i = 0; i < stateblock->num_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]); + state->transforms[transform] = stateblock->stateblock_state.transforms[transform]; + wined3d_device_set_transform(device, transform, &stateblock->stateblock_state.transforms[transform]); + } } if (stateblock->changed.indices) @@ -1579,6 +1584,7 @@ void CDECL wined3d_stateblock_set_transform(struct wined3d_stateblock *statebloc stateblock->stateblock_state.transforms[d3dts] = *matrix; stateblock->changed.transform[d3dts >> 5] |= 1u << (d3dts & 0x1f); + stateblock->changed.transforms = 1; } void CDECL wined3d_stateblock_multiply_transform(struct wined3d_stateblock *stateblock, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c658f5104c..f266d2a690 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3938,7 +3938,8 @@ struct wined3d_saved_states DWORD store_stream_offset : 1; DWORD blend_state : 1; DWORD lights : 1; - DWORD padding : 2; + DWORD transforms : 1; + DWORD padding : 1; }; struct StageState {