pipeline->needs_data_cache = true;
}
+ if (stage == MESA_SHADER_COMPUTE)
+ ((struct brw_cs_prog_data *)prog_data)->thread_local_id_index =
+ prog_data->nr_params++; /* The CS Thread ID uniform */
+
if (nir->info.num_ssbos > 0)
pipeline->needs_data_cache = true;
*/
int param_count = cp->program.Base.nir->num_uniforms / 4;
+ /* The backend also sometimes add a param for the thread local id. */
+ prog_data.thread_local_id_index = param_count++;
+
/* The backend also sometimes adds params for texture size. */
param_count += 2 * ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits;
prog_data.base.param =
payload.num_regs = 1;
- if (nir->info.system_values_read & SYSTEM_BIT_LOCAL_INVOCATION_ID) {
+ if (nir->info.system_values_read & SYSTEM_BIT_LOCAL_INVOCATION_ID &&
+ prog_data->thread_local_id_index < 0) {
prog_data->local_invocation_id_regs = dispatch_width * 3 / 8;
payload.local_invocation_id_reg = payload.num_regs;
payload.num_regs += prog_data->local_invocation_id_regs;
true);
brw_nir_lower_cs_shared(shader);
prog_data->base.total_shared += shader->num_shared;
+
+ /* The driver isn't yet ready to support thread_local_id_index, so we force
+ * it to disabled for now.
+ */
+ prog_data->thread_local_id_index = -1;
+
+ /* Now that we cloned the nir_shader, we can update num_uniforms based on
+ * the thread_local_id_index.
+ */
+ if (prog_data->thread_local_id_index >= 0) {
+ shader->num_uniforms =
+ MAX2(shader->num_uniforms,
+ (unsigned)4 * (prog_data->thread_local_id_index + 1));
+ }
+
shader = brw_postprocess_nir(shader, compiler->devinfo, true);
prog_data->local_size[0] = shader->info.cs.local_size[0];