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
[naga] Calling a function accepting a ptr from within another function #4827
Comments
|
I tried also with var but with no luck 😥 |
Same error message? |
Adding maybe similar use case scenario - the situation is the following one: struct RayData { and a function fn intersect_aabb(ray: ptr<function, Ray>, aabb_min: vec3, aabb_max: vec3) -> f32 { /* ... */ } and it seems that naga today is complaining on: let intersection = intersect_aabb(&data.ray, (*node).min, (*node).max); while it seems to accept if I do something like: var ray_copied = data.ray; data is also declared as a var data but it seems that ptr is not able to use to inner variables of a struct as ptr, but maybe is correct and it's me that I'm expecting something that should not work like that |
struct RayData {
ray: Ray,
};
struct Ray {
data_type: u32,
};
fn main() {
var data = RayData();
let intersection = intersect_aabb(&data.ray);
}
fn intersect_aabb(ray: ptr<function, Ray>) -> f32 {
return 0.0;
} This compiles fine via naga cli on trunk. Could you provide a minimum reproducible example like the one above that doesn't? |
Oh sorry, maybe I didn't clarity it. |
In what way does it fail to be used? The original error you were getting was "Function [44] 'my_function_name' is invalid" which is a naga validation error; I'm confused 😅. |
This is an example that validate correctly but than fails at runtime: struct InnerContainer {
inner_id: u32,
}
struct Container {
id: u32,
inner: InnerContainer,
};
fn id(c: ptr<function, Container>) -> u32 {
return (*c).id;
}
fn inner_id(c: ptr<function, InnerContainer>) -> u32 {
return (*c).inner_id;
}
fn first(c: ptr<function, Container>) -> u32 {
return id(c);
}
fn second(c: ptr<function, Container>) -> u32 {
return inner_id(&(*c).inner);
}
@compute
@workgroup_size(16, 16, 1)
fn main() {
var global_var = Container(1u, InnerContainer(2u));
let u = first(&global_var);
let v = second(&global_var);
} But this time the error is: |
Ah, this is probably the same issue as #4517. |
I'm in a situation where I would like to call a function accepting a ptr from within another function.
But it fails to compile without much info
and inside another function I'm calling
But the error that I get is just: Function [44] 'my_function_name' is invalid
It seems that it should work, but the error doesn't give much info and it seems to not be able to validate the shader
The text was updated successfully, but these errors were encountered: