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

Big ask: can we instance in a browser? #7

Open
gilescope opened this issue Oct 3, 2022 · 5 comments
Open

Big ask: can we instance in a browser? #7

gilescope opened this issue Oct 3, 2022 · 5 comments

Comments

@gilescope
Copy link

Thought I would push my luck and try it on the browsers of a mac:

app-8d2b3f51c8c35afe.js:1734 panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_bind_group_layout
      note: label = `cuboid_instances_layout`
    binding 0 entry is invalid
    Downlevel flags VERTEX_STORAGE are required but not supported on the device.
This is not an invalid use of WebGPU: the underlying API or device does not support enough features to be a fully compliant implementation. A subset of the features can still be used. If you are running this program on native and not in a browser and wish to work around this issue, call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.

', /Users/bit/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:2391:5

Do we have to wait for WebGPU to land in 2023 or are there maybe some tweaks we could try to get it running somehow in the browser?

@gilescope
Copy link
Author

@bonsairobo
Copy link
Collaborator

Sorry this fell of my radar. If the browser doesn't support storage buffers then the only way to work around it is to figure out how to store the instances in a different kind of uniform buffer, maybe a texture. It's not an easy "tweak" AFAICT.

@gilescope
Copy link
Author

gilescope commented Nov 12, 2022 via email

@EmiOnGit
Copy link

Since I just saw this issue and did play with this I can give some input:

It is totally possible to use textures to store the instance data and is rather straight forward to implement.
Also it doesn't seem to come with any performance issues AFAICT.

The biggest problem is that wgpu only supports images up to a hard coded size limitation (8192 pixels per dimension),
the capacity can be increased by using a 2d or even 3d texture if needed
and in the worst case, you could even change the encoding of the instances to be more dense than 1 instance per pixel
but I don't thing this is a good idea.

As for the limit I'm currently using a 2d texture and it just seems to work fine for 100m entities (which is the limit my crate can handle)
For reference, I used this in my warbler_grass crate.

@gilescope
Copy link
Author

gilescope commented Mar 12, 2023 via email

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

No branches or pull requests

3 participants