[Mesa-dev] [PATCH 03/18] nir: add new intrinsic field for storing component offset

Kenneth Graunke kenneth at whitecape.org
Sun Jun 12 03:14:29 UTC 2016


On Saturday, June 11, 2016 9:03:23 AM PDT Timothy Arceri wrote:
> This offset is used for packing.
> ---
>  src/compiler/nir/nir.h            | 6 ++++++
>  src/compiler/nir/nir_intrinsics.h | 8 ++++----
>  src/compiler/nir/nir_lower_io.c   | 8 ++++++++
>  src/compiler/nir/nir_print.c      | 3 +++
>  4 files changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index ec7b0c7..d5e4733 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -987,6 +987,11 @@ typedef enum {
>      */
>     NIR_INTRINSIC_BINDING = 7,
>  
> +   /**
> +    * Component offset.
> +    */
> +   NIR_INTRINSIC_COMPONENT = 8,
> +
>     NIR_INTRINSIC_NUM_INDEX_FLAGS,
>  
>  } nir_intrinsic_index_flag;
> @@ -1053,6 +1058,7 @@ 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)
> +INTRINSIC_IDX_ACCESSORS(component, COMPONENT, unsigned)
>  
>  /**
>   * \group texture information
> diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
> index 6f86c9f..4da36ff 100644
> --- a/src/compiler/nir/nir_intrinsics.h
> +++ b/src/compiler/nir/nir_intrinsics.h
> @@ -336,9 +336,9 @@ LOAD(uniform, 1, 2, BASE, RANGE, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC
>  /* src[] = { buffer_index, offset }. No const_index */
>  LOAD(ubo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
>  /* src[] = { offset }. const_index[] = { base } */
> -LOAD(input, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
> +LOAD(input, 1, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
>  /* src[] = { vertex, offset }. const_index[] = { base } */
> -LOAD(per_vertex_input, 2, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
> +LOAD(per_vertex_input, 2, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
>  /* src[] = { buffer_index, offset }. No const_index */
>  LOAD(ssbo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
>  /* src[] = { offset }. const_index[] = { base } */

Don't nir_intrinsic_load_output and nir_intrinsic_load_per_vertex_output
need component support too?  (These are used to read TCS outputs.)

> @@ -362,9 +362,9 @@ LOAD(push_constant, 1, 2, BASE, RANGE, xx,
>     INTRINSIC(store_##name, srcs, ARR(0, 1, 1, 1), false, 0, 0, num_indices, idx0, idx1, idx2, flags)
>  
>  /* src[] = { value, offset }. const_index[] = { base, write_mask } */
> -STORE(output, 2, 2, BASE, WRMASK, xx, 0)
> +STORE(output, 2, 3, BASE, WRMASK, COMPONENT, 0)
>  /* src[] = { value, vertex, offset }. const_index[] = { base, write_mask } */
> -STORE(per_vertex_output, 3, 2, BASE, WRMASK, xx, 0)
> +STORE(per_vertex_output, 3, 3, BASE, WRMASK, COMPONENT, 0)
>  /* src[] = { value, block_index, offset }. const_index[] = { write_mask } */
>  STORE(ssbo, 3, 1, WRMASK, xx, xx, 0)
>  /* src[] = { value, offset }. const_index[] = { base, write_mask } */
> diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
> index a839924..0d6d8e4 100644
> --- a/src/compiler/nir/nir_lower_io.c
> +++ b/src/compiler/nir/nir_lower_io.c
> @@ -274,6 +274,10 @@ nir_lower_io_block(nir_block *block,
>  
>           nir_intrinsic_set_base(load,
>              intrin->variables[0]->var->data.driver_location);
> +         if (mode == nir_var_shader_in) {

If you add load_output support, then this would need to be

   if (mode == nir_var_shader_in || mode == nir_var_shader_out)

With that changed, patches 1-3 are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

> +            nir_intrinsic_set_component(load,
> +               intrin->variables[0]->var->data.location_frac);
> +         }
>  
>           if (load->intrinsic == nir_intrinsic_load_uniform) {
>              nir_intrinsic_set_range(load,
> @@ -322,6 +326,10 @@ nir_lower_io_block(nir_block *block,
>  
>           nir_intrinsic_set_base(store,
>              intrin->variables[0]->var->data.driver_location);
> +         if (mode == nir_var_shader_out) {
> +            nir_intrinsic_set_component(store,
> +               intrin->variables[0]->var->data.location_frac);
> +         }
>           nir_intrinsic_set_write_mask(store, nir_intrinsic_write_mask(intrin));
>  
>           if (per_vertex)
> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
> index 36176ec..bca8a35 100644
> --- a/src/compiler/nir/nir_print.c
> +++ b/src/compiler/nir/nir_print.c
> @@ -570,6 +570,7 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
>        [NIR_INTRINSIC_RANGE] = "range",
>        [NIR_INTRINSIC_DESC_SET] = "desc-set",
>        [NIR_INTRINSIC_BINDING] = "binding",
> +      [NIR_INTRINSIC_COMPONENT] = "component",
>     };
>     for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
>        if (!info->index_map[idx])
> @@ -614,6 +615,8 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
>  
>     nir_foreach_variable(var, var_list) {
>        if ((var->data.driver_location == nir_intrinsic_base(instr)) &&
> +          (instr->intrinsic == nir_intrinsic_load_uniform ||
> +           var->data.location_frac == nir_intrinsic_component(instr)) &&
>            var->name) {
>           fprintf(fp, "\t/* %s */", var->name);
>           break;
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160611/b1a3d512/attachment-0001.sig>


More information about the mesa-dev mailing list