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:

  7b7381e8d7 ("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>
This commit is contained in:
Paulo Zanoni
2022-12-12 15:04:20 -08:00
parent 4b1c4925e7
commit 4168d3ef30
2 changed files with 4 additions and 35 deletions
+4 -34
View File
@@ -66,22 +66,8 @@ anv_reloc_list_init_clone(struct anv_reloc_list *list,
const VkAllocationCallbacks *alloc,
const struct anv_reloc_list *other_list)
{
list->num_relocs = other_list->num_relocs;
list->array_length = other_list->array_length;
if (list->num_relocs > 0) {
list->reloc_bos =
vk_alloc(alloc, list->array_length * sizeof(*list->reloc_bos), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (list->reloc_bos == NULL)
return vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
memcpy(list->reloc_bos, other_list->reloc_bos,
list->array_length * sizeof(*list->reloc_bos));
} else {
list->reloc_bos = NULL;
}
list->reloc_bos = NULL;
list->dep_words = other_list->dep_words;
if (list->dep_words > 0) {
@@ -110,11 +96,11 @@ anv_reloc_list_grow(struct anv_reloc_list *list,
const VkAllocationCallbacks *alloc,
size_t num_additional_relocs)
{
if (list->num_relocs + num_additional_relocs <= list->array_length)
if (num_additional_relocs <= list->array_length)
return VK_SUCCESS;
size_t new_length = MAX2(16, list->array_length * 2);
while (new_length < list->num_relocs + num_additional_relocs)
while (new_length < num_additional_relocs)
new_length *= 2;
struct anv_bo **new_reloc_bos =
@@ -178,7 +164,6 @@ anv_reloc_list_add_bo(struct anv_reloc_list *list,
static void
anv_reloc_list_clear(struct anv_reloc_list *list)
{
list->num_relocs = 0;
if (list->dep_words > 0)
memset(list->deps, 0, list->dep_words * sizeof(BITSET_WORD));
}
@@ -188,17 +173,10 @@ anv_reloc_list_append(struct anv_reloc_list *list,
const VkAllocationCallbacks *alloc,
struct anv_reloc_list *other)
{
VkResult result = anv_reloc_list_grow(list, alloc, other->num_relocs);
VkResult result = anv_reloc_list_grow(list, alloc, 0);
if (result != VK_SUCCESS)
return result;
if (other->num_relocs > 0) {
memcpy(&list->reloc_bos[list->num_relocs], &other->reloc_bos[0],
other->num_relocs * sizeof(other->reloc_bos[0]));
list->num_relocs += other->num_relocs;
}
anv_reloc_list_grow_deps(list, alloc, other->dep_words);
for (uint32_t w = 0; w < other->dep_words; w++)
list->deps[w] |= other->deps[w];
@@ -1245,14 +1223,6 @@ anv_execbuf_add_bo(struct anv_device *device,
}
if (relocs != NULL) {
for (size_t i = 0; i < relocs->num_relocs; i++) {
VkResult result =
anv_execbuf_add_bo(device, exec, relocs->reloc_bos[i],
NULL, extra_flags);
if (result != VK_SUCCESS)
return result;
}
return anv_execbuf_add_bo_bitset(device, exec, relocs->dep_words,
relocs->deps, extra_flags);
}
-1
View File
@@ -1394,7 +1394,6 @@ void anv_vma_free(struct anv_device *device,
uint64_t address, uint64_t size);
struct anv_reloc_list {
uint32_t num_relocs;
uint32_t array_length;
struct anv_bo ** reloc_bos;
uint32_t dep_words;