From bcc65f2d489b728589fc629a3889a2f9bd7d4759 Mon Sep 17 00:00:00 2001 From: Idan Raiter Date: Wed, 1 Jul 2020 21:37:57 +0000 Subject: [PATCH] Vulkan: Enable robust buffer access if validation is on Bug: dawn:480 Change-Id: Id145fab2fe24b70a063c3cc1f75f0a565635abf8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24182 Commit-Queue: Idan Raiter Reviewed-by: Corentin Wallez --- src/dawn_native/Device.cpp | 4 ++++ src/dawn_native/Device.h | 1 + src/dawn_native/Toggles.cpp | 2 ++ src/dawn_native/Toggles.h | 1 + src/dawn_native/vulkan/DeviceVk.cpp | 4 ++++ 5 files changed, 12 insertions(+) diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index adc75fce9b..79c441e566 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -832,6 +832,10 @@ namespace dawn_native { return !IsToggleEnabled(Toggle::SkipValidation); } + bool DeviceBase::IsRobustnessEnabled() const { + return !IsToggleEnabled(Toggle::DisableRobustness); + } + size_t DeviceBase::GetLazyClearCountForTesting() { return mLazyClearCountForTesting; } diff --git a/src/dawn_native/Device.h b/src/dawn_native/Device.h index a513796e14..bcea26ffd7 100644 --- a/src/dawn_native/Device.h +++ b/src/dawn_native/Device.h @@ -216,6 +216,7 @@ namespace dawn_native { bool IsExtensionEnabled(Extension extension) const; bool IsToggleEnabled(Toggle toggle) const; bool IsValidationEnabled() const; + bool IsRobustnessEnabled() const; size_t GetLazyClearCountForTesting(); void IncrementLazyClearCountForTesting(); size_t GetDeprecationWarningCountForTesting(); diff --git a/src/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp index b4ec0db0e3..9eb526a2ec 100644 --- a/src/dawn_native/Toggles.cpp +++ b/src/dawn_native/Toggles.cpp @@ -131,6 +131,8 @@ namespace dawn_native { {Toggle::UseDXC, {"use_dxc", "Use DXC instead of FXC for compiling HLSL", "https://crbug.com/dawn/402"}}, + {Toggle::DisableRobustness, + {"disable_robustness", "Disable robust buffer access", "https://crbug.com/dawn/480"}}, }}; } // anonymous namespace diff --git a/src/dawn_native/Toggles.h b/src/dawn_native/Toggles.h index 18a26a9a63..1e7e3e3b7a 100644 --- a/src/dawn_native/Toggles.h +++ b/src/dawn_native/Toggles.h @@ -42,6 +42,7 @@ namespace dawn_native { DisableBaseInstance, UseD3D12SmallShaderVisibleHeapForTesting, UseDXC, + DisableRobustness, EnumCount, InvalidEnum = EnumCount, diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index 921dd7341c..2415b49bc9 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -299,6 +299,10 @@ namespace dawn_native { namespace vulkan { // Always require fragmentStoresAndAtomics because it is required by end2end tests. usedKnobs.features.fragmentStoresAndAtomics = VK_TRUE; + if (IsRobustnessEnabled()) { + usedKnobs.features.robustBufferAccess = VK_TRUE; + } + if (mDeviceInfo.HasExt(DeviceExt::SubgroupSizeControl)) { ASSERT(usedKnobs.HasExt(DeviceExt::SubgroupSizeControl));