mirror of
https://github.com/bevyengine/bevy
synced 2024-11-29 08:00:20 +00:00
Fix incorrect workgroupBarrier and OOB array access in auto_exposure (#13283)
This commit fixes two issues in auto_exposure.wgsl: * A `storageBarrier()` was incorrectly used where a `workgroupBarrier()` should be used instead; * Resetting the `histogram_shared` array would write beyond the 64th index, which is out of bounds. ## Solution The first issue is fixed by using the appropriate workgroupBarrier instead; The second issue is fixed by adding a range check before setting `histogram_shared[local_invocation_index] = 0u`. ## Testing These changes were tested using the Xcode metal profiler, and I could not find any noticable change in compute shader performance.
This commit is contained in:
parent
de7ff295e1
commit
bfc13383e0
1 changed files with 4 additions and 2 deletions
|
@ -95,10 +95,12 @@ fn compute_histogram(
|
||||||
@builtin(local_invocation_index) local_invocation_index: u32
|
@builtin(local_invocation_index) local_invocation_index: u32
|
||||||
) {
|
) {
|
||||||
// Clear the workgroup shared histogram
|
// Clear the workgroup shared histogram
|
||||||
histogram_shared[local_invocation_index] = 0u;
|
if local_invocation_index < 64 {
|
||||||
|
histogram_shared[local_invocation_index] = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
// Wait for all workgroup threads to clear the shared histogram
|
// Wait for all workgroup threads to clear the shared histogram
|
||||||
storageBarrier();
|
workgroupBarrier();
|
||||||
|
|
||||||
let dim = vec2<u32>(textureDimensions(tex_color));
|
let dim = vec2<u32>(textureDimensions(tex_color));
|
||||||
let uv = vec2<f32>(global_invocation_id.xy) / vec2<f32>(dim);
|
let uv = vec2<f32>(global_invocation_id.xy) / vec2<f32>(dim);
|
||||||
|
|
Loading…
Reference in a new issue