use threadgroup pointers instead of references in metal#9380
use threadgroup pointers instead of references in metal#938039ali wants to merge 2 commits intogfx-rs:trunkfrom
Conversation
|
@39ali: Before we have somebody do review, this needs to be rebased, and CI errors need to be fixed. |
| }; | ||
| (coherent, space, access, "&") | ||
|
|
||
| let (suffix, reference) = if let crate::AddressSpace::WorkGroup = var.space { |
There was a problem hiding this comment.
If let is probably less clear than simply var.space == .... Also, do you know whether this should affect AddressSpace::TaskPayload, or any ray payload space? If not that warrants a comment explaining.
There was a problem hiding this comment.
just saw the mesh shader changes, i'll look into it
| // but for it to work with the rest of the code we reference it in a temp var in the function body: | ||
| // threadgroup type& temp = *temp_ptr; | ||
| for (handle, var) in module.global_variables.iter() { | ||
| if var.space == crate::AddressSpace::WorkGroup && !fun_info[handle].is_empty() { |
There was a problem hiding this comment.
Again, TaskPayload?
| // for threadgroup, we use pointer and not a reference to disable compiler reordering | ||
| // but for it to work with the rest of the code we reference it in a temp var in the function body: | ||
| // threadgroup type& temp = *temp_ptr; |
There was a problem hiding this comment.
This should probably link to an issue. "Compiler reordering" is not perfectly clear on what the problem actually is. And its not obvious why we can redeclare as a refernece later without issue.
| Ok(write!( | ||
| out, | ||
| "{}{}{}{}{}{}{} {}", | ||
| "{}{}{}{}{}{}{} {}{}", |
There was a problem hiding this comment.
This does not adequately handle cases where there might be another variable with this name. You have to use the writer's namer.
|
|
||
| writeln!( | ||
| self.out, | ||
| " threadgroup {}& {} = *{}_ptr;", |
There was a problem hiding this comment.
This _ptr will have to change according to the comment above.
|
@inner-daemons i didn't like that local reference hack so i changed it to actually use the pointer |
f8258f1 to
f615b3a
Compare
Connections
#4500
Description
threadgroups are broken in metal when referenced instead of using pointers(i suspect because of compiler reordering)
this seems to fix the issue
Testing
ran tests, and local test that uses threadgroups
Squash or Rebase?
either
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.