[Mesa-dev] [PATCH 4/6] nir: move lowering of SYSTEM_VALUE_LOCAL_GROUP_SIZE into a function
Jason Ekstrand
jason at jlekstrand.net
Wed Jul 11 21:37:19 UTC 2018
On Wed, Jul 11, 2018 at 2:29 PM Karol Herbst <kherbst at redhat.com> wrote:
> we already have this code duplicated and we will need it for the global
> group size as well
>
> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> ---
> src/compiler/nir/nir_lower_system_values.c | 29 +++++++++++-----------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/src/compiler/nir/nir_lower_system_values.c
> b/src/compiler/nir/nir_lower_system_values.c
> index f315b7ae96f..2a1be8fdd45 100644
> --- a/src/compiler/nir/nir_lower_system_values.c
> +++ b/src/compiler/nir/nir_lower_system_values.c
> @@ -28,6 +28,17 @@
> #include "nir.h"
> #include "nir_builder.h"
>
> +static nir_ssa_def*
> +handle_local_group_size(nir_builder *b)
>
How about build_local_group_size_imm or something like that? "handle" is a
bit of an odd name.
> +{
> + nir_const_value local_size;
> + memset(&local_size, 0, sizeof(local_size));
> + local_size.u32[0] = b->shader->info.cs.local_size[0];
> + local_size.u32[1] = b->shader->info.cs.local_size[1];
> + local_size.u32[2] = b->shader->info.cs.local_size[2];
> + return nir_build_imm(b, 3, 32, local_size);
> +}
> +
> static bool
> convert_block(nir_block *block, nir_builder *b)
> {
> @@ -66,18 +77,11 @@ convert_block(nir_block *block, nir_builder *b)
> * "The value of gl_GlobalInvocationID is equal to
> * gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID"
> */
> -
> - nir_const_value local_size;
> - memset(&local_size, 0, sizeof(local_size));
> - local_size.u32[0] = b->shader->info.cs.local_size[0];
> - local_size.u32[1] = b->shader->info.cs.local_size[1];
> - local_size.u32[2] = b->shader->info.cs.local_size[2];
> -
> + nir_ssa_def *group_size = handle_local_group_size(b);
> nir_ssa_def *group_id = nir_load_work_group_id(b);
> nir_ssa_def *local_id = nir_load_local_invocation_id(b);
>
> - sysval = nir_iadd(b, nir_imul(b, group_id,
> - nir_build_imm(b, 3, 32,
> local_size)),
> + sysval = nir_iadd(b, nir_imul(b, group_id, group_size),
> local_id);
>
Can this fit on one line now? Not that it matters much.
4 and 5 are
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
> break;
> }
> @@ -112,12 +116,7 @@ convert_block(nir_block *block, nir_builder *b)
> }
>
> case SYSTEM_VALUE_LOCAL_GROUP_SIZE: {
> - nir_const_value local_size;
> - memset(&local_size, 0, sizeof(local_size));
> - local_size.u32[0] = b->shader->info.cs.local_size[0];
> - local_size.u32[1] = b->shader->info.cs.local_size[1];
> - local_size.u32[2] = b->shader->info.cs.local_size[2];
> - sysval = nir_build_imm(b, 3, 32, local_size);
> + sysval = handle_local_group_size(b);
> break;
> }
>
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180711/be034061/attachment.html>
More information about the mesa-dev
mailing list