-
Notifications
You must be signed in to change notification settings - Fork 195
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
[meta] Advanced compute support #1154
Comments
For pointer support, I'm adding a few edge cases that seem interesting: Broken, fn array_read_from_pointer(p: ptr<workgroup, array<u32, 32>>, i: u32) -> u32 {
return *p[i];
// This works instead: return *(p[i]);
} Works: fn array_write_from_pointer(p: ptr<function, array<u32, 32>>, i: u32) -> u32 {
p[i] = 42u;
} Broken, runtime arrays seem to have a fn runtime_array_read_from_pointer(p: ptr<storage, array<u32>>, i: u32) -> u32 {
return p[i];
} Broken, runtime arrays seem to have a fn runtime_array_write_from_pointer(p: ptr<storage, array<u32>, read_write>, i: u32) {
p[i] = 42u;
} Works: struct Foo {
bar: u32;
};
fn struct_field_read_from_pointer(p: ptr<function, Foo>) -> u32 {
return *p.bar;
} Works: struct Foo {
bar: u32;
};
fn struct_field_write_from_pointer(p: ptr<function, Foo>) {
p.bar = 42u;
} |
This now errors with: error: the value indexed by a `[]` subscripting expression must not be a pointer
┌─ test.wgsl:69:13
│
69 │ return *p[i];
│ ^ expression is a pointer and error: the value indexed by a `[]` subscripting expression must not be a pointer
┌─ test.wgsl:69:14
│
69 │ return *(p[i]);
│ ^ expression is a pointer Looking at the relevant grammar section in the WGSL spec this is intended and
This now errors with: error: the value indexed by a `[]` subscripting expression must not be a pointer
┌─ test.wgsl:67:73
│
67 │ fn array_write_from_pointer2(p: ptr<function, array<u32, 32>>, i: u32) {
│ ╭────────────────────────────────────────────────────────────────────────^
68 │ │ p[i] = 42u;
│ ╰─────^ expression is a pointer According to the relevant grammar section in the WGSL spec
Both of these are intended to not work according to the spec and they will fail with the following error: error:
┌─ test.wgsl:1:1
│
1 │ ╭ fn runtime_array_read_from_pointer(p: ptr<storage, array<u32>>, i: u32) -> u32 {
│ ^^^^^^^^^^^^^^^^^^^^^^^^ naga::Type [3]
2 │ │ return (*p)[i];
3 │ │ }
│ ╰─^ naga::Function [1]
Function [1] 'runtime_array_read_from_pointer' is invalid:
Argument 'p' at index 0 is a pointer of space Storage { access: LOAD }, which can't be passed into functions.
This one errors again and should be
This one errors again and should be ConclusionEverything related to pointers besides the assignment works as intended. I opened gfx-rs/wgpu#4383 to tackle the assignment issue. |
Will close this, let's track the last 2 items in their own issues |
I wanted to have a checklist of some more advanced features that would enable complex compute use cases in one place so it's easier to keep up with naga's development. Feel free to add/edit/remove as appropriate.
Features:
The text was updated successfully, but these errors were encountered: