KhronosGroup / KhronosGroup/Vulkan-Docs

Fundamentals, Object Lifetime should mention non-parent–child relationships object destruction order

Open
#2,656 3 comments 0 reactions 1 assignee Claimed by @oddhack View on GitHub
Dominant language
JavaScript
Stars
3.3k
Forks
549
Avg merge
5d 5h
Merged PRs (30d)
2

Description

Fundamentals, Object Lifetime reads:

> Applications can free or destroy objects in any order, except that parent objects must be freed only after all child objects are freed. An object is the parent of another child object if the parent was used as the first object parameter in the creation of the child.

A reader may now conclude that they do not need to worry about destruction order, except for the parent–child relationship. For example, they may conclude that they may destroy an image before destroying an image view created from the image, as the parent–child relationships are device–image and device–image-view.

But there is another exception to the "any order" permission, through Fundamentals, Valid Usage for Object Handles:

> Any input parameter to a command that is an object handle must be a valid object handle, unless otherwise specified. An object handle is valid if:
>
> - Any objects used by that object, either as part of creation or execution, must also be valid.

together with `VUID-vkDestroyFooBar-fooBar-parameter`, such as for image views:

> `VUID-vkDestroyImageView-imageView-parameter`
> If `imageView` is not `VK_NULL_HANDLE`, `imageView` must be a valid `VkImageView` handle

As such, Fundamentals, Object Lifetime should not suggest _any order_ is allowed, because it is not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.