Skip to content

PassMode::Indirect entry inputs should make copies. #731

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
eddyb opened this issue Aug 19, 2021 · 0 comments · Fixed by #766
Closed

PassMode::Indirect entry inputs should make copies. #731

eddyb opened this issue Aug 19, 2021 · 0 comments · Fixed by #766

Comments

@eddyb
Copy link
Contributor

eddyb commented Aug 19, 2021

#[spirv(fragment)]
pub fn main(mut xs: [f32; 3]) {
    xs[0] = 0.0;
}

errors with:

error: error:0:0 - OpStore Pointer <id> '15[%15]' storage class is read-only
  OpStore %15 %float_0

  |
  = note: spirv-val failed

This happens because we're passing the Input OpVariable pointer as the pointer for xs.

Crucially, those are the semantics of an Operand::Move call arguments in MIR, transferring ownership from the caller to the callee. That's not correct, the caller doesn't own the global OpVariable, and should make a local copy (in a Function-scoped OpVariable), before passing a pointer to that in the call.

For MIR calls, this is where that's implemented, and we pretty much have to do the same dance (note that OperandValue::Ref(_).store(dest) does a memcpy).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant