-
Notifications
You must be signed in to change notification settings - Fork 245
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
Calling methods on entrypoint argument struct members produces "Pointer operand must be a memory operand declaration" validation error #554
Comments
I've taken a bit more of a look at this, and the issue seems to be a missing OpCopyMemory. The generated ASM is:
For reference, GLAM's source code for inverse is #[inline(always)]
pub fn inverse(&self) -> Self {
Self(self.0.inverse())
} It seems that rust-gpu might need to aggressively save entrypoint parameters that are used as function parameters into OpVariables. |
Can you elaborate on why you think it's a missing OpCopyMemory? Looking at that assembly, I don't see any missing OpCopyMemory, so I'd appreciate a pointer on where exactly it should be placed. |
Not exactly sure if this is correct, but I think that the extra instruction would go here:
From the spec's definition for Memory Object Declaration, it seems that function parameters can generally only be passed with OpVariable's. |
Right, unfortunately that's not a valid fix in general, because the parameter could be |
That's a good point. At least for graphics shaders, it's hard to translate rust that passes around mutable pointers (see below) without inlining everything into a single function, since graphics shaders don't have that concept of pointers. pub struct Foo {
pub unicorn: f32,
pub griffin: f32,
pub wyvern: f32,
}
impl Foo {
fn magic(&mut self) {
self.unicorn += 1;
}
} And since the optimizer already performs fairly aggressive inlining, I think that inlining is probably the simplest solution for these types of situations in general. 👍 |
Expected Behavior
This code should pass validation, but it doesn't. Interestingly, it seems to also cause a DEVICE_LOST error on my GPU if I ignore validation and run it anyway.
Note that the link is to shader playground, which hasn't updated rust-gpu in a month, but this bug is still present on the latest version.
Example & Steps To Reproduce
System Info
rustc 1.53.0-nightly (5d04957a4 2021-03-22)
SPIRV-Tools v2020.7-dev v2020.6
(but rust-gpu builds its own version of SPIR-V tools, so this is incorrect)The text was updated successfully, but these errors were encountered: