[Mesa-dev] [PATCH 1/2] spirv: handle OpUndef as part of the variable parsing pass

Jason Ekstrand jason at jlekstrand.net
Thu Jan 26 17:22:40 UTC 2017


Thanks!

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

Please cc stable for both patches.
--Jason

On Thu, Jan 26, 2017 at 9:08 AM, Lionel Landwerlin <
lionel.g.landwerlin at intel.com> wrote:

> Looking at the following bit of SPIRV shader :
>
> ...
> %zero        = OpConstant %i32 0
> %ivec3_0     = OpConstantComposite %ivec3 %zero %zero %zero
> %vec3_undef  = OpUndef %ivec3
> %sc_0        = OpSpecConstant %i32 0
> %sc_1        = OpSpecConstant %i32 0
> %sc_2        = OpSpecConstant %i32 0
> ...
>
> Our compiler currently stops parsing variables & types on the OpUndef
> and switches to instructions, leaving the following sc_[0-2] variables
> untreated.
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> ---
>  src/compiler/spirv/spirv_to_nir.c  | 1 +
>  src/compiler/spirv/vtn_variables.c | 6 ++++++
>  2 files changed, 7 insertions(+)
>
> diff --git a/src/compiler/spirv/spirv_to_nir.c
> b/src/compiler/spirv/spirv_to_nir.c
> index 261be65e9f..2d773b4373 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -2923,6 +2923,7 @@ vtn_handle_variable_or_type_instruction(struct
> vtn_builder *b, SpvOp opcode,
>        vtn_handle_constant(b, opcode, w, count);
>        break;
>
> +   case SpvOpUndef:
>     case SpvOpVariable:
>        vtn_handle_variables(b, opcode, w, count);
>        break;
> diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_
> variables.c
> index b6c36f3d6a..098cfb5de7 100644
> --- a/src/compiler/spirv/vtn_variables.c
> +++ b/src/compiler/spirv/vtn_variables.c
> @@ -1287,6 +1287,12 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp
> opcode,
>                       const uint32_t *w, unsigned count)
>  {
>     switch (opcode) {
> +   case SpvOpUndef: {
> +      struct vtn_value *val = vtn_push_value(b, w[2],
> vtn_value_type_undef);
> +      val->type = vtn_value(b, w[1], vtn_value_type_type)->type;
> +      break;
> +   }
> +
>     case SpvOpVariable: {
>        struct vtn_variable *var = rzalloc(b, struct vtn_variable);
>        var->type = vtn_value(b, w[1], vtn_value_type_type)->type;
> --
> 2.11.0
>
> _______________________________________________
> 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/20170126/3057f686/attachment.html>


More information about the mesa-dev mailing list