diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index 791818c967..de7c8d422a 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -320,6 +320,7 @@ namespace dawn_native { namespace vulkan { // if HasExt(DeviceExt::GetPhysicalDeviceProperties2) is true. VkPhysicalDeviceFeatures2 features2 = {}; features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + features2.pNext = nullptr; PNextChainBuilder featuresChain(&features2); // Required for core WebGPU features. diff --git a/src/dawn_native/vulkan/UtilsVulkan.h b/src/dawn_native/vulkan/UtilsVulkan.h index 53b6d41e26..7b7ead5d5d 100644 --- a/src/dawn_native/vulkan/UtilsVulkan.h +++ b/src/dawn_native/vulkan/UtilsVulkan.h @@ -30,16 +30,14 @@ namespace dawn_native { namespace vulkan { // A Helper type used to build a pNext chain of extension structs. // Usage is: - // 1) Create instance, passing the address of the first struct in the - // chain. This will parse the existing |pNext| chain in it to find - // its tail. + // 1) Create instance, passing the address of the first struct in the chain. This requires + // pNext to be nullptr. If you already have a chain you need to pass a pointer to the tail + // of it. // - // 2) Call Add(&vk_struct) every time a new struct needs to be appended - // to the chain. + // 2) Call Add(&vk_struct) every time a new struct needs to be appended to the chain. // - // 3) Alternatively, call Add(&vk_struct, VK_STRUCTURE_TYPE_XXX) to - // initialize the struct with a given VkStructureType value while - // appending it to the chain. + // 3) Alternatively, call Add(&vk_struct, VK_STRUCTURE_TYPE_XXX) to initialize the struct + // with a given VkStructureType value while appending it to the chain. // // Examples: // VkPhysicalFeatures2 features2 = { @@ -61,10 +59,7 @@ namespace dawn_native { namespace vulkan { template explicit PNextChainBuilder(VK_STRUCT_TYPE* head) : mCurrent(reinterpret_cast(head)) { - // Find the end of the current chain. - while (mCurrent->pNext != nullptr) { - mCurrent = mCurrent->pNext; - } + ASSERT(head->pNext == nullptr); } // Add one item to the chain. |vk_struct| must be a Vulkan structure diff --git a/src/dawn_native/vulkan/VulkanInfo.cpp b/src/dawn_native/vulkan/VulkanInfo.cpp index a053df18a4..4b0159f38b 100644 --- a/src/dawn_native/vulkan/VulkanInfo.cpp +++ b/src/dawn_native/vulkan/VulkanInfo.cpp @@ -219,10 +219,12 @@ namespace dawn_native { namespace vulkan { // because these extensions (transitively) depend on it in `EnsureDependencies` VkPhysicalDeviceFeatures2 features2 = {}; features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + features2.pNext = nullptr; PNextChainBuilder featuresChain(&features2); VkPhysicalDeviceProperties2 properties2 = {}; properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; + features2.pNext = nullptr; PNextChainBuilder propertiesChain(&properties2); if (info.extensions[DeviceExt::ShaderFloat16Int8]) {