[PATCH 4/7] wined3d: Use atomic instructions for resource view bind counts.

Jan Sikorski jsikorski at codeweavers.com
Thu Oct 7 05:57:27 CDT 2021


Signed-off-by: Jan Sikorski <jsikorski at codeweavers.com>
---
It looks fishy that these are written to when encoding into deferred
contexts; and also that they are read in the cs thread. This patch
however is just so that we don't need a mutex for application threads
to call these.
---
 dlls/wined3d/wined3d_private.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 827ebbec773..dbb49f7e104 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4157,8 +4157,8 @@ struct wined3d_resource
 
     struct list resource_list_entry;
 
-    uint32_t srv_bind_count_device;
-    uint32_t rtv_bind_count_device;
+    int32_t srv_bind_count_device;
+    int32_t rtv_bind_count_device;
 };
 
 static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
@@ -6330,22 +6330,22 @@ static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarge
 
 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view *srv)
 {
-    ++srv->resource->srv_bind_count_device;
+    InterlockedIncrement(&srv->resource->srv_bind_count_device);
 }
 
 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view *srv)
 {
-    --srv->resource->srv_bind_count_device;
+    InterlockedDecrement(&srv->resource->srv_bind_count_device);
 }
 
 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv)
 {
-    ++rtv->resource->rtv_bind_count_device;
+    InterlockedIncrement(&rtv->resource->rtv_bind_count_device);
 }
 
 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view *rtv)
 {
-    --rtv->resource->rtv_bind_count_device;
+    InterlockedDecrement(&rtv->resource->rtv_bind_count_device);
 }
 
 static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view *rtv,
-- 
2.30.2




More information about the wine-devel mailing list