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

WebGPU buffers of MemoryType::Upload can't be created #104

Open
aleino-nv opened this issue Nov 12, 2024 · 2 comments
Open

WebGPU buffers of MemoryType::Upload can't be created #104

aleino-nv opened this issue Nov 12, 2024 · 2 comments

Comments

@aleino-nv
Copy link
Contributor

It is a WebGPU limitation that mappable buffers can't have any other usages. (The spec mentions this clearly.)

Currently in Slang-RHI, if a buffer with MemoryType::Upload is created then this constraint will be violated and buffer creation just fails.

@aleino-nv
Copy link
Contributor Author

Example WebGPU error message:

WGPU error: Buffer usages (BufferUsage::(MapWrite|CopySrc|CopyDst)) is invalid. If a buffer usage contains 
BufferUsage::MapWrite the only other allowed usage is BufferUsage::CopySrc.
 - While calling [Device].CreateBuffer([BufferDescriptor "Unnamed buffer (size=96, elementSize=0, format=Unknown, 
 memoryType=Upload, usage=VertexBuffer, defaultState=VertexBuffer)"]).

@aleino-nv
Copy link
Contributor Author

Thus far, when I've run into this it has turned out that MemoryType::Upload wasn't actually necessary -- the buffers typically get initialized with data at creation time and then never updated from the host.

Switching to MemoryType::DeviceLocal is often a viable workaround.

aleino-nv added a commit to aleino-nv/slang that referenced this issue Nov 13, 2024
csyonghe pushed a commit to shader-slang/slang that referenced this issue Nov 13, 2024
* Update Slang-RHI to get WGPU backend fixes

* render-test: Use device local memory type for vertex buffers

This helps to avoid shader-slang/slang-rhi#104

* Fix bug in WGSL emitter layout code.

There was a "kinds" vs. "kind flags" mismatch, and also getBindingOffsetForKinds was not
being used.

This patch enables a bunch of tests for WGPU.
This helps to address issue #4943.

* format code

---------

Co-authored-by: slangbot <[email protected]>
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

1 participant