-
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
Implement const-expressions (phase 1) #2266
Conversation
c3ce0dd
to
80976de
Compare
f80a43d
to
7c64222
Compare
ed30382
to
c10de39
Compare
5a3adea
to
0fa81d2
Compare
0fa81d2
to
9ae732d
Compare
9ae732d
to
b423dfe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments for now. Once you've done the Specialization
rename, then I have some doc comments to push to the branch.
I find myself wishing that
For the latter point, I suspect that supporting override expressions is going to make us introduce something like that anyway. |
WGSL const-expressions may have abstract type. We should not introduce abstract types into the IR, so that means that, at least sometimes we will not be able to render WGSL |
I think we will have to have abstract types at the IR level because any expression can potentially be a const-expression (not only those in |
cf77790
to
3a812b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't debugged this, but it looks like the problems the WGSL front end rewrite used to have when it forgot to switch arenas:
var<private> arr: array<i32, 10> = array<i32,10>(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
const const_zero: i32 = 0;
fn test_arr_as_arg(a: array<f32, 10>) -> f32 {
return a[const_zero];
}
This gives me:
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 13', src/proc/mod.rs:594:19
Bizarrely, RUST_BACKTRACE=1
does not give me a full stack - the only interesting frames are:
6: <naga::arena::Arena<T> as core::ops::index::Index<naga::arena::Handle<T>>>::index
at /home/jimb/rust/naga/src/arena.rs:413:10
7: naga::proc::GlobalCtx::eval_expr_to_u32::get
at /home/jimb/rust/naga/src/proc/mod.rs:594:19
Further, I suspect that when we fix the bad handle we'll find that when the WGSL front end lowers an |
I've split out the introduction of |
I think I've got |
I pushed a commit that fixes #2266 (review), it looks like I already fixed it in the phase 2 PR as well. |
d19dca3
to
9df71e5
Compare
When I run
The first one is present on |
We should |
@teoxoy If I add this test to
|
9df71e5
to
df3cbf1
Compare
I rebased and fixed the compilation warnings when no feature flags are used. |
Regarding the self-referential test, I'd argue that the |
9b5bd3f
to
51af0f6
Compare
We talked about this in chat, and I pushed a new test case that doesn't call |
force-pushed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'm finally done looking this over. With the changes here, this can land.
@jimblandy thanks for the review! I think I addressed all the feedback in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up. Still approved.
e9c4d44
to
0d01f4f
Compare
Autosquashed the fixup commits. |
First phase of gfx-rs/wgpu#4484.