mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-17 12:30:33 +01:00
nir/opt_ray_queries: Cleanup and return if functions is not singular
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37283>
This commit is contained in:
parent
39a5e80a7a
commit
2a4b1ea69b
1 changed files with 11 additions and 10 deletions
|
|
@ -213,11 +213,12 @@ get_parent_loop(nir_cf_node *node)
|
|||
bool
|
||||
nir_opt_ray_query_ranges(nir_shader *shader)
|
||||
{
|
||||
assert(exec_list_length(&shader->functions) == 1);
|
||||
if (!exec_list_is_singular(&shader->functions)) {
|
||||
nir_shader_preserve_all_metadata(shader);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct nir_function *func =
|
||||
(struct nir_function *)exec_list_get_head_const(&shader->functions);
|
||||
assert(func->impl);
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||
|
||||
uint32_t ray_query_count = 0;
|
||||
nir_foreach_variable_in_shader(var, shader) {
|
||||
|
|
@ -225,19 +226,19 @@ nir_opt_ray_query_ranges(nir_shader *shader)
|
|||
continue;
|
||||
ray_query_count++;
|
||||
}
|
||||
nir_foreach_function_temp_variable(var, func->impl) {
|
||||
nir_foreach_function_temp_variable(var, impl) {
|
||||
if (!var->data.ray_query || glsl_type_is_array(var->type))
|
||||
continue;
|
||||
ray_query_count++;
|
||||
}
|
||||
|
||||
if (ray_query_count <= 1) {
|
||||
return nir_no_progress(func->impl);
|
||||
return nir_no_progress(impl);
|
||||
}
|
||||
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
nir_metadata_require(func->impl, nir_metadata_instr_index | nir_metadata_dominance);
|
||||
nir_metadata_require(impl, nir_metadata_instr_index | nir_metadata_dominance);
|
||||
|
||||
nir_variable **ray_queries = ralloc_array(mem_ctx, nir_variable *, ray_query_count);
|
||||
ray_query_count = 0;
|
||||
|
|
@ -250,7 +251,7 @@ nir_opt_ray_query_ranges(nir_shader *shader)
|
|||
ray_query_count++;
|
||||
}
|
||||
|
||||
nir_foreach_function_temp_variable(var, func->impl) {
|
||||
nir_foreach_function_temp_variable(var, impl) {
|
||||
if (!var->data.ray_query || glsl_type_is_array(var->type))
|
||||
continue;
|
||||
|
||||
|
|
@ -267,7 +268,7 @@ nir_opt_ray_query_ranges(nir_shader *shader)
|
|||
struct hash_table *range_indices = _mesa_pointer_hash_table_create(mem_ctx);
|
||||
uint32_t target_index = 0;
|
||||
|
||||
nir_foreach_block(block, func->impl) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_cf_node *parent_loop = get_parent_loop(&block->cf_node);
|
||||
|
||||
nir_foreach_instr(instr, block) {
|
||||
|
|
@ -404,7 +405,7 @@ nir_opt_ray_query_ranges(nir_shader *shader)
|
|||
}
|
||||
}
|
||||
|
||||
nir_no_progress(func->impl);
|
||||
nir_no_progress(impl);
|
||||
|
||||
/* Remove dead ray queries. */
|
||||
if (progress) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue