diff options
author | Chia-I Wu <[email protected]> | 2013-07-18 05:43:00 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-08-13 15:52:37 +0800 |
commit | 5df62dce347eb8046a38630280aa043e075ac56f (patch) | |
tree | a686670500f623489c4a3518b6dcb808ed76a615 /src/gallium/drivers/ilo/ilo_state.c | |
parent | 8b5b5fe3944d75c5d3667516139e366d2207c22a (diff) |
ilo: make constant buffer 0 upload optional
Add ILO_KERNEL_SKIP_CBUF0_UPLOAD so that we can skip constant buffer 0 upload
when the kernel does not need it.
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_state.c')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.c | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index ce6930c4aec..c72d93a49df 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -85,44 +85,46 @@ finalize_shader_states(struct ilo_context *ilo) } static void -finalize_constant_buffers(struct ilo_context *ilo) +finalize_cbuf_state(struct ilo_context *ilo, + struct ilo_cbuf_state *cbuf, + const struct ilo_shader_state *sh) { - int sh; + uint32_t upload_mask = cbuf->enabled_mask; - if (!(ilo->dirty & ILO_DIRTY_CBUF)) - return; + /* skip CBUF0 if the kernel does not need it */ + upload_mask &= + ~ilo_shader_get_kernel_param(sh, ILO_KERNEL_SKIP_CBUF0_UPLOAD); - /* TODO push constants? */ - for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { - unsigned enabled_mask = ilo->cbuf[sh].enabled_mask; + while (upload_mask) { + const enum pipe_format elem_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + unsigned offset, i; - while (enabled_mask) { - struct ilo_cbuf_cso *cbuf; - int i; + i = u_bit_scan(&upload_mask); + /* no need to upload */ + if (cbuf->cso[i].resource) + continue; - i = u_bit_scan(&enabled_mask); - cbuf = &ilo->cbuf[sh].cso[i]; + u_upload_data(ilo->uploader, 0, cbuf->cso[i].user_buffer_size, + cbuf->cso[i].user_buffer, &offset, &cbuf->cso[i].resource); - /* upload user buffer */ - if (cbuf->user_buffer) { - const enum pipe_format elem_format = - PIPE_FORMAT_R32G32B32A32_FLOAT; - unsigned offset; + ilo_gpe_init_view_surface_for_buffer(ilo->dev, + ilo_buffer(cbuf->cso[i].resource), + offset, cbuf->cso[i].user_buffer_size, + util_format_get_blocksize(elem_format), elem_format, + false, false, &cbuf->cso[i].surface); - u_upload_data(ilo->uploader, 0, cbuf->user_buffer_size, - cbuf->user_buffer, &offset, &cbuf->resource); + ilo->dirty |= ILO_DIRTY_CBUF; + } +} - ilo_gpe_init_view_surface_for_buffer(ilo->dev, - ilo_buffer(cbuf->resource), - offset, cbuf->user_buffer_size, - util_format_get_blocksize(elem_format), elem_format, - false, false, &cbuf->surface); +static void +finalize_constant_buffers(struct ilo_context *ilo) +{ + if (ilo->dirty & (ILO_DIRTY_CBUF | ILO_DIRTY_VS)) + finalize_cbuf_state(ilo, &ilo->cbuf[PIPE_SHADER_VERTEX], ilo->vs); - cbuf->user_buffer = NULL; - cbuf->user_buffer_size = 0; - } - } - } + if (ilo->dirty & (ILO_DIRTY_CBUF | ILO_DIRTY_FS)) + finalize_cbuf_state(ilo, &ilo->cbuf[PIPE_SHADER_FRAGMENT], ilo->fs); } static void |