From 4e4ebe87ade76682319fba9263894cc44c617b08 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 19 Jun 2020 16:08:43 +0000 Subject: [PATCH] Vulkan: Simplify PNextChainBuilder Change mTailPtr to mCurrent that's a VkBaseOutStructure*. Bug: dawn:464 Change-Id: Ic10a0abc95e279e1537786601d006cf18305687a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23540 Reviewed-by: Stephen White Reviewed-by: Austin Eng Commit-Queue: Corentin Wallez --- src/dawn_native/vulkan/UtilsVulkan.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/dawn_native/vulkan/UtilsVulkan.h b/src/dawn_native/vulkan/UtilsVulkan.h index 462c08c68c..36ebd34fe6 100644 --- a/src/dawn_native/vulkan/UtilsVulkan.h +++ b/src/dawn_native/vulkan/UtilsVulkan.h @@ -53,10 +53,10 @@ namespace dawn_native { namespace vulkan { // which is why the VkBaseOutStructure* casts below are necessary. template explicit PNextChainBuilder(VK_STRUCT_TYPE* head) - : mTailPtr(&reinterpret_cast(head)->pNext) { + : mCurrent(reinterpret_cast(head)) { // Find the end of the current chain. - while (*mTailPtr) { - mTailPtr = &(*mTailPtr)->pNext; + while (mCurrent->pNext != nullptr) { + mCurrent = mCurrent->pNext; } } @@ -70,8 +70,9 @@ namespace dawn_native { namespace vulkan { offsetof(VK_STRUCT_TYPE, pNext) == offsetof(VkBaseOutStructure, pNext), "Argument type is not a proper Vulkan structure type"); vkStruct->pNext = nullptr; - *mTailPtr = reinterpret_cast(vkStruct); - mTailPtr = &(*mTailPtr)->pNext; + + mCurrent->pNext = reinterpret_cast(vkStruct); + mCurrent = mCurrent->pNext; } // A variant of Add() above that also initializes the |sType| field in |vk_struct|. @@ -82,7 +83,7 @@ namespace dawn_native { namespace vulkan { } private: - VkBaseOutStructure** mTailPtr; + VkBaseOutStructure* mCurrent; }; VkCompareOp ToVulkanCompareOp(wgpu::CompareFunction op);