From 9ab04c564e1a14348a4b81c2f61744821b65e61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 6 Feb 2018 11:40:04 +0100 Subject: [PATCH] wined3d: Use wined3d_bit_scan() in context_apply_compute_state(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/context.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 81a0f4fcd1b..ccfe630e1f2 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -3983,7 +3983,7 @@ void context_apply_compute_state(struct wined3d_context *context, { const struct StateEntry *state_table = context->state_table; const struct wined3d_gl_info *gl_info = context->gl_info; - unsigned int state_id, i, j; + unsigned int state_id, i; context_load_shader_resources(context, state, 1u << WINED3D_SHADER_TYPE_COMPUTE); context_load_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_COMPUTE], @@ -3991,11 +3991,13 @@ void context_apply_compute_state(struct wined3d_context *context, for (i = 0, state_id = STATE_COMPUTE_OFFSET; i < ARRAY_SIZE(context->dirty_compute_states); ++i) { - for (j = 0; j < sizeof(*context->dirty_compute_states) * CHAR_BIT; ++j, ++state_id) + unsigned int dirty_mask = context->dirty_compute_states[i]; + while (dirty_mask) { - if (context->dirty_compute_states[i] & (1u << j)) - state_table[state_id].apply(context, state, state_id); + unsigned int current_state_id = state_id + wined3d_bit_scan(&dirty_mask); + state_table[current_state_id].apply(context, state, current_state_id); } + state_id += sizeof(*context->dirty_compute_states) * CHAR_BIT; } memset(context->dirty_compute_states, 0, sizeof(*context->dirty_compute_states));