Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array binding provided zero elements validation error when using PARTIALLY_BOUND_BINDING_ARRAY #3692

Open
Tracked by #3637 ...
JMS55 opened this issue Apr 15, 2023 · 7 comments
Labels
area: api Issues related to API surface type: enhancement New feature or request

Comments

@JMS55
Copy link
Contributor

JMS55 commented Apr 15, 2023

Using the PARTIALLY_BOUND_BINDING_ARRAY feature and using BindingResource::TextureViewArray(&[]) I get a validation error Array binding provided zero elements when creating the bind group. I'm not sure if this is intended.

Currently I'm working around this by adding a dummy texture to my array to ensure it has at least one element.

CC @kanerogers

@cwfitzgerald cwfitzgerald added type: enhancement New feature or request area: api Issues related to API surface labels Apr 15, 2023
@kanerogers
Copy link

@JMS55 Sorry to hear you're having issues here!

Can I ask what backend you're using and which adapter features you've enabled?

@JMS55
Copy link
Contributor Author

JMS55 commented Apr 15, 2023

RTX 3080, Vulkan, all of them. Bevy enables all features by default. Let me know if there's more info you need.

@kanerogers
Copy link

Thanks so much for the prompt response!

To be totally upfront I'm absolutely not a wgpu expert; just someone who's contributing some work on bindless. That said, I'm more than happy to take a look for you in the next week.

@kanerogers
Copy link

Ah, one last question: how are you using the texture array in your shader?

At first glance what you've described should be legal, at least from a Vulkan perspective (as per: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDescriptorBindingFlagBits.html) but there may be something wgpu specific that requires at least one texture view to be present in the array.

@JMS55
Copy link
Contributor Author

JMS55 commented Apr 15, 2023

I'm using it as a binding_array<texture_2d<f32>> in my shader.

The issue is in bind group creation, though. It looks like wgpu unconditionally disallows zero-length arrays.

if num_bindings == 0 {
return Err(Error::BindingArrayZeroLength);
}

I'm wondering if we can relax that, so that I don't have to work around it in user code.

@kanerogers
Copy link

kanerogers commented Apr 21, 2023

Hi, @JMS55 👋🏻

Thanks for your patience on this one. I've spoken with some of the wgpu maintainers and it looks like the solution here is something like the following:

  • If each backend that supports PARTIALLY_BOUND_BINDING_ARRAY also supports zero sized bindings, then this restriction will be relaxed.
  • Otherwise, the default behaviour will be to support the lowest common denominator, and a new feature, for example ZERO_SIZED_BINDING_ARRAYS will be created to identify which backends support this.

I can't give you a timeframe on when this will be done, but I hope this clarification explains this a bit further. If you do have some spare time and are looking to contribute, I would be happy to help you tackle this one yourself; wgpu is a very interesting piece of software and, given its complexity, is very approachable.

If you have any other questions or if there's anything else I can do to assist, please, just let me know.

@JMS55
Copy link
Contributor Author

JMS55 commented Apr 21, 2023

Hi, thank you for the update!

Unfortunately I don't have time at the moment to contribute myself. No worries about it though, the work-around is easy enough, it's not a major issue :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants