Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ By @SupaMaggie70Incorporated in [#8206](https://github.com/gfx-rs/wgpu/pull/8206

- Added support for transient textures on Vulkan and Metal. By @opstic in [#8247](https://github.com/gfx-rs/wgpu/pull/8247)
- Implement shader triangle barycentric coordinate builtins. By @atlv24 in [#8320](https://github.com/gfx-rs/wgpu/pull/8320).
- Added support for binding arrays of storage buffers and storage textures on Metal. By @msvbg in [#8464](https://github.com/gfx-rs/wgpu/pull/8464)

### Changes

Expand Down
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ which = "8"
xshell = "0.2.2"

# Metal dependencies
metal = "0.32"
metal = { git = "https://github.com/msvbg/metal-rs", branch = "gpu_resource_id_for_buffer" }
block = "0.1.6"
core-graphics-types = "0.2"
objc = "0.2.5"
Expand Down
8 changes: 5 additions & 3 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7099,9 +7099,11 @@ template <typename A>
}
}
crate::ImageClass::Storage { .. } => {
return Err(Error::UnsupportedArrayOf(
"read-write textures".to_string(),
));
if options.lang_version < (3, 0) {
return Err(Error::UnsupportedArrayOf(
"read-write textures".to_string(),
));
}
}
crate::ImageClass::External => {
return Err(Error::UnsupportedArrayOf(
Expand Down
7 changes: 7 additions & 0 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,13 @@ impl super::PrivateCapabilities {
&& self.supports_arrays_of_textures
&& self.argument_buffers as u64 >= MTLArgumentBuffersTier::Tier2 as u64,
);
features.set(
F::STORAGE_RESOURCE_BINDING_ARRAY,
self.msl_version >= MTLLanguageVersion::V3_0
&& self.supports_arrays_of_textures
&& self.supports_arrays_of_textures_write
&& self.argument_buffers as u64 >= MTLArgumentBuffersTier::Tier2 as u64,
);
features.set(
F::SHADER_INT64,
self.int64 && self.msl_version >= MTLLanguageVersion::V2_3,
Expand Down
10 changes: 10 additions & 0 deletions wgpu-hal/src/metal/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ pub fn map_resource_usage(ty: &wgt::BindingType) -> MTLResourceUsage {
MTLResourceUsage::Read | MTLResourceUsage::Write
}
},
wgt::BindingType::Buffer { ty, .. } => match ty {
wgt::BufferBindingType::Uniform => MTLResourceUsage::Read,
wgt::BufferBindingType::Storage { read_only } => {
if *read_only {
MTLResourceUsage::Read
} else {
MTLResourceUsage::Read | MTLResourceUsage::Write
}
}
},
wgt::BindingType::Sampler(..) => MTLResourceUsage::empty(),
_ => unreachable!(),
}
Expand Down
19 changes: 19 additions & 0 deletions wgpu-hal/src/metal/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,25 @@ impl crate::Device for super::Device {
};

match layout.ty {
wgt::BindingType::Buffer { .. } => {
let start = entry.resource_index as usize;
let end = start + count as usize;
let buffers = &desc.buffers[start..end];
let compute_visible =
layout.visibility.contains(wgt::ShaderStages::COMPUTE);

for (idx, buffer_binding) in buffers.iter().enumerate() {
contents[idx] = buffer_binding.buffer.raw.gpu_resource_id();

let use_info = bg
.resources_to_use
.entry(buffer_binding.buffer.as_raw().cast())
.or_default();
use_info.stages |= stages;
use_info.uses |= uses;
use_info.visible_in_compute |= compute_visible;
}
}
wgt::BindingType::Texture { .. }
| wgt::BindingType::StorageTexture { .. } => {
let start = entry.resource_index as usize;
Expand Down
Loading