Vulkan: Fix FindBestType logic for device-local preference.

Previously when comparing a "bestType" that's device-local with a
"current" that's non-device-local, the logic to favor device-local
memory would be skipped and the types compared on their size. This lead
to incorrect memory types selection on some configurations (where the
small device local heap was selected).

Bug: dawn:659
Change-Id: Ie764815082ebeef845b70077fe630df05bcdb92b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/39500
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez 2021-06-22 14:59:26 +00:00 committed by Dawn LUCI CQ
parent 61b40d2c50
commit 7149c017b6
1 changed files with 7 additions and 6 deletions

View File

@ -259,14 +259,15 @@ namespace dawn_native { namespace vulkan {
}
// For non-mappable resources, favor device local memory.
if (!mappable) {
if ((info.memoryTypes[bestType].propertyFlags &
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == 0 &&
(info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) !=
0) {
bool currentDeviceLocal =
info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
bool bestDeviceLocal =
info.memoryTypes[bestType].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
if (!mappable && (currentDeviceLocal != bestDeviceLocal)) {
if (currentDeviceLocal) {
bestType = static_cast<int>(i);
continue;
}
continue;
}
// All things equal favor the memory in the biggest heap