Skip to content
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

Treat atomic writes in shaders as write accesses #1989

Merged
merged 1 commit into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/src/bin/gl-interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ mod linux {
};

let surface = WindowBuilder::new()
.build_vk_surface(&event_loop, instance.clone())
.build_vk_surface(event_loop, instance.clone())
.unwrap();

let device_extensions = DeviceExtensions {
Expand Down
26 changes: 23 additions & 3 deletions vulkano/src/shader/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,23 @@ fn inspect_entry_point(
}
} else {
match instruction {
&Instruction::AtomicLoad { pointer, .. }
| &Instruction::AtomicStore { pointer, .. }
&Instruction::AtomicLoad { pointer, .. } => {
// Storage buffer
instruction_chain(result, global, spirv, [], pointer);

// Storage image
if let Some((variable, Some(index))) = instruction_chain(
result,
global,
spirv,
[inst_image_texel_pointer],
pointer,
) {
variable.reqs.storage_image_atomic.insert(index);
}
}

&Instruction::AtomicStore { pointer, .. }
| &Instruction::AtomicExchange { pointer, .. }
| &Instruction::AtomicCompareExchange { pointer, .. }
| &Instruction::AtomicCompareExchangeWeak { pointer, .. }
Expand All @@ -315,7 +330,11 @@ fn inspect_entry_point(
| &Instruction::AtomicFMaxEXT { pointer, .. }
| &Instruction::AtomicFAddEXT { pointer, .. } => {
// Storage buffer
instruction_chain(result, global, spirv, [], pointer);
if let Some((variable, Some(index))) =
instruction_chain(result, global, spirv, [], pointer)
{
variable.reqs.storage_write.insert(index);
}

// Storage image
if let Some((variable, Some(index))) = instruction_chain(
Expand All @@ -325,6 +344,7 @@ fn inspect_entry_point(
[inst_image_texel_pointer],
pointer,
) {
variable.reqs.storage_write.insert(index);
variable.reqs.storage_image_atomic.insert(index);
}
}
Expand Down