<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Dec 19, 2018 at 4:06 PM Bas Nieuwenhuizen <<a href="mailto:bas@basnieuwenhuizen.nl">bas@basnieuwenhuizen.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Dec 19, 2018 at 8:45 PM Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>> wrote:<br>
><br>
> This is little more than an iadd_imm right now but it will help in the<br>
> next commit where we refactor things further.<br>
> ---<br>
>  src/amd/vulkan/radv_query.c | 31 ++++++++++++++++---------------<br>
>  1 file changed, 16 insertions(+), 15 deletions(-)<br>
><br>
> diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c<br>
> index 9797d156c88..6e88de691d6 100644<br>
> --- a/src/amd/vulkan/radv_query.c<br>
> +++ b/src/amd/vulkan/radv_query.c<br>
> @@ -51,6 +51,12 @@ static unsigned get_max_db(struct radv_device *device)<br>
>         return num_db;<br>
>  }<br>
><br>
> +<br>
> +static nir_ssa_def *nir_flag_set(nir_builder *b, nir_ssa_def *flags, uint32_t flag)<br>
<br>
Can I ask you to rename this to something like nir_test_flag?<br>
nir_flag_set would first make me think of the verb in imperative,<br>
which would result in an or instead of an and.<br></blockquote><div><br></div><div>Sure.  Happy to do so.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Otherwise<br>
<br>
Reviewed-by: Bas Nieuwenhuizen <<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>><br></blockquote><div><br></div><div>Did you also test it?  Because I didn't. :-)</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> +{<br>
> +       return nir_iand(b, flags, nir_imm_int(b, flag));<br>
> +}<br>
> +<br>
>  static void radv_break_on_count(nir_builder *b, nir_variable *var, nir_ssa_def *count)<br>
>  {<br>
>         nir_ssa_def *counter = nir_load_var(b, var);<br>
> @@ -214,12 +220,11 @@ build_occlusion_query_shader(struct radv_device *device) {<br>
><br>
>         /* Store the result if complete or if partial results have been requested. */<br>
><br>
> -       nir_ssa_def *result_is_64bit = nir_iand(&b, flags,<br>
> -                                               nir_imm_int(&b, VK_QUERY_RESULT_64_BIT));<br>
> +       nir_ssa_def *result_is_64bit = nir_flag_set(&b, flags, VK_QUERY_RESULT_64_BIT);<br>
>         nir_ssa_def *result_size = nir_b32csel(&b, result_is_64bit, nir_imm_int(&b, 8), nir_imm_int(&b, 4));<br>
><br>
>         nir_if *store_if = nir_if_create(b.shader);<br>
> -       store_if->condition = nir_src_for_ssa(nir_ior(&b, nir_iand(&b, flags, nir_imm_int(&b, VK_QUERY_RESULT_PARTIAL_BIT)), nir_load_var(&b, available)));<br>
> +       store_if->condition = nir_src_for_ssa(nir_ior(&b, nir_flag_set(&b, flags, VK_QUERY_RESULT_PARTIAL_BIT), nir_load_var(&b, available)));<br>
>         nir_cf_node_insert(b.cursor, &store_if->cf_node);<br>
><br>
>         b.cursor = nir_after_cf_list(&store_if->then_list);<br>
> @@ -253,7 +258,7 @@ build_occlusion_query_shader(struct radv_device *device) {<br>
>         /* Store the availability bit if requested. */<br>
><br>
>         nir_if *availability_if = nir_if_create(b.shader);<br>
> -       availability_if->condition = nir_src_for_ssa(nir_iand(&b, flags, nir_imm_int(&b, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)));<br>
> +       availability_if->condition = nir_src_for_ssa(nir_flag_set(&b, flags, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT));<br>
>         nir_cf_node_insert(b.cursor, &availability_if->cf_node);<br>
><br>
>         b.cursor = nir_after_cf_list(&availability_if->then_list);<br>
> @@ -369,15 +374,14 @@ build_pipeline_statistics_query_shader(struct radv_device *device) {<br>
>         nir_builder_instr_insert(&b, &load->instr);<br>
>         nir_ssa_def *available = &load->dest.ssa;<br>
><br>
> -       nir_ssa_def *result_is_64bit = nir_iand(&b, flags,<br>
> -                                               nir_imm_int(&b, VK_QUERY_RESULT_64_BIT));<br>
> +       nir_ssa_def *result_is_64bit = nir_flag_set(&b, flags, VK_QUERY_RESULT_64_BIT);<br>
>         nir_ssa_def *elem_size = nir_b32csel(&b, result_is_64bit, nir_imm_int(&b, 8), nir_imm_int(&b, 4));<br>
>         nir_ssa_def *elem_count = nir_ushr(&b, stats_mask, nir_imm_int(&b, 16));<br>
><br>
>         /* Store the availability bit if requested. */<br>
><br>
>         nir_if *availability_if = nir_if_create(b.shader);<br>
> -       availability_if->condition = nir_src_for_ssa(nir_iand(&b, flags, nir_imm_int(&b, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)));<br>
> +       availability_if->condition = nir_src_for_ssa(nir_flag_set(&b, flags, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT));<br>
>         nir_cf_node_insert(b.cursor, &availability_if->cf_node);<br>
><br>
>         b.cursor = nir_after_cf_list(&availability_if->then_list);<br>
> @@ -401,7 +405,7 @@ build_pipeline_statistics_query_shader(struct radv_device *device) {<br>
>         nir_store_var(&b, output_offset, output_base, 0x1);<br>
>         for (int i = 0; i < 11; ++i) {<br>
>                 nir_if *store_if = nir_if_create(b.shader);<br>
> -               store_if->condition = nir_src_for_ssa(nir_iand(&b, stats_mask, nir_imm_int(&b, 1u << i)));<br>
> +               store_if->condition = nir_src_for_ssa(nir_flag_set(&b, stats_mask, 1u << i));<br>
>                 nir_cf_node_insert(b.cursor, &store_if->cf_node);<br>
><br>
>                 b.cursor = nir_after_cf_list(&store_if->then_list);<br>
> @@ -463,8 +467,7 @@ build_pipeline_statistics_query_shader(struct radv_device *device) {<br>
>         b.cursor = nir_after_cf_list(&available_if->else_list);<br>
><br>
>         available_if = nir_if_create(b.shader);<br>
> -       available_if->condition = nir_src_for_ssa(nir_iand(&b, flags,<br>
> -                                                              nir_imm_int(&b, VK_QUERY_RESULT_PARTIAL_BIT)));<br>
> +       available_if->condition = nir_src_for_ssa(nir_flag_set(&b, flags, VK_QUERY_RESULT_PARTIAL_BIT));<br>
>         nir_cf_node_insert(b.cursor, &available_if->cf_node);<br>
><br>
>         b.cursor = nir_after_cf_list(&available_if->then_list);<br>
> @@ -667,7 +670,7 @@ build_tfb_query_shader(struct radv_device *device)<br>
><br>
>         /* Determine if result is 64 or 32 bit. */<br>
>         nir_ssa_def *result_is_64bit =<br>
> -               nir_iand(&b, flags, nir_imm_int(&b, VK_QUERY_RESULT_64_BIT));<br>
> +               nir_flag_set(&b, flags, VK_QUERY_RESULT_64_BIT);<br>
>         nir_ssa_def *result_size =<br>
>                 nir_b32csel(&b, result_is_64bit, nir_imm_int(&b, 16),<br>
>                             nir_imm_int(&b, 8));<br>
> @@ -675,8 +678,7 @@ build_tfb_query_shader(struct radv_device *device)<br>
>         /* Store the result if complete or partial results have been requested. */<br>
>         nir_if *store_if = nir_if_create(b.shader);<br>
>         store_if->condition =<br>
> -               nir_src_for_ssa(nir_ior(&b, nir_iand(&b, flags,<br>
> -                                                    nir_imm_int(&b, VK_QUERY_RESULT_PARTIAL_BIT)),<br>
> +               nir_src_for_ssa(nir_ior(&b, nir_flag_set(&b, flags, VK_QUERY_RESULT_PARTIAL_BIT),<br>
>                                         nir_load_var(&b, available)));<br>
>         nir_cf_node_insert(b.cursor, &store_if->cf_node);<br>
><br>
> @@ -714,8 +716,7 @@ build_tfb_query_shader(struct radv_device *device)<br>
>         /* Store the availability bit if requested. */<br>
>         nir_if *availability_if = nir_if_create(b.shader);<br>
>         availability_if->condition =<br>
> -               nir_src_for_ssa(nir_iand(&b, flags,<br>
> -                                        nir_imm_int(&b, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)));<br>
> +               nir_src_for_ssa(nir_flag_set(&b, flags, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT));<br>
>         nir_cf_node_insert(b.cursor, &availability_if->cf_node);<br>
><br>
>         b.cursor = nir_after_cf_list(&availability_if->then_list);<br>
> --<br>
> 2.19.2<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>