Bug 1686158 - make max_bands atomic. r=lsalzman
authorAlexis Beingessner <a.beingessner@gmail.com>
Thu, 14 Jan 2021 01:20:12 +0000
changeset 563003 044f8b594c716c99228cb6d70543d64ae7ce0427
parent 563002 62acc7bce1c17e7dded73c1d9931f1c8f3a0611f
child 563004 4cff94ca98189769f21a855520a345c6c4e5c841
push id38104
push usernbeleuzu@mozilla.com
push dateFri, 15 Jan 2021 03:50:53 +0000
treeherdermozilla-central@0f5e4a3c6f0a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1686158 - make max_bands atomic. r=lsalzman Differential Revision: https://phabricator.services.mozilla.com/D101653
--- a/gfx/webrender_bindings/src/swgl_bindings.rs
+++ b/gfx/webrender_bindings/src/swgl_bindings.rs
@@ -566,17 +566,17 @@ impl DerefMut for SwCompositeGraphNodeRe
 /// Dependency graph of composite jobs to be completed. Keeps a list of child jobs that are dependent on the completion of this job.
 /// Also keeps track of the number of parent jobs that this job is dependent upon before it can be processed. Once there are no more
 /// in-flight parent jobs that it depends on, the graph node is finally added to the job queue for processing.
 struct SwCompositeGraphNode {
     /// Job to be queued for this graph node once ready.
     job: Option<SwCompositeJob>,
     /// The maximum number of available bands associated with this job.
-    max_bands: u8,
+    max_bands: AtomicU8,
     /// The number of remaining bands associated with this job. When this is
     /// non-zero and the node has no more parents left, then the node is being
     /// actively used by the composite thread to process jobs. Once it hits
     /// zero, the owning thread (which brought it to zero) can safely retire
     /// the node as no other thread is using it.
     remaining_bands: AtomicU8,
     /// The number of bands that have been taken for processing.
     band_index: AtomicU8,
@@ -589,28 +589,28 @@ struct SwCompositeGraphNode {
 unsafe impl Sync for SwCompositeGraphNode {}
 impl SwCompositeGraphNode {
     fn new() -> SwCompositeGraphNodeRef {
         SwCompositeGraphNodeRef::new(SwCompositeGraphNode {
             job: None,
-            max_bands: 0,
+            max_bands: AtomicU8::new(0),
             remaining_bands: AtomicU8::new(0),
             band_index: AtomicU8::new(0),
             parents: AtomicU32::new(0),
             children: Vec::new(),
     /// Reset the node's state for a new frame
     fn reset(&mut self) {
         self.job = None;
-        self.max_bands = 0;
+        self.max_bands.store(0, Ordering::SeqCst);
         self.remaining_bands.store(0, Ordering::SeqCst);
         self.band_index.store(0, Ordering::SeqCst);
         // Initialize parents to 1 as sentinel dependency for uninitialized job
         // to avoid queuing unitialized job as unblocked child dependency.
         self.parents.store(1, Ordering::SeqCst);
@@ -619,26 +619,26 @@ impl SwCompositeGraphNode {
         child.parents.fetch_add(1, Ordering::SeqCst);
     /// Install a job for this node. Return whether or not the job has any unprocessed parents
     /// that would block immediate composition.
     fn set_job(&mut self, job: SwCompositeJob, num_bands: u8) -> bool {
         self.job = Some(job);
-        self.max_bands = num_bands;
+        self.max_bands.store(num_bands, Ordering::SeqCst);
         self.remaining_bands.store(num_bands, Ordering::SeqCst);
         // Subtract off the sentinel parent dependency now that job is initialized and check
         // whether there are any remaining parent dependencies to see if this job is ready.
         self.parents.fetch_sub(1, Ordering::SeqCst) <= 1
     fn take_band(&self) -> Option<u8> {
         let band_index = self.band_index.fetch_add(1, Ordering::SeqCst);
-        if band_index < self.max_bands {
+        if band_index < self.max_bands.load(Ordering::SeqCst) {
         } else {
     /// Try to take the job from this node for processing and then process it within the current band.
     fn process_job(&self, band_index: u8) {