[Mesa-dev] [PATCH 03/26] nir/intrinsics: Add a vulkan_resource_index intrinsic
Rob Clark
robdclark at gmail.com
Sat Mar 26 15:53:36 UTC 2016
On Fri, Mar 25, 2016 at 7:12 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> This is used to facilitate the Vulkan binding model where each resource is
> described by a (descriptor set, binding, array index) tuple.
> ---
> src/compiler/nir/nir.h | 12 ++++++++++++
> src/compiler/nir/nir_intrinsics.h | 20 ++++++++++++++++++++
> src/compiler/nir/nir_print.c | 2 ++
> 3 files changed, 34 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 996f104..33bb1fd 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -960,6 +960,16 @@ typedef enum {
> */
> NIR_INTRINSIC_RANGE = 5,
>
> + /**
> + * The Vulkan descriptor set for vulkan_resource_index intrinsic.
> + */
> + NIR_INTRINSIC_DESC_SET = 6,
> +
> + /**
> + * The Vulkan descriptor set binding for vulkan_resource_index intrinsic.
> + */
> + NIR_INTRINSIC_BINDING = 7,
> +
> NIR_INTRINSIC_NUM_INDEX_FLAGS,
>
> } nir_intrinsic_index_flag;
> @@ -1024,6 +1034,8 @@ INTRINSIC_IDX_ACCESSORS(base, BASE, int)
> INTRINSIC_IDX_ACCESSORS(stream_id, STREAM_ID, unsigned)
> INTRINSIC_IDX_ACCESSORS(ucp_id, UCP_ID, unsigned)
> INTRINSIC_IDX_ACCESSORS(range, RANGE, unsigned)
> +INTRINSIC_IDX_ACCESSORS(desc_set, DESC_SET, unsigned)
> +INTRINSIC_IDX_ACCESSORS(binding, BINDING, unsigned)
>
> /**
> * \group texture information
> diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
> index 2d6b7b7..efbf35d 100644
> --- a/src/compiler/nir/nir_intrinsics.h
> +++ b/src/compiler/nir/nir_intrinsics.h
> @@ -176,6 +176,26 @@ INTRINSIC(image_samples, 0, ARR(), true, 1, 1, 0, xx, xx, xx,
> NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
>
> /*
> + * Vulkan descriptor set intrinsic
> + *
> + * The Vulkan API uses a different binding model from GL. In the Vulkan
> + * API, all external resources are represented by a tripple:
s/tripple/tuple/? Or triplet? (But tuple makes more sense since it
is clear from next line that it is a 3-tuple)
anyways, just nit picking..
Reviewed-by: Rob Clark <robdclark at gmail.com>
> + *
> + * (descriptor set, binding, array index)
> + *
> + * where the array index is the only thing allowed to be indirect. The
> + * vulkan_surface_index intrinsic takes the descriptor set and binding as
> + * its first two indices and the array index as its source. The third
> + * index is a nir_variable_mode in case that's useful to the backend.
> + *
> + * The intended usage is that the shader will call vulkan_surface_index to
> + * get an index and then pass that as the buffer index ubo/ssbo calls.
> + */
> +INTRINSIC(vulkan_resource_index, 1, ARR(1), true, 1, 0, 2,
> + DESC_SET, BINDING, xx,
> + NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
> +
> +/*
> * variable atomic intrinsics
> *
> * All of these variable atomic memory operations read a value from memory,
> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
> index 28c8043..17ae368 100644
> --- a/src/compiler/nir/nir_print.c
> +++ b/src/compiler/nir/nir_print.c
> @@ -505,6 +505,8 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
> [NIR_INTRINSIC_STREAM_ID] = "stream-id",
> [NIR_INTRINSIC_UCP_ID] = "ucp-id",
> [NIR_INTRINSIC_RANGE] = "range",
> + [NIR_INTRINSIC_DESC_SET] = "desc-set",
> + [NIR_INTRINSIC_BINDING] = "binding",
> };
> for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
> if (!info->index_map[idx])
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list