Skip to content

Use Update After Bind Descriptors for Bind Groups With Binding Arrays#6815

Merged
cwfitzgerald merged 4 commits intogfx-rs:trunkfrom
cwfitzgerald:cw/use-update-after-bind-for-binding-arrays
Feb 15, 2025
Merged

Use Update After Bind Descriptors for Bind Groups With Binding Arrays#6815
cwfitzgerald merged 4 commits intogfx-rs:trunkfrom
cwfitzgerald:cw/use-update-after-bind-for-binding-arrays

Conversation

@cwfitzgerald
Copy link
Copy Markdown
Member

@cwfitzgerald cwfitzgerald commented Dec 23, 2024

Closes #6737
Closes #6606

@cwfitzgerald cwfitzgerald requested a review from a team as a code owner December 23, 2024 07:42
@cwfitzgerald

This comment was marked as outdated.

@cwfitzgerald cwfitzgerald marked this pull request as draft December 24, 2024 00:38
@cwfitzgerald cwfitzgerald force-pushed the cw/use-update-after-bind-for-binding-arrays branch 5 times, most recently from 88b1ce1 to 78549c4 Compare January 19, 2025 21:51
@cwfitzgerald cwfitzgerald force-pushed the cw/use-update-after-bind-for-binding-arrays branch from 78549c4 to 56d33e8 Compare January 21, 2025 00:26
@cwfitzgerald cwfitzgerald marked this pull request as ready for review January 21, 2025 00:30
@cwfitzgerald cwfitzgerald requested a review from a team January 21, 2025 00:30
@cwfitzgerald
Copy link
Copy Markdown
Member Author

This PR is a bit of a mess, but I think it's broadly correct and the following PRs will further refine feature specifics. Specifically, we're moving towards two features for bindless, not many. One for "Baseline Bindless" which gets you non-uniform indexing of Storage Textures, Storage Buffers, and Sampled Textures. Then one feature for non-uniform indexing of uniform buffers, if people end up wanting that.

Copy link
Copy Markdown
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused: The new split out UNIFORM_BUFFER_INDEXING feature is never set, thus we never pass the new capability to naga, therefore it should now always reject uniform buffer indexing as its analyzer already correctly distinguishes that now to emit the (new) naga capability as required.

Comment on lines 626 to 658
if let Some(ref descriptor_indexing) = self.descriptor_indexing {
const STORAGE: F = F::STORAGE_RESOURCE_BINDING_ARRAY;
features.set(
F::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
(features.contains(F::TEXTURE_BINDING_ARRAY)
&& descriptor_indexing.shader_sampled_image_array_non_uniform_indexing != 0)
&& (features.contains(F::BUFFER_BINDING_ARRAY | STORAGE)
&& descriptor_indexing.shader_storage_buffer_array_non_uniform_indexing
!= 0),
);
features.set(
F::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
(features.contains(F::BUFFER_BINDING_ARRAY)
&& descriptor_indexing.shader_uniform_buffer_array_non_uniform_indexing != 0)
&& (features.contains(F::TEXTURE_BINDING_ARRAY | STORAGE)
&& descriptor_indexing.shader_storage_image_array_non_uniform_indexing
!= 0),
);
if descriptor_indexing.descriptor_binding_partially_bound != 0 && !intel_windows {
features |= F::PARTIALLY_BOUND_BINDING_ARRAY;
}
// We use update-after-bind descriptors for all bind groups containing binding arrays.
//
// In those bind groups, we allow all binding types except uniform buffers to be present.
//
// As we can only switch between update-after-bind and not on a per bind group basis,
// all supported binding types need to be able to be marked update after bind.
//
// As such, we enable all features as a whole, rather individually.
let supports_descriptor_indexing =
// Sampled Images
descriptor_indexing.shader_sampled_image_array_non_uniform_indexing != 0
&& descriptor_indexing.descriptor_binding_sampled_image_update_after_bind != 0
// Storage Images
&& descriptor_indexing.shader_storage_image_array_non_uniform_indexing != 0
&& descriptor_indexing.descriptor_binding_storage_image_update_after_bind != 0
// Storage Buffers
&& descriptor_indexing.shader_storage_buffer_array_non_uniform_indexing != 0
&& descriptor_indexing.descriptor_binding_storage_buffer_update_after_bind != 0;

let descriptor_indexing_features = F::BUFFER_BINDING_ARRAY
| F::TEXTURE_BINDING_ARRAY
| F::STORAGE_RESOURCE_BINDING_ARRAY
| F::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING
| F::STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING;

features.set(descriptor_indexing_features, supports_descriptor_indexing);

let supports_partially_bound =
descriptor_indexing.descriptor_binding_partially_bound != 0;

features.set(F::PARTIALLY_BOUND_BINDING_ARRAY, supports_partially_bound);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something, but I can't see anywhere where this would set F::UNIFORM_BUFFER_INDEXING. According to the comment block that would be a separate feature that needs to be checked

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a thing I just forgot to mention entirely. Currently it's impossible to use this new feature. The validation added in #6811 mean that such a bind group will always get rejected. I'm going to update the feature description and make an issue to properly implement it.

Copy link
Copy Markdown
Member Author

@cwfitzgerald cwfitzgerald Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the docs and filed #7149

…bind-for-binding-arrays

# Conflicts:
#	deno_webgpu/lib.rs
#	wgpu-types/src/lib.rs
@cwfitzgerald cwfitzgerald requested a review from Wumpf February 15, 2025 05:33
@cwfitzgerald cwfitzgerald merged commit d8833d0 into gfx-rs:trunk Feb 15, 2025
@cwfitzgerald cwfitzgerald deleted the cw/use-update-after-bind-for-binding-arrays branch February 15, 2025 17:35
davnotdev pushed a commit to davnotdev/wgpu that referenced this pull request Mar 4, 2025
…gfx-rs#6815)

* Use Update After Bind Descriptors for Bind Groups With Binding Arrays

Update After Bind

x

* Comments

* Fix URL
sharmajai pushed a commit to sharmajai/wgpu that referenced this pull request Oct 12, 2025
…gfx-rs#6815)

* Use Update After Bind Descriptors for Bind Groups With Binding Arrays

Update After Bind

x

* Comments

* Fix URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use UPDATE_AFTER_BIND Descriptors for binding_arrays PARTIALLY_BOUND_BINDING_ARRAY workaround is too restrictive

3 participants