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 | |
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')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_shader.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_shader.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.c | 60 |
3 files changed, 35 insertions, 29 deletions
diff --git a/src/gallium/drivers/ilo/ilo_shader.c b/src/gallium/drivers/ilo/ilo_shader.c index 27555262b97..0db03966c6b 100644 --- a/src/gallium/drivers/ilo/ilo_shader.c +++ b/src/gallium/drivers/ilo/ilo_shader.c @@ -1060,6 +1060,9 @@ ilo_shader_get_kernel_param(const struct ilo_shader_state *shader, case ILO_KERNEL_URB_DATA_START_REG: val = kernel->in.start_grf; break; + case ILO_KERNEL_SKIP_CBUF0_UPLOAD: + val = false; + break; case ILO_KERNEL_VS_INPUT_INSTANCEID: val = shader->info.has_instanceid; diff --git a/src/gallium/drivers/ilo/ilo_shader.h b/src/gallium/drivers/ilo/ilo_shader.h index 6a2b8a397b3..67f190c7bc0 100644 --- a/src/gallium/drivers/ilo/ilo_shader.h +++ b/src/gallium/drivers/ilo/ilo_shader.h @@ -34,6 +34,7 @@ enum ilo_kernel_param { ILO_KERNEL_INPUT_COUNT, ILO_KERNEL_OUTPUT_COUNT, ILO_KERNEL_URB_DATA_START_REG, + ILO_KERNEL_SKIP_CBUF0_UPLOAD, ILO_KERNEL_VS_INPUT_INSTANCEID, ILO_KERNEL_VS_INPUT_VERTEXID, 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 |