Vulkan: Fix texture barriers for readonly storage.

One of the helper methods to compute texture barriers didn't handle the
kReadOnlyStorage usage, which made barriers issued too small.

Issue was caught by running
StorageTextureZeroInitTests.ReadonlyStorageTextureClearsToZeroInRenderPass
with the Vulkan barrier validation enabled.

Also renames kReadonlyStorageTexture to kReadOnlyStorageTexture for
consistency.

Bug: dawn:635
Change-Id: I6e6027c380672dcdaea789c811665536b446003e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38101
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2021-01-20 19:39:28 +00:00 committed by Commit Bot service account
parent 40422659d4
commit 25dc10cee7
8 changed files with 13 additions and 10 deletions

View File

@ -63,7 +63,7 @@ namespace dawn_native {
TextureViewBase* view = group->GetBindingAsTextureView(bindingIndex);
switch (bindingInfo.storageTexture.access) {
case wgpu::StorageTextureAccess::ReadOnly:
usageTracker->TextureViewUsedAs(view, kReadonlyStorageTexture);
usageTracker->TextureViewUsedAs(view, kReadOnlyStorageTexture);
break;
case wgpu::StorageTextureAccess::WriteOnly:
usageTracker->TextureViewUsedAs(view, wgpu::TextureUsage::Storage);

View File

@ -365,7 +365,7 @@ namespace dawn_native {
// Add readonly storage usage if the texture has a storage usage. The validation rules in
// ValidatePassResourceUsage will make sure we don't use both at the same time.
if (mUsage & wgpu::TextureUsage::Storage) {
mUsage |= kReadonlyStorageTexture;
mUsage |= kReadOnlyStorageTexture;
}
}

View File

@ -39,7 +39,7 @@ namespace dawn_native {
bool IsValidSampleCount(uint32_t sampleCount);
static constexpr wgpu::TextureUsage kReadOnlyTextureUsages =
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::Sampled | kReadonlyStorageTexture;
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::Sampled | kReadOnlyStorageTexture;
static constexpr wgpu::TextureUsage kWritableTextureUsages =
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Storage |

View File

@ -280,7 +280,7 @@ namespace dawn_native { namespace d3d12 {
wgpu::TextureUsage usage;
switch (bindingInfo.storageTexture.access) {
case wgpu::StorageTextureAccess::ReadOnly:
usage = kReadonlyStorageTexture;
usage = kReadOnlyStorageTexture;
break;
case wgpu::StorageTextureAccess::WriteOnly:
usage = wgpu::TextureUsage::Storage;

View File

@ -49,7 +49,7 @@ namespace dawn_native { namespace d3d12 {
if (usage & wgpu::TextureUsage::CopyDst) {
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
}
if (usage & (wgpu::TextureUsage::Sampled | kReadonlyStorageTexture)) {
if (usage & (wgpu::TextureUsage::Sampled | kReadOnlyStorageTexture)) {
resourceState |= (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE |
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
}

View File

@ -27,7 +27,7 @@ namespace dawn_native {
// (readonly storage texture usage) for render pass resource tracking
static constexpr wgpu::BufferUsage kReadOnlyStorageBuffer =
static_cast<wgpu::BufferUsage>(0x80000000);
static constexpr wgpu::TextureUsage kReadonlyStorageTexture =
static constexpr wgpu::TextureUsage kReadOnlyStorageTexture =
static_cast<wgpu::TextureUsage>(0x80000000);
// Add an extra texture usage for textures that will be presented, for use in backends

View File

@ -71,6 +71,9 @@ namespace dawn_native { namespace vulkan {
if (usage & wgpu::TextureUsage::Storage) {
flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
}
if (usage & kReadOnlyStorageTexture) {
flags |= VK_ACCESS_SHADER_READ_BIT;
}
if (usage & wgpu::TextureUsage::RenderAttachment) {
if (format.HasDepthOrStencil()) {
flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
@ -128,7 +131,7 @@ namespace dawn_native { namespace vulkan {
// and store operations on storage images can only be done on the images in
// VK_IMAGE_LAYOUT_GENERAL layout.
case wgpu::TextureUsage::Storage:
case kReadonlyStorageTexture:
case kReadOnlyStorageTexture:
return VK_IMAGE_LAYOUT_GENERAL;
case wgpu::TextureUsage::RenderAttachment:
if (format.HasDepthOrStencil()) {
@ -156,7 +159,7 @@ namespace dawn_native { namespace vulkan {
if (usage & (wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst)) {
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
}
if (usage & (wgpu::TextureUsage::Sampled | kReadonlyStorageTexture)) {
if (usage & (wgpu::TextureUsage::Sampled | kReadOnlyStorageTexture)) {
// TODO(cwallez@chromium.org): Only transition to the usage we care about to avoid
// introducing FS -> VS dependencies that would prevent parallelization on tiler
// GPUs
@ -392,7 +395,7 @@ namespace dawn_native { namespace vulkan {
if (usage & wgpu::TextureUsage::Sampled) {
flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
}
if (usage & wgpu::TextureUsage::Storage) {
if (usage & (wgpu::TextureUsage::Storage | kReadOnlyStorageTexture)) {
flags |= VK_IMAGE_USAGE_STORAGE_BIT;
}
if (usage & wgpu::TextureUsage::RenderAttachment) {

View File

@ -38,7 +38,7 @@ TEST_P(InternalResourceUsageTests, InternalTextureUsage) {
wgpu::TextureDescriptor descriptor;
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
descriptor.size = {1, 1, 1};
descriptor.usage = dawn_native::kReadonlyStorageTexture;
descriptor.usage = dawn_native::kReadOnlyStorageTexture;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}