Avoid an overflow when computing limits in Vulkan.

Drivers can have UINT32_MAX for maxVertexAttributeInputOffset, leading
to an overflow that puts a 0 in maxVertexBufferArrayStride, and failing
to support WebGPU.

Fixed: dawn:2313
Change-Id: Iffd86c193f1b09d8972adc361606e018d84bfdc6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/167680
Reviewed-by: Loko Kung <lokokung@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
index 3669575..f9e98d0 100644
--- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
+++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
@@ -498,8 +498,11 @@
         vkLimits.maxVertexInputAttributeOffset < baseLimits.v1.maxVertexBufferArrayStride - 1) {
         return DAWN_INTERNAL_ERROR("Insufficient Vulkan limits for maxVertexBufferArrayStride");
     }
+    // Note that some drivers have UINT32_MAX as maxVertexInputAttributeOffset so we do that +1 only
+    // after the std::min.
     limits->v1.maxVertexBufferArrayStride =
-        std::min(vkLimits.maxVertexInputBindingStride, vkLimits.maxVertexInputAttributeOffset + 1);
+        std::min(vkLimits.maxVertexInputBindingStride - 1, vkLimits.maxVertexInputAttributeOffset) +
+        1;
 
     if (vkLimits.maxVertexOutputComponents < baseLimits.v1.maxInterStageShaderComponents ||
         vkLimits.maxFragmentInputComponents < baseLimits.v1.maxInterStageShaderComponents) {