vulkan-zig icon indicating copy to clipboard operation
vulkan-zig copied to clipboard

`freeDescriptorSets` returns an error union

Open andrewrk opened this issue 1 year ago • 2 comments

        pub fn freeDescriptorSets(
            self: Self,
            device: Device,
            descriptor_pool: DescriptorPool,
            descriptor_set_count: u32,
            p_descriptor_sets: [*]const DescriptorSet,
        ) FreeDescriptorSetsError!void {
            const result = self.dispatch.vkFreeDescriptorSets(
                device,
                descriptor_pool,
                descriptor_set_count,
                p_descriptor_sets,
            );
            switch (result) {
                Result.success => {},
                else => return error.Unknown,
            }
        }

really? can something go wrong when freeing these?

edit: question remains, but I remembered that these are allocated out of a pool so it's uncommon to need to free them individually.

andrewrk avatar Sep 30 '24 07:09 andrewrk

I've seen drivers return VK_ERROR_UNKNOWN from random places, so all functions also return this error. I would suggest to just assert that there is no write instead of handling it. Maybe it would sense to do that at a library level? It said clean up some of these things, what do you think?

Snektron avatar Sep 30 '24 08:09 Snektron

A future extension could add a possible error code (e.g. some of the "maintenance" extensions modify existing functions like this), and given that it returns a VkResult, Khronos might think it's a possibility. Although encountering the "unknown" case is a bit contrived as the user would need to have enabled the extension by name but be using an old version of the bindings that doesn't support that extension (i.e. they would not be able to use its functions).

EDIT: Also in this case where an error result is added later, if freeDescriptorSets() currently returned void then that would be a breaking change, even if you're not using that extension.

poconn avatar Sep 30 '24 17:09 poconn