Skip to content

Commit 1f67c9f

Browse files
committed
Features and Partial Binding
1 parent 1daf5f9 commit 1f67c9f

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

wgpu-hal/src/metal/adapter.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -905,18 +905,10 @@ impl super::PrivateCapabilities {
905905
features.set(
906906
F::TEXTURE_BINDING_ARRAY
907907
| F::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING
908-
| F::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
909-
self.msl_version >= MTLLanguageVersion::V2_0 && self.supports_arrays_of_textures,
908+
| F::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
909+
| F::PARTIALLY_BOUND_BINDING_ARRAY,
910+
self.msl_version >= MTLLanguageVersion::V3_0 && self.supports_arrays_of_textures,
910911
);
911-
//// XXX: this is technically not true, as read-only storage images can be used in arrays
912-
//// on precisely the same conditions that sampled textures can. But texel fetch from a
913-
//// sampled texture is a thing; should we bother introducing another feature flag?
914-
if self.msl_version >= MTLLanguageVersion::V2_2
915-
&& self.supports_arrays_of_textures
916-
&& self.supports_arrays_of_textures_write
917-
{
918-
features.insert(F::STORAGE_RESOURCE_BINDING_ARRAY);
919-
}
920912
features.set(
921913
F::SHADER_INT64,
922914
self.int64 && self.msl_version >= MTLLanguageVersion::V2_3,

wgpu-hal/src/metal/device.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ impl crate::Device for super::Device {
564564
if let Some(label) = desc.label {
565565
descriptor.set_label(label);
566566
}
567+
if self.features.contains(wgt::Features::TEXTURE_BINDING_ARRAY) {
568+
descriptor.set_support_argument_buffers(true);
569+
}
567570
let raw = self.shared.device.lock().new_sampler(&descriptor);
568571

569572
self.counters.samplers.add(1);
@@ -810,8 +813,8 @@ impl crate::Device for super::Device {
810813
});
811814
for (entry, layout) in layout_and_entry_iter {
812815
// Bindless path
813-
if let Some(count) = layout.count {
814-
let count = count.get();
816+
if layout.count.is_some() {
817+
let count = entry.count;
815818

816819
let stages = conv::map_render_stages(layout.visibility);
817820
let uses = conv::map_resource_usage(&layout.ty);
@@ -823,7 +826,9 @@ impl crate::Device for super::Device {
823826
| metal::MTLResourceOptions::StorageModeShared,
824827
);
825828

826-
let contents: *mut metal::MTLResourceID = buffer.contents().cast();
829+
let contents: &mut [metal::MTLResourceID] = unsafe {
830+
std::slice::from_raw_parts_mut(buffer.contents().cast(), count as usize)
831+
};
827832

828833
match layout.ty {
829834
wgt::BindingType::Texture { .. }
@@ -833,9 +838,7 @@ impl crate::Device for super::Device {
833838
let textures = &desc.textures[start..end];
834839

835840
for (idx, tex) in textures.iter().enumerate() {
836-
unsafe {
837-
contents.add(idx).write(tex.view.raw.gpu_resource_id())
838-
}
841+
contents[idx] = tex.view.raw.gpu_resource_id();
839842

840843
let use_info = bg
841844
.resources_to_use
@@ -852,13 +855,8 @@ impl crate::Device for super::Device {
852855
let end = start + count as usize;
853856
let samplers = &desc.samplers[start..end];
854857

855-
dbg!(samplers);
856-
857858
for (idx, &sampler) in samplers.iter().enumerate() {
858-
dbg!(sampler);
859-
unsafe {
860-
contents.add(idx).write(dbg!(sampler.raw.gpu_resource_id()))
861-
}
859+
contents[idx] = sampler.raw.gpu_resource_id();
862860
// Samplers aren't resources like buffers and textures, so don't
863861
// need to be passed to useResource
864862
}

0 commit comments

Comments
 (0)