Skip to content

Commit 1776de7

Browse files
committed
Relax atomic memory ordering for texture attachments
1 parent 7368cde commit 1776de7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/bevy_render/src/texture/texture_attachment.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ColorAttachment {
4040
/// The returned attachment will always have writing enabled (`store: StoreOp::Load`).
4141
pub fn get_attachment(&self) -> RenderPassColorAttachment<'_> {
4242
if let Some(resolve_target) = self.resolve_target.as_ref() {
43-
let first_call = self.is_first_call.fetch_and(false, Ordering::SeqCst);
43+
let first_call = self.is_first_call.fetch_and(false, Ordering::Relaxed);
4444

4545
RenderPassColorAttachment {
4646
view: &resolve_target.default_view,
@@ -64,7 +64,7 @@ impl ColorAttachment {
6464
///
6565
/// The returned attachment will always have writing enabled (`store: StoreOp::Load`).
6666
pub fn get_unsampled_attachment(&self) -> RenderPassColorAttachment<'_> {
67-
let first_call = self.is_first_call.fetch_and(false, Ordering::SeqCst);
67+
let first_call = self.is_first_call.fetch_and(false, Ordering::Relaxed);
6868

6969
RenderPassColorAttachment {
7070
view: &self.texture.default_view,
@@ -81,7 +81,7 @@ impl ColorAttachment {
8181
}
8282

8383
pub(crate) fn mark_as_cleared(&self) {
84-
self.is_first_call.store(false, Ordering::SeqCst);
84+
self.is_first_call.store(false, Ordering::Relaxed);
8585
}
8686
}
8787

@@ -108,7 +108,7 @@ impl DepthAttachment {
108108
pub fn get_attachment(&self, store: StoreOp) -> RenderPassDepthStencilAttachment<'_> {
109109
let first_call = self
110110
.is_first_call
111-
.fetch_and(store != StoreOp::Store, Ordering::SeqCst);
111+
.fetch_and(store != StoreOp::Store, Ordering::Relaxed);
112112

113113
RenderPassDepthStencilAttachment {
114114
view: &self.view,
@@ -148,7 +148,7 @@ impl OutputColorAttachment {
148148
/// the provided `clear_color` if this is the first time calling this function, otherwise it
149149
/// will be loaded.
150150
pub fn get_attachment(&self, clear_color: Option<LinearRgba>) -> RenderPassColorAttachment<'_> {
151-
let first_call = self.is_first_call.fetch_and(false, Ordering::SeqCst);
151+
let first_call = self.is_first_call.fetch_and(false, Ordering::Relaxed);
152152

153153
RenderPassColorAttachment {
154154
view: &self.view,
@@ -168,6 +168,6 @@ impl OutputColorAttachment {
168168
// we re-use is_first_call atomic to track usage, which assumes that calls to get_attachment
169169
// are always consumed by a render pass that writes to the attachment
170170
pub fn needs_present(&self) -> bool {
171-
!self.is_first_call.load(Ordering::SeqCst)
171+
!self.is_first_call.load(Ordering::Relaxed)
172172
}
173173
}

0 commit comments

Comments
 (0)