How to read from an dynamically sized storage buffer #1779
Unanswered
gliderkite
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi! Could you post the whole shader? We recommend looking at the examples, and there is a handy table of features to point you to the right one. Storage buffers are used in |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm currently playing around with
wgpu
, as my first introduction to 3D computer graphics and GPU programming in general, learning the theory as I go.My current goal is to be able to write a buffer of transformation matrices so that I can access them in the vertex shader using an index of the array. So far I've followed the learn-gpu tutorial, and I was able to create an uniform buffer for a single matrix used for the camera.
I'm using WGSL for the shader, where if I wanted to keep using a uniform buffer with a fixed number of elements I could write something like:
And I create the buffer, layout and bind group with:
I then update the buffer by pushing the new data into the queue:
While this works, I would like to not having to specify a fixed size for the transformation array in the shader, and I seem to understand this is not possible with uniform buffer, but I need to use storage buffers. So I changed the following part of the code:
The problem is that when I run the code I get
Global variable [2] is used incorrectly as READ
, full error:So my questions is: how should I structure my code to be able to read from a dynamically sized buffer (note: the same error is raised even if I keep the buffer with a fixed size in the shader)?
Beta Was this translation helpful? Give feedback.
All reactions