static void gather_intrinsic_info(const nir_intrinsic_instr *instr, struct ac_shader_info *info) { switch (instr->intrinsic) { case nir_intrinsic_interp_var_at_sample: info->ps.needs_sample_positions = true; break; case nir_intrinsic_load_draw_id: info->vs.needs_draw_id = true; break; case nir_intrinsic_load_instance_id: info->vs.needs_instance_id = true; break; case nir_intrinsic_load_num_work_groups: info->cs.uses_grid_size = true; break; case nir_intrinsic_load_local_invocation_id: case nir_intrinsic_load_work_group_id: { unsigned mask = nir_ssa_def_components_read(&instr->dest.ssa); while (mask) { unsigned i = u_bit_scan(&mask); if (instr->intrinsic == nir_intrinsic_load_work_group_id) info->cs.uses_block_id[i] = true; else info->cs.uses_thread_id[i] = true; } break; } case nir_intrinsic_load_local_invocation_index: info->cs.uses_local_invocation_idx = true; break; case nir_intrinsic_load_sample_id: info->ps.force_persample = true; break; case nir_intrinsic_load_sample_pos: info->ps.force_persample = true; break; case nir_intrinsic_load_view_index: info->needs_multiview_view_index = true; break; case nir_intrinsic_load_invocation_id: info->uses_invocation_id = true; break; case nir_intrinsic_load_primitive_id: info->uses_prim_id = true; break; case nir_intrinsic_load_push_constant: info->loads_push_constants = true; break; case nir_intrinsic_vulkan_resource_index: info->desc_set_used_mask |= (1 << nir_intrinsic_desc_set(instr)); break; case nir_intrinsic_image_load: case nir_intrinsic_image_store: case nir_intrinsic_image_atomic_add: case nir_intrinsic_image_atomic_min: case nir_intrinsic_image_atomic_max: case nir_intrinsic_image_atomic_and: case nir_intrinsic_image_atomic_or: case nir_intrinsic_image_atomic_xor: case nir_intrinsic_image_atomic_exchange: case nir_intrinsic_image_atomic_comp_swap: case nir_intrinsic_image_size: { const struct glsl_type *type = instr->variables[0]->var->type; if(instr->variables[0]->deref.child) type = instr->variables[0]->deref.child->type; enum glsl_sampler_dim dim = glsl_get_sampler_dim(type); if (dim == GLSL_SAMPLER_DIM_SUBPASS || dim == GLSL_SAMPLER_DIM_SUBPASS_MS) info->ps.uses_input_attachments = true; mark_sampler_desc(instr->variables[0]->var, info); break; } default: break; } }
static void gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr, struct ac_shader_info *info) { switch (instr->intrinsic) { case nir_intrinsic_interp_var_at_sample: info->ps.needs_sample_positions = true; break; case nir_intrinsic_load_draw_id: info->vs.needs_draw_id = true; break; case nir_intrinsic_load_instance_id: info->vs.needs_instance_id = true; break; case nir_intrinsic_load_num_work_groups: info->cs.uses_grid_size = true; break; case nir_intrinsic_load_local_invocation_id: case nir_intrinsic_load_work_group_id: { unsigned mask = nir_ssa_def_components_read(&instr->dest.ssa); while (mask) { unsigned i = u_bit_scan(&mask); if (instr->intrinsic == nir_intrinsic_load_work_group_id) info->cs.uses_block_id[i] = true; else info->cs.uses_thread_id[i] = true; } break; } case nir_intrinsic_load_local_invocation_index: info->cs.uses_local_invocation_idx = true; break; case nir_intrinsic_load_sample_id: info->ps.force_persample = true; break; case nir_intrinsic_load_sample_pos: info->ps.force_persample = true; break; case nir_intrinsic_load_view_index: info->needs_multiview_view_index = true; break; case nir_intrinsic_load_invocation_id: info->uses_invocation_id = true; break; case nir_intrinsic_load_primitive_id: info->uses_prim_id = true; break; case nir_intrinsic_load_push_constant: info->loads_push_constants = true; break; case nir_intrinsic_vulkan_resource_index: info->desc_set_used_mask |= (1 << nir_intrinsic_desc_set(instr)); break; case nir_intrinsic_image_load: case nir_intrinsic_image_store: case nir_intrinsic_image_atomic_add: case nir_intrinsic_image_atomic_min: case nir_intrinsic_image_atomic_max: case nir_intrinsic_image_atomic_and: case nir_intrinsic_image_atomic_or: case nir_intrinsic_image_atomic_xor: case nir_intrinsic_image_atomic_exchange: case nir_intrinsic_image_atomic_comp_swap: case nir_intrinsic_image_size: { const struct glsl_type *type = instr->variables[0]->var->type; if(instr->variables[0]->deref.child) type = instr->variables[0]->deref.child->type; enum glsl_sampler_dim dim = glsl_get_sampler_dim(type); if (dim == GLSL_SAMPLER_DIM_SUBPASS || dim == GLSL_SAMPLER_DIM_SUBPASS_MS) info->ps.uses_input_attachments = true; mark_sampler_desc(instr->variables[0]->var, info); if (nir_intrinsic_image_store || nir_intrinsic_image_atomic_add || nir_intrinsic_image_atomic_min || nir_intrinsic_image_atomic_max || nir_intrinsic_image_atomic_and || nir_intrinsic_image_atomic_or || nir_intrinsic_image_atomic_xor || nir_intrinsic_image_atomic_exchange || nir_intrinsic_image_atomic_comp_swap) { if (nir->info.stage == MESA_SHADER_FRAGMENT) info->ps.writes_memory = true; } break; } case nir_intrinsic_store_ssbo: case nir_intrinsic_ssbo_atomic_add: case nir_intrinsic_ssbo_atomic_imin: case nir_intrinsic_ssbo_atomic_umin: case nir_intrinsic_ssbo_atomic_imax: case nir_intrinsic_ssbo_atomic_umax: case nir_intrinsic_ssbo_atomic_and: case nir_intrinsic_ssbo_atomic_or: case nir_intrinsic_ssbo_atomic_xor: case nir_intrinsic_ssbo_atomic_exchange: case nir_intrinsic_ssbo_atomic_comp_swap: if (nir->info.stage == MESA_SHADER_FRAGMENT) info->ps.writes_memory = true; break; case nir_intrinsic_load_var: if (nir->info.stage == MESA_SHADER_VERTEX) { nir_deref_var *dvar = instr->variables[0]; nir_variable *var = dvar->var; if (var->data.mode == nir_var_shader_in) { unsigned idx = var->data.location; uint8_t mask = nir_ssa_def_components_read(&instr->dest.ssa); info->vs.input_usage_mask[idx] |= mask; } } break; default: break; } }