diff options
author | Chia-I Wu <[email protected]> | 2013-06-26 18:50:01 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-06-26 21:50:26 +0800 |
commit | c610b67972b4a06a25699623d1134b197ae277e0 (patch) | |
tree | 520cf079a990e1ddbe6de7a3849073f768541bf9 /src | |
parent | 9aebad618c0aab527a0b838ce0a79ffa6dd426bb (diff) |
ilo: use a bitmask for enabled constant buffers
Looping over 4 * 13 constant buffers while in most cases only two are enabled
is stupid.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.c | 24 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/gallium/drivers/ilo/ilo_gpe.h b/src/gallium/drivers/ilo/ilo_gpe.h index aa979f31a09..1f5f47cacaa 100644 --- a/src/gallium/drivers/ilo/ilo_gpe.h +++ b/src/gallium/drivers/ilo/ilo_gpe.h @@ -221,6 +221,7 @@ struct ilo_cbuf_cso { struct ilo_cbuf_state { struct ilo_cbuf_cso cso[ILO_MAX_CONST_BUFFERS]; + uint32_t enabled_mask; unsigned count; }; diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index ede72623f17..59d3c3612a0 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -87,17 +87,21 @@ finalize_shader_states(struct ilo_context *ilo) static void finalize_constant_buffers(struct ilo_context *ilo) { - int sh, i; + int sh; if (!(ilo->dirty & ILO_DIRTY_CONSTANT_BUFFER)) return; /* TODO push constants? */ for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { - int last_cbuf = -1; + unsigned enabled_mask = ilo->cbuf[sh].enabled_mask; - for (i = 0; i < Elements(ilo->cbuf[sh].cso); i++) { - struct ilo_cbuf_cso *cbuf = &ilo->cbuf[sh].cso[i]; + while (enabled_mask) { + struct ilo_cbuf_cso *cbuf; + int i; + + i = u_bit_scan(&enabled_mask); + cbuf = &ilo->cbuf[sh].cso[i]; /* upload user buffer */ if (cbuf->user_buffer) { @@ -117,12 +121,9 @@ finalize_constant_buffers(struct ilo_context *ilo) cbuf->user_buffer = NULL; cbuf->user_buffer_size = 0; } - - if (cbuf->resource) - last_cbuf = i; } - ilo->cbuf[sh].count = last_cbuf + 1; + ilo->cbuf[sh].count = util_last_bit(ilo->cbuf[sh].enabled_mask); } } @@ -610,6 +611,8 @@ ilo_set_constant_buffer(struct pipe_context *pipe, cbuf->user_buffer = state->user_buffer; cbuf->user_buffer_size = state->buffer_size; } + + ilo->cbuf[shader].enabled_mask |= 1 << index; } else { pipe_resource_reference(&cbuf->resource, NULL); @@ -617,10 +620,9 @@ ilo_set_constant_buffer(struct pipe_context *pipe, cbuf->user_buffer = NULL; cbuf->user_buffer_size = 0; - } - /* the correct value will be set in ilo_finalize_3d_states() */ - ilo->cbuf[shader].count = 0; + ilo->cbuf[shader].enabled_mask &= ~(1 << index); + } ilo->dirty |= ILO_DIRTY_CONSTANT_BUFFER; } |