Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move destroyInstance to Base level #167

Open
vkensou opened this issue Oct 23, 2024 · 4 comments
Open

Move destroyInstance to Base level #167

vkensou opened this issue Oct 23, 2024 · 4 comments

Comments

@vkensou
Copy link

vkensou commented Oct 23, 2024

Suggestion move destroyInstance to Base level, move destroyDevice to Instance level

const instance_handle = try vkb.createInstance(&create_info, null);
// If load Instance proc failed, no chance to destroy instance
const vki = try proc.loadInstance(instance_handle, vkb.dispatch.vkGetInstanceProcAddr);
errdefer vki.destroyInstance(instance_handle, null);

destroyDevice is the same

const device_handle = try self.vki.createDevice(self.physical_devices[0], &p_create_info, null);
// If load Device proc failed, no chance to destroy device
const vkd = try proc.loadDevice(device_handle, vki.dispatch.vkGetDeviceProcAddr);
errdefer vkd.destroyDevice(device_handle, null);
@Snektron
Copy link
Owner

Yes this annoying, but it does make sense: the instance destructor is specific to one type of instance, so it's depended on the load. To be clear, this is a Vulkan thing and not something that I can really change.

If you want to deal with it, you can catch and use a dedicated wrapper that only had the destroy function. If that also fails youre out of luck i guess. Personally i suggest to leak it: the OS will clean things up for you anyway.

@vkensou
Copy link
Author

vkensou commented Oct 24, 2024

Yes this annoying, but it does make sense: the instance destructor is specific to one type of instance, so it's depended on the load. To be clear, this is a Vulkan thing and not something that I can really change.

If you want to deal with it, you can catch and use a dedicated wrapper that only had the destroy function. If that also fails youre out of luck i guess. Personally i suggest to leak it: the OS will clean things up for you anyway.

I was mistaken. Perhaps we can add a load function without errors to avoid this situation.

@Snektron
Copy link
Owner

There's a loadNoFail i think

@vkensou vkensou closed this as completed Oct 27, 2024
@vkensou
Copy link
Author

vkensou commented Oct 27, 2024

There's a loadNoFail i think

If use loadNoFil, how do we check a function valid?
if (vki.dispatch.vkGetPhysicalDeviceProperties2KHR != undefined) is useless.

Sometimes, the diver is strange, a extension is valid, but related function is invalid, so I must check the function is valid manually.

@vkensou vkensou reopened this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants