summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r--src/gallium/drivers/ilo/ilo_shader.c3
-rw-r--r--src/gallium/drivers/ilo/ilo_shader.h1
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c60
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