mesa: add Const.BufferCreateMapUnsynchronizedThreadSafe & MESA_MAP_THREAD_SAFE
authorMarek Olšák <marek.olsak@amd.com>
Sun, 8 Mar 2020 21:43:26 +0000 (17:43 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 27 Apr 2020 11:56:06 +0000 (11:56 +0000)
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4758>

src/mesa/main/dd.h
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_extensions.c

index 3fd47ba6f9ea030622959a0569dd340971f78f91..b7973e1c6aec9230de6ba5f4aa341da96e943d04 100644 (file)
@@ -70,6 +70,9 @@ struct _mesa_index_buffer;
  */
 #define MESA_MAP_NOWAIT_BIT       0x4000
 
+/* Mapping a buffer is allowed from any thread. */
+#define MESA_MAP_THREAD_SAFE_BIT  0x8000
+
 
 /**
  * Device driver function table.
index db55117bc087ce259431427bdbb49c5cb57d5ae3..a8b75b32f5246779360bbf22f1b71aff531e3a4c 100644 (file)
@@ -4126,6 +4126,12 @@ struct gl_constants
    /** When drivers are OK with mapped buffers during draw and other calls. */
    bool AllowMappedBuffersDuringExecution;
 
+   /**
+    * Whether buffer creation, unsynchronized mapping, unmapping, and
+    * deletion is thread-safe.
+    */
+   bool BufferCreateMapUnsynchronizedThreadSafe;
+
    /** GL_ARB_get_program_binary */
    GLuint NumProgramBinaryFormats;
 
index c95a3d4d2ac165309212b3e0ba5c474794d1184d..33778df0afa83b423d3d0567028745619c76b706 100644 (file)
@@ -494,6 +494,8 @@ st_access_flags_to_transfer_flags(GLbitfield access, bool wholeBuffer)
 
    if (access & MESA_MAP_NOWAIT_BIT)
       flags |= PIPE_TRANSFER_DONTBLOCK;
+   if (access & MESA_MAP_THREAD_SAFE_BIT)
+      flags |= PIPE_TRANSFER_THREAD_SAFE;
 
    return flags;
 }
index b0ee3e2210a4187892a4a4cc1865f4538b8eb890..b6f6091fb3a32ec1e7b8801b26d2f16ce378228e 100644 (file)
@@ -556,6 +556,9 @@ void st_init_limits(struct pipe_screen *screen,
    c->AllowMappedBuffersDuringExecution =
       screen->get_param(screen, PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION);
 
+   c->BufferCreateMapUnsynchronizedThreadSafe =
+      screen->get_param(screen, PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE);
+
    c->UseSTD430AsDefaultPacking =
       screen->get_param(screen, PIPE_CAP_LOAD_CONSTBUF);