anv: remove anv_reloc_list->num_relocs
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Mon, 12 Dec 2022 23:04:20 +0000 (15:04 -0800)
committerPaulo Zanoni <paulo.r.zanoni@intel.com>
Wed, 14 Dec 2022 18:44:31 +0000 (10:44 -0800)
commit4168d3ef30bdbb14866d933be9829c2453652304
treea2d8800795a53b024a122df5cc0f359a401ca915
parent4b1c4925e7414365b18bd0b802dd979a77ec2f4f
anv: remove anv_reloc_list->num_relocs

There are only a few places in the code where num_relocs gets set:

  - During anv_reloc_list_init() where it gets memset() to 0.
  - At anv_reloc_list_init_clone() where it gets set with the value of
    another anv_reloc_list->num_relocs.
  - During anv_reloc_list_clear(), where it gets set to 0.
  - During anv_reloc_list_append(), where it gets added with the value
    of another anv_reloc_list->num_relocs.

As you can see, either we explicitly set the value to 0 or we copy the
value that's present in another anv_reloc_list, which should be 0. The
one place where we used to increment num_relocs was in
anv_reloc_list_add(), but that was deleted by:

  7b7381e8d7a5 ("anv: Delete anv_reloc_list_add()")

So in this commit we delete the num_relocs field from struct
anv_reloc_list and we also delete some lines where, if the value is 0,
nothing will happen.

There's more we could be deleting here, but I wanted this commit to be
minimal so it's very clear that num_relocs can't be non-zero. We were
having some speculation that anv_reloc_list may still be important for
actually adding BOs to the batch and building the validation list, so
let's go slowly with the removal to make everything more easily
reviewable.

The one possibility I could be missing here is another situation like
the memset() we have at anv_reloc_list_init() or some other crazy
indirect overwrite, but as far as I have checked, that is not the
case.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20309>
src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_private.h