Can't get storage buffer's access mode
bbbbx opened this issue · 3 comments
bbbbx commented
For example:
WGSL:
struct ReadonlyStorageBufferBlockName {
/* @offset(0) */
a : f32,
}
struct ReadWriteStorageBufferBlockName {
/* @offset(0) */
b : f32,
}
@group(3) @binding(1) var<storage, read> readonlyStorageBuffer : ReadonlyStorageBufferBlockName; // <= read-only
@group(3) @binding(2) var<storage, read_write> readWriteStorageBuffer : ReadWriteStorageBufferBlockName; // <= read-write
@compute @workgroup_size(1,1,1)
fn main() {}
JS:
const reflect = new WgslReflect(wgsl);
const groups = reflect.getBindGroups()
this infomation is useful for:
enum GPUBufferBindingType {
"uniform",
"storage",
"read-only-storage",
};
brendan-duncan commented
I'll get that added
brendan-duncan commented
I started working on this, only to realize @wardenfeng already added it a couple weeks ago and I forgot. I added a test for it.
test("access mode", function (test) {
const reflect = new WgslReflect(`
struct ReadonlyStorageBufferBlockName {
a : f32,
}
struct ReadWriteStorageBufferBlockName {
b : f32,
}
@group(3) @binding(1) var<storage, read> readonlyStorageBuffer : ReadonlyStorageBufferBlockName;
@group(3) @binding(2) var<storage, read_write> readWriteStorageBuffer : ReadWriteStorageBufferBlockName;
@compute @workgroup_size(1,1,1)
fn main() {}`);
const groups = reflect.getBindGroups();
test.equals(groups[3][1].name, "readonlyStorageBuffer");
test.equals(groups[3][1].access, "read");
test.equals(groups[3][2].name, "readWriteStorageBuffer");
test.equals(groups[3][2].access, "read_write");
});
bbbbx commented
Thanks, I used the latest version and it works