wined3d: Optimize setting shader constants in wined3d_stateblock_capture().

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2020-03-02 14:02:48 +01:00 committed by Alexandre Julliard
parent ac142679ee
commit 7f2aee8570
1 changed files with 32 additions and 48 deletions

View File

@ -720,9 +720,9 @@ static void wined3d_state_record_lights(struct wined3d_light_state *dst_state,
void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
const struct wined3d_stateblock *device_state) const struct wined3d_stateblock *device_state)
{ {
const unsigned int word_bit_count = sizeof(*stateblock->changed.vs_consts_f) * CHAR_BIT;
const struct wined3d_stateblock_state *state = &device_state->stateblock_state; const struct wined3d_stateblock_state *state = &device_state->stateblock_state;
unsigned int i, j, idx; struct wined3d_range range;
unsigned int i, start;
DWORD map; DWORD map;
TRACE("stateblock %p, device_state %p.\n", stateblock, device_state); TRACE("stateblock %p, device_state %p.\n", stateblock, device_state);
@ -738,74 +738,58 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
stateblock->stateblock_state.vs = state->vs; stateblock->stateblock_state.vs = state->vs;
} }
for (i = 0; i < ARRAY_SIZE(stateblock->changed.vs_consts_f); ++i) for (start = 0; ; start = range.offset + range.size)
{ {
map = stateblock->changed.vs_consts_f[i]; if (!wined3d_bitmap_get_range(stateblock->changed.vs_consts_f, WINED3D_MAX_VS_CONSTS_F, start, &range))
break;
while (map) memcpy(&stateblock->stateblock_state.vs_consts_f[range.offset], &state->vs_consts_f[range.offset],
{ sizeof(*state->vs_consts_f) * range.size);
j = wined3d_bit_scan(&map);
idx = i * word_bit_count + j;
TRACE("Setting vs_consts_f[%u] to %s.\n", idx, debug_vec4(&state->vs_consts_f[idx]));
stateblock->stateblock_state.vs_consts_f[idx] = state->vs_consts_f[idx];
}
} }
map = stateblock->changed.vertexShaderConstantsI; map = stateblock->changed.vertexShaderConstantsI;
while (map) for (start = 0; ; start = range.offset + range.size)
{ {
idx = wined3d_bit_scan(&map); if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_I, start, &range))
break;
TRACE("Setting vs_consts_i[%u] to %s.\n", idx, debug_ivec4(&state->vs_consts_i[idx])); memcpy(&stateblock->stateblock_state.vs_consts_i[range.offset], &state->vs_consts_i[range.offset],
sizeof(*state->vs_consts_i) * range.size);
stateblock->stateblock_state.vs_consts_i[idx] = state->vs_consts_i[idx];
} }
map = stateblock->changed.vertexShaderConstantsB; map = stateblock->changed.vertexShaderConstantsB;
while (map) for (start = 0; ; start = range.offset + range.size)
{ {
idx = wined3d_bit_scan(&map); if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_B, start, &range))
break;
TRACE("Setting vs_consts_b[%u] to %s.\n", memcpy(&stateblock->stateblock_state.vs_consts_b[range.offset], &state->vs_consts_b[range.offset],
idx, state->vs_consts_b[idx] ? "TRUE" : "FALSE"); sizeof(*state->vs_consts_b) * range.size);
stateblock->stateblock_state.vs_consts_b[idx] = state->vs_consts_b[idx];
} }
for (i = 0; i < ARRAY_SIZE(stateblock->changed.ps_consts_f); ++i) for (start = 0; ; start = range.offset + range.size)
{ {
map = stateblock->changed.ps_consts_f[i]; if (!wined3d_bitmap_get_range(stateblock->changed.ps_consts_f, WINED3D_MAX_PS_CONSTS_F, start, &range))
break;
while (map) memcpy(&stateblock->stateblock_state.ps_consts_f[range.offset], &state->ps_consts_f[range.offset],
{ sizeof(*state->ps_consts_f) * range.size);
j = wined3d_bit_scan(&map);
idx = i * word_bit_count + j;
TRACE("Setting ps_consts_f[%u] to %s.\n", idx, debug_vec4(&state->ps_consts_f[idx]));
stateblock->stateblock_state.ps_consts_f[idx] = state->ps_consts_f[idx];
}
} }
map = stateblock->changed.pixelShaderConstantsI; map = stateblock->changed.pixelShaderConstantsI;
while (map) for (start = 0; ; start = range.offset + range.size)
{ {
idx = wined3d_bit_scan(&map); if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_I, start, &range))
break;
TRACE("Setting ps_consts_i[%u] to %s.\n", idx, debug_ivec4(&state->ps_consts_i[idx])); memcpy(&stateblock->stateblock_state.ps_consts_i[range.offset], &state->ps_consts_i[range.offset],
sizeof(*state->ps_consts_i) * range.size);
stateblock->stateblock_state.ps_consts_i[idx] = state->ps_consts_i[idx];
} }
map = stateblock->changed.pixelShaderConstantsB; map = stateblock->changed.pixelShaderConstantsB;
while (map) for (start = 0; ; start = range.offset + range.size)
{ {
idx = wined3d_bit_scan(&map); if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_B, start, &range))
break;
TRACE("Setting ps_consts_b[%u] to %s.\n", memcpy(&stateblock->stateblock_state.ps_consts_b[range.offset], &state->ps_consts_b[range.offset],
idx, state->ps_consts_b[idx] ? "TRUE" : "FALSE"); sizeof(*state->ps_consts_b) * range.size);
stateblock->stateblock_state.ps_consts_b[idx] = state->ps_consts_b[idx];
} }
if (stateblock->changed.transforms) if (stateblock->changed.transforms)