1---2name: vulkan-extension-detection3description: Add extension usage detection4---561. Check that we were told which Vulkan extension we are supposed to check. If this was not specified, ask.72. Download the extension text from `https://docs.vulkan.org/refpages/latest/refpages/source/<extension name>.html` and read it.83. If you cannot download the extension text due to sandbox permission issues, ask user to add the following to their `~/.codex/config.toml`:9```10[network]11enable_domain_allowlist = true12domain_allowlist = [13 "docs.vulkan.org",14 "github.com",15 "api.github.com"16]17```184. Our usage detection code is in `src/usagetracker/vulkan_feature_detect.cpp` and `src/usagetracker/vulkan_feature_detect.h`.19 There is a test for it at `src/vulkan_feature.cpp`.205. Consider whether it is possible at all for us to detect whether the extension is actually being used. It has to express its21 functionality through commands, structures and SPIRV capabilities for us to actually detect it. We do not track state or22 maintain internal bookkeeping and we cannot add this. If we cannot detect its usage with these limitations, stop and inform23 the user.246. Add our extension to the `feature_detection` struct in the header, like this:25```cpp26 std::atomic_bool has_<name of extension> { false };27```287. If the extension has a feature enablement struct (typically named `VK_STRUCTURE_TYPE_<something>_FEATURES`), then we need29 to make a decision: Do we need to check this feature struct to determine if the extension is used or will we have sufficient30 evidence without it? If we need to check it, then add this check to `check_vkCreateDevice` and count it as used if its feature31 bit is set. If we can do without it, then do not add this check there and we instead allow `check_prune_device` to later remove32 the feature struct of unused extensions. Inform the user of the decision you make here.33 - Usually a feature struct has a main bit that gates access to all other features. If so, we only need to check this one.348. Add support for our extension to `adjust_device_extensions` if it is a device extension, or `adjust_instance_extensions` if35 it is an instance extension. If we have a feature enable struct in our extension, then we should add a removal of it also36 to `adjust_VkDeviceCreateInfo` (if device extension) or to `adjust_VkInstanceCreateInfo` (if instance extension).379. Make sure each new Vulkan command and command using any new struct defined in the given extension are checked in our detection38 code. If not, add them. If the extension adds new SPIRV capabilities, also check that in `parse_SPIRV`. If any of our new39 Vulkan commands or structs or SPIRV capabilities are used, we must flag the extension as in use.4010. If it is safe to do so, we should not consider command variants that have been promoted to core as using the extension -41 they would be using the relevant core version or core feature instead, which is out of scope here.4211. Err on the side of caution - if we cannot tell for sure whether an extension is being used in some way or not, then we should43 assume it is being used. If this caution means we always assume it is used, then this detection is pointless so stop and44 inform the user of the problem.4512. Add a quick test for our extension to `src/vulkan_feature.cpp`. Compile and test that it all works fine.