From: Jason Ekstrand Date: Fri, 20 Nov 2015 23:15:38 +0000 (-0800) Subject: nir/spirv: Rework decoration iteration X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1157b0360d9978028685dd78fa77871d5172c628;p=mesa.git nir/spirv: Rework decoration iteration The old code didn't work correctly if you had member decorations after non-member decorations. Since glslang never gave us any of those, it wasn't properly tested. --- diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index ba49b04a54e..70610ca0f66 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -186,24 +186,25 @@ vtn_handle_extension(struct vtn_builder *b, SpvOp opcode, static void _foreach_decoration_helper(struct vtn_builder *b, struct vtn_value *base_value, - int member, + int parent_member, struct vtn_value *value, vtn_decoration_foreach_cb cb, void *data) { - int new_member = member; - for (struct vtn_decoration *dec = value->decoration; dec; dec = dec->next) { - if (dec->member >= 0) { - assert(member == -1); - new_member = dec->member; + int member; + if (dec->member < 0) { + member = parent_member; + } else { + assert(parent_member == -1); + member = dec->member; } if (dec->group) { assert(dec->group->value_type == vtn_value_type_decoration_group); - _foreach_decoration_helper(b, base_value, new_member, dec->group, + _foreach_decoration_helper(b, base_value, member, dec->group, cb, data); } else { - cb(b, base_value, new_member, dec, data); + cb(b, base_value, member, dec, data); } } }