diff options
author | Timur Kristóf <[email protected]> | 2019-06-14 14:03:28 +0200 |
---|---|---|
committer | Timur Kristóf <[email protected]> | 2019-06-23 18:33:23 +0200 |
commit | 3b6d787e404181758227e205eda03600b25c1fd9 (patch) | |
tree | a492653d635a0033c43b7649bcb60dfbe5c7ea1d /src/gallium/drivers/iris/iris_program.c | |
parent | ebc8c20b3e688edf7b0157774572251444d33b04 (diff) |
iris: move sysvals to their own constant buffer
This commit moves the sysvals to a separate, new constant buffer
at the end (before the shader constants). It also allows us to
remove the special handling we had for cbuf0, and enables all
constant buffers to support user-specified resources and user
buffers.
v2: (by Kenneth Graunke)
- Rebase on the previous patch to fix system value uploading.
- Fix disk cache num_cbufs calculation
- Fix passthrough TCS to report num_cbufs = 1 so upload actually occurs
- Change upload_sysvals to assert that num_cbufs > 0 when
num_system_values > 0.
Signed-off-by: Timur Kristóf <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/gallium/drivers/iris/iris_program.c')
-rw-r--r-- | src/gallium/drivers/iris/iris_program.c | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 1eef88f1ba3..ba3cf6f6b29 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -428,9 +428,18 @@ iris_setup_uniforms(const struct brw_compiler *compiler, nir_validate_shader(nir, "before remapping"); - /* Place the new params at the front of constant buffer 0. */ + /* Uniforms are stored in constant buffer 0, the + * user-facing UBOs are indexed by one. So if any constant buffer is + * needed, the constant buffer 0 will be needed, so account for it. + */ + unsigned num_cbufs = nir->info.num_ubos; + if (num_cbufs || nir->num_uniforms) + num_cbufs++; + + /* Place the new params in a new cbuf. */ if (num_system_values > 0) { - nir->num_uniforms += num_system_values * sizeof(uint32_t); + unsigned sysval_cbuf_index = num_cbufs; + num_cbufs++; system_values = reralloc(mem_ctx, system_values, enum brw_param_builtin, num_system_values); @@ -450,15 +459,9 @@ iris_setup_uniforms(const struct brw_compiler *compiler, assert(load->src[0].is_ssa); if (load->src[0].ssa == temp_ubo_name) { + nir_ssa_def *imm = nir_imm_int(&b, sysval_cbuf_index); nir_instr_rewrite_src(instr, &load->src[0], - nir_src_for_ssa(nir_imm_int(&b, 0))); - } else if (nir_src_is_const(load->src[0]) && - nir_src_as_uint(load->src[0]) == 0) { - nir_ssa_def *offset = - nir_iadd(&b, load->src[1].ssa, - nir_imm_int(&b, 4 * num_system_values)); - nir_instr_rewrite_src(instr, &load->src[1], - nir_src_for_ssa(offset)); + nir_src_for_ssa(imm)); } } } @@ -470,6 +473,7 @@ iris_setup_uniforms(const struct brw_compiler *compiler, system_values = NULL; } + assert(num_cbufs < PIPE_MAX_CONSTANT_BUFFERS); nir_validate_shader(nir, "after remap"); /* We don't use params[], but fs_visitor::nir_setup_uniforms() asserts @@ -479,14 +483,6 @@ iris_setup_uniforms(const struct brw_compiler *compiler, prog_data->nr_params = nir->num_uniforms / 4; prog_data->param = rzalloc_array(mem_ctx, uint32_t, prog_data->nr_params); - /* System values and uniforms are stored in constant buffer 0, the - * user-facing UBOs are indexed by one. So if any constant buffer is - * needed, the constant buffer 0 will be needed, so account for it. - */ - unsigned num_cbufs = nir->info.num_ubos; - if (num_cbufs || num_system_values || nir->num_uniforms) - num_cbufs++; - /* Constant loads (if any) need to go at the end of the constant buffers so * we need to know num_cbufs before we can lower to them. */ @@ -995,7 +991,7 @@ iris_update_compiled_vs(struct iris_context *ice) IRIS_DIRTY_BINDINGS_VS | IRIS_DIRTY_CONSTANTS_VS | IRIS_DIRTY_VF_SGVS; - shs->cbuf0_needs_upload = true; + shs->sysvals_need_upload = true; const struct brw_vs_prog_data *vs_prog_data = (void *) shader->prog_data; @@ -1108,6 +1104,7 @@ iris_compile_tcs(struct iris_context *ice, nir = brw_nir_create_passthrough_tcs(mem_ctx, compiler, options, key); /* Reserve space for passing the default tess levels as constants. */ + num_cbufs = 1; num_system_values = 8; system_values = rzalloc_array(mem_ctx, enum brw_param_builtin, num_system_values); @@ -1211,20 +1208,7 @@ iris_update_compiled_tcs(struct iris_context *ice) ice->state.dirty |= IRIS_DIRTY_TCS | IRIS_DIRTY_BINDINGS_TCS | IRIS_DIRTY_CONSTANTS_TCS; - shs->cbuf0_needs_upload = true; - - if (!tcs) { - /* We're binding a passthrough TCS, which doesn't have uniforms. - * Since there's no actual TCS, the state tracker doesn't bother - * to call set_constant_buffers to clear stale constant buffers. - * - * We do upload TCS constants for the default tesslevel system - * values, however. In this case, we would see stale constant - * data and try and read a dangling cbuf0->user_buffer pointer. - * Just zero out the stale constants to avoid the upload. - */ - memset(&shs->cbuf0, 0, sizeof(shs->cbuf0)); - } + shs->sysvals_need_upload = true; } } @@ -1327,14 +1311,14 @@ iris_update_compiled_tes(struct iris_context *ice) ice->state.dirty |= IRIS_DIRTY_TES | IRIS_DIRTY_BINDINGS_TES | IRIS_DIRTY_CONSTANTS_TES; - shs->cbuf0_needs_upload = true; + shs->sysvals_need_upload = true; } /* TODO: Could compare and avoid flagging this. */ const struct shader_info *tes_info = &ish->nir->info; if (tes_info->system_values_read & (1ull << SYSTEM_VALUE_VERTICES_IN)) { ice->state.dirty |= IRIS_DIRTY_CONSTANTS_TES; - ice->state.shaders[MESA_SHADER_TESS_EVAL].cbuf0_needs_upload = true; + ice->state.shaders[MESA_SHADER_TESS_EVAL].sysvals_need_upload = true; } } @@ -1439,7 +1423,7 @@ iris_update_compiled_gs(struct iris_context *ice) ice->state.dirty |= IRIS_DIRTY_GS | IRIS_DIRTY_BINDINGS_GS | IRIS_DIRTY_CONSTANTS_GS; - shs->cbuf0_needs_upload = true; + shs->sysvals_need_upload = true; } } @@ -1541,7 +1525,7 @@ iris_update_compiled_fs(struct iris_context *ice) IRIS_DIRTY_WM | IRIS_DIRTY_CLIP | IRIS_DIRTY_SBE; - shs->cbuf0_needs_upload = true; + shs->sysvals_need_upload = true; } } @@ -1794,7 +1778,7 @@ iris_update_compiled_compute_shader(struct iris_context *ice) ice->state.dirty |= IRIS_DIRTY_CS | IRIS_DIRTY_BINDINGS_CS | IRIS_DIRTY_CONSTANTS_CS; - shs->cbuf0_needs_upload = true; + shs->sysvals_need_upload = true; } } |