From ebc96e32bdb721f549cf7d704c19b0d762d3f147 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Fri, 28 Feb 2020 11:24:59 +0100 Subject: [PATCH] wined3d: Optimize scanning changed texture states in wined3d_device_apply_stateblock(). Signed-off-by: Matteo Bruni Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/device.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e706c830d31..9478c459e0a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3951,12 +3951,13 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, } } - for (i = 0; i < ARRAY_SIZE(state->texture_states); ++i) + for (i = 0; i < ARRAY_SIZE(changed->textureState); ++i) { - for (j = 0; j < ARRAY_SIZE(state->texture_states[i]); ++j) + map = changed->textureState[i]; + while (map) { - if (changed->textureState[i] & (1u << j)) - wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]); + j = wined3d_bit_scan(&map); + wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]); } }