Vulkan: make PNextChainBuilder require pNext==nullptr
This will hopefully help catch issues early when people forget to set pNext before creating the PNextChainBuilder. Bug: dawn:1223 Change-Id: Ic6b9704aeaa20731e4f7de4d1ac0207d4110c720 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71762 Reviewed-by: Loko Kung <lokokung@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
cebe8c340a
commit
3b7e75865c
|
@ -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.
|
||||
|
|
|
@ -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 <typename VK_STRUCT_TYPE>
|
||||
explicit PNextChainBuilder(VK_STRUCT_TYPE* head)
|
||||
: mCurrent(reinterpret_cast<VkBaseOutStructure*>(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
|
||||
|
|
|
@ -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]) {
|
||||
|
|
Loading…
Reference in New Issue