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.
|
// if HasExt(DeviceExt::GetPhysicalDeviceProperties2) is true.
|
||||||
VkPhysicalDeviceFeatures2 features2 = {};
|
VkPhysicalDeviceFeatures2 features2 = {};
|
||||||
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||||
|
features2.pNext = nullptr;
|
||||||
PNextChainBuilder featuresChain(&features2);
|
PNextChainBuilder featuresChain(&features2);
|
||||||
|
|
||||||
// Required for core WebGPU features.
|
// 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.
|
// A Helper type used to build a pNext chain of extension structs.
|
||||||
// Usage is:
|
// Usage is:
|
||||||
// 1) Create instance, passing the address of the first struct in the
|
// 1) Create instance, passing the address of the first struct in the chain. This requires
|
||||||
// chain. This will parse the existing |pNext| chain in it to find
|
// pNext to be nullptr. If you already have a chain you need to pass a pointer to the tail
|
||||||
// its tail.
|
// of it.
|
||||||
//
|
//
|
||||||
// 2) Call Add(&vk_struct) every time a new struct needs to be appended
|
// 2) Call Add(&vk_struct) every time a new struct needs to be appended to the chain.
|
||||||
// to the chain.
|
|
||||||
//
|
//
|
||||||
// 3) Alternatively, call Add(&vk_struct, VK_STRUCTURE_TYPE_XXX) to
|
// 3) Alternatively, call Add(&vk_struct, VK_STRUCTURE_TYPE_XXX) to initialize the struct
|
||||||
// initialize the struct with a given VkStructureType value while
|
// with a given VkStructureType value while appending it to the chain.
|
||||||
// appending it to the chain.
|
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
// VkPhysicalFeatures2 features2 = {
|
// VkPhysicalFeatures2 features2 = {
|
||||||
|
@ -61,10 +59,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
template <typename VK_STRUCT_TYPE>
|
template <typename VK_STRUCT_TYPE>
|
||||||
explicit PNextChainBuilder(VK_STRUCT_TYPE* head)
|
explicit PNextChainBuilder(VK_STRUCT_TYPE* head)
|
||||||
: mCurrent(reinterpret_cast<VkBaseOutStructure*>(head)) {
|
: mCurrent(reinterpret_cast<VkBaseOutStructure*>(head)) {
|
||||||
// Find the end of the current chain.
|
ASSERT(head->pNext == nullptr);
|
||||||
while (mCurrent->pNext != nullptr) {
|
|
||||||
mCurrent = mCurrent->pNext;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add one item to the chain. |vk_struct| must be a Vulkan structure
|
// 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`
|
// because these extensions (transitively) depend on it in `EnsureDependencies`
|
||||||
VkPhysicalDeviceFeatures2 features2 = {};
|
VkPhysicalDeviceFeatures2 features2 = {};
|
||||||
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||||
|
features2.pNext = nullptr;
|
||||||
PNextChainBuilder featuresChain(&features2);
|
PNextChainBuilder featuresChain(&features2);
|
||||||
|
|
||||||
VkPhysicalDeviceProperties2 properties2 = {};
|
VkPhysicalDeviceProperties2 properties2 = {};
|
||||||
properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
|
properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
|
||||||
|
features2.pNext = nullptr;
|
||||||
PNextChainBuilder propertiesChain(&properties2);
|
PNextChainBuilder propertiesChain(&properties2);
|
||||||
|
|
||||||
if (info.extensions[DeviceExt::ShaderFloat16Int8]) {
|
if (info.extensions[DeviceExt::ShaderFloat16Int8]) {
|
||||||
|
|
Loading…
Reference in New Issue