From 457c25e94adc47aa29e1e2349c2452bca3acac83 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:56:02 +0100 Subject: [PATCH] remove `BufferUses::STORAGE_WRITE_ONLY`, reverting part of 0b6571a The spec doesn't have write-only storage buffers. --- wgpu-core/src/conv.rs | 2 +- wgpu-core/src/device/resource.rs | 11 +---------- wgpu-hal/src/dx12/conv.rs | 2 +- wgpu-hal/src/gles/queue.rs | 4 +--- wgpu-hal/src/lib.rs | 2 -- wgpu-hal/src/vulkan/conv.rs | 18 ++++++------------ 6 files changed, 10 insertions(+), 29 deletions(-) diff --git a/wgpu-core/src/conv.rs b/wgpu-core/src/conv.rs index b114e9826e..dbf3adb2a6 100644 --- a/wgpu-core/src/conv.rs +++ b/wgpu-core/src/conv.rs @@ -82,7 +82,7 @@ pub fn map_buffer_usage(usage: wgt::BufferUsages) -> hal::BufferUses { usage.contains(wgt::BufferUsages::UNIFORM), ); u.set( - hal::BufferUses::STORAGE_READ_WRITE, + hal::BufferUses::STORAGE_READ_ONLY | hal::BufferUses::STORAGE_READ_WRITE, usage.contains(wgt::BufferUsages::STORAGE), ); u.set( diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index cf5ed7038b..403ced5263 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -521,16 +521,7 @@ impl Device { self.require_downlevel_flags(wgt::DownlevelFlags::INDIRECT_EXECUTION)?; // We are going to be reading from it, internally; // when validating the content of the buffer - if !usage.intersects( - hal::BufferUses::STORAGE_READ_ONLY | hal::BufferUses::STORAGE_READ_WRITE, - ) { - if usage.contains(hal::BufferUses::STORAGE_WRITE_ONLY) { - usage |= hal::BufferUses::STORAGE_READ_WRITE; - usage &= !hal::BufferUses::STORAGE_WRITE_ONLY; - } else { - usage |= hal::BufferUses::STORAGE_READ_ONLY; - } - } + usage |= hal::BufferUses::STORAGE_READ_ONLY | hal::BufferUses::STORAGE_READ_WRITE; } if desc.mapped_at_creation { diff --git a/wgpu-hal/src/dx12/conv.rs b/wgpu-hal/src/dx12/conv.rs index 70ba83fa42..4d597af1db 100644 --- a/wgpu-hal/src/dx12/conv.rs +++ b/wgpu-hal/src/dx12/conv.rs @@ -128,7 +128,7 @@ pub fn map_buffer_usage_to_state(usage: crate::BufferUses) -> Direct3D12::D3D12_ if usage.intersects(Bu::VERTEX | Bu::UNIFORM) { state |= Direct3D12::D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER; } - if usage.intersects(Bu::STORAGE_READ_WRITE | Bu::STORAGE_WRITE_ONLY) { + if usage.intersects(Bu::STORAGE_READ_WRITE) { state |= Direct3D12::D3D12_RESOURCE_STATE_UNORDERED_ACCESS; } else if usage.intersects(Bu::STORAGE_READ_ONLY) { state |= Direct3D12::D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 892e854b52..8896aa4ed0 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -1225,9 +1225,7 @@ impl super::Queue { flags |= glow::BUFFER_UPDATE_BARRIER_BIT; } if usage.intersects( - crate::BufferUses::STORAGE_READ_ONLY - | crate::BufferUses::STORAGE_WRITE_ONLY - | crate::BufferUses::STORAGE_READ_WRITE, + crate::BufferUses::STORAGE_READ_ONLY | crate::BufferUses::STORAGE_READ_WRITE, ) { flags |= glow::SHADER_STORAGE_BARRIER_BIT; } diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index d989f6dc7e..a398f079a7 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -1675,8 +1675,6 @@ bitflags::bitflags! { const UNIFORM = 1 << 6; /// A read-only storage buffer used in a bind group. const STORAGE_READ_ONLY = 1 << 7; - /// A write-only storage buffer used in a bind group. - const STORAGE_WRITE_ONLY = 1 << 8; /// A read-write buffer used in a bind group. const STORAGE_READ_WRITE = 1 << 8; /// The indirect or count buffer in a indirect draw or dispatch. diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index ce4aa410bf..05a06011d8 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -515,11 +515,9 @@ pub fn map_buffer_usage(usage: crate::BufferUses) -> vk::BufferUsageFlags { if usage.contains(crate::BufferUses::UNIFORM) { flags |= vk::BufferUsageFlags::UNIFORM_BUFFER; } - if usage.intersects( - crate::BufferUses::STORAGE_READ_ONLY - | crate::BufferUses::STORAGE_WRITE_ONLY - | crate::BufferUses::STORAGE_READ_WRITE, - ) { + if usage + .intersects(crate::BufferUses::STORAGE_READ_ONLY | crate::BufferUses::STORAGE_READ_WRITE) + { flags |= vk::BufferUsageFlags::STORAGE_BUFFER; } if usage.contains(crate::BufferUses::INDEX) { @@ -573,17 +571,13 @@ pub fn map_buffer_usage_to_barrier( stages |= shader_stages; access |= vk::AccessFlags::UNIFORM_READ; } - if usage - .intersects(crate::BufferUses::STORAGE_READ_ONLY | crate::BufferUses::STORAGE_READ_WRITE) - { + if usage.intersects(crate::BufferUses::STORAGE_READ_ONLY) { stages |= shader_stages; access |= vk::AccessFlags::SHADER_READ; } - if usage - .intersects(crate::BufferUses::STORAGE_WRITE_ONLY | crate::BufferUses::STORAGE_READ_WRITE) - { + if usage.intersects(crate::BufferUses::STORAGE_READ_WRITE) { stages |= shader_stages; - access |= vk::AccessFlags::SHADER_WRITE; + access |= vk::AccessFlags::SHADER_READ | vk::AccessFlags::SHADER_WRITE; } if usage.contains(crate::BufferUses::INDEX) { stages |= vk::PipelineStageFlags::VERTEX_INPUT;