[Mesa-stable] [PATCH 2/2] st/nine: Use atomics for available_texture_mem

Axel Davy axel.davy at ens.fr
Wed Mar 15 21:56:30 UTC 2017


Resource dtor can be executed in the worker thread.
Use atomic to avoid threading safety issues.

CC: "17.0" <mesa-stable at lists.freedesktop.org>
Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/resource9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/nine/resource9.c b/src/gallium/state_trackers/nine/resource9.c
index c583724174..852801624a 100644
--- a/src/gallium/state_trackers/nine/resource9.c
+++ b/src/gallium/state_trackers/nine/resource9.c
@@ -79,7 +79,7 @@ NineResource9_ctor( struct NineResource9 *This,
         if (This->info.target != PIPE_BUFFER) {
             This->size = util_resource_size(&This->info);
 
-            This->base.device->available_texture_mem -= This->size;
+            p_atomic_add(&This->base.device->available_texture_mem, -This->size);
             if (This->base.device->available_texture_mem <=
                     This->base.device->available_texture_limit) {
                 return D3DERR_OUTOFVIDEOMEMORY;
@@ -111,7 +111,7 @@ NineResource9_dtor( struct NineResource9 *This )
 
     /* NOTE: size is 0, unless something has actually been allocated */
     if (This->base.device)
-        This->base.device->available_texture_mem += This->size;
+        p_atomic_add(&This->base.device->available_texture_mem, This->size);
 
     NineUnknown_dtor(&This->base);
 }
-- 
2.12.0



More information about the mesa-stable mailing list