Cleanup: Use blender::Mutex for various static mutexes
Change almost all `static ThreadMutex` to `static blender::Mutex`.
See b7a1325c3c.
Pull Request: https://projects.blender.org/blender/blender/pulls/138556
This commit is contained in:
@@ -31,12 +31,12 @@
|
||||
#include "BLI_math_bits.h"
|
||||
#include "BLI_math_color_blend.h"
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_path_utils.hh"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_string_cursor_utf8.h"
|
||||
#include "BLI_string_utf8.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "BLF_api.hh"
|
||||
@@ -64,7 +64,7 @@ static FTC_Manager ftc_manager = nullptr;
|
||||
static FTC_CMapCache ftc_charmap_cache = nullptr;
|
||||
|
||||
/* Lock for FreeType library, used around face creation and deletion. */
|
||||
static ThreadMutex ft_lib_mutex;
|
||||
static blender::Mutex ft_lib_mutex;
|
||||
|
||||
/* May be set to #UI_widgetbase_draw_cache_flush. */
|
||||
static void (*blf_draw_cache_flush)() = nullptr;
|
||||
@@ -102,7 +102,7 @@ static FT_Error blf_cache_face_requester(FTC_FaceID faceID,
|
||||
FontBLF *font = (FontBLF *)faceID;
|
||||
int err = FT_Err_Cannot_Open_Resource;
|
||||
|
||||
BLI_mutex_lock(&ft_lib_mutex);
|
||||
std::scoped_lock lock(ft_lib_mutex);
|
||||
if (font->filepath) {
|
||||
err = FT_New_Face(lib, font->filepath, 0, face);
|
||||
}
|
||||
@@ -110,7 +110,6 @@ static FT_Error blf_cache_face_requester(FTC_FaceID faceID,
|
||||
err = FT_New_Memory_Face(
|
||||
lib, static_cast<const FT_Byte *>(font->mem), (FT_Long)font->mem_size, 0, face);
|
||||
}
|
||||
BLI_mutex_unlock(&ft_lib_mutex);
|
||||
|
||||
if (err == FT_Err_Ok) {
|
||||
font->face = *face;
|
||||
@@ -1580,7 +1579,6 @@ char *blf_display_name(FontBLF *font)
|
||||
int blf_font_init()
|
||||
{
|
||||
memset(&g_batch, 0, sizeof(g_batch));
|
||||
BLI_mutex_init(&ft_lib_mutex);
|
||||
int err = FT_Init_FreeType(&ft_lib);
|
||||
if (err == FT_Err_Ok) {
|
||||
/* Create a FreeType cache manager. */
|
||||
@@ -1601,7 +1599,6 @@ int blf_font_init()
|
||||
|
||||
void blf_font_exit()
|
||||
{
|
||||
BLI_mutex_end(&ft_lib_mutex);
|
||||
if (ftc_manager) {
|
||||
FTC_Manager_Done(ftc_manager);
|
||||
}
|
||||
@@ -1884,7 +1881,7 @@ bool blf_ensure_face(FontBLF *font)
|
||||
err = FTC_Manager_LookupFace(ftc_manager, font, &font->face);
|
||||
}
|
||||
else {
|
||||
BLI_mutex_lock(&ft_lib_mutex);
|
||||
std::scoped_lock lock(ft_lib_mutex);
|
||||
if (font->filepath) {
|
||||
err = FT_New_Face(font->ft_lib, font->filepath, 0, &font->face);
|
||||
}
|
||||
@@ -1898,7 +1895,6 @@ bool blf_ensure_face(FontBLF *font)
|
||||
if (!err) {
|
||||
font->face->generic.data = font;
|
||||
}
|
||||
BLI_mutex_unlock(&ft_lib_mutex);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
@@ -2107,14 +2103,13 @@ void blf_font_free(FontBLF *font)
|
||||
}
|
||||
|
||||
if (font->face) {
|
||||
BLI_mutex_lock(&ft_lib_mutex);
|
||||
std::scoped_lock lock(ft_lib_mutex);
|
||||
if (font->flags & BLF_CACHED) {
|
||||
FTC_Manager_RemoveFaceID(ftc_manager, font);
|
||||
}
|
||||
else {
|
||||
FT_Done_Face(font->face);
|
||||
}
|
||||
BLI_mutex_unlock(&ft_lib_mutex);
|
||||
font->face = nullptr;
|
||||
}
|
||||
if (font->filepath) {
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "BLI_iterator.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_string_utils.hh"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
@@ -868,14 +868,13 @@ static void collection_object_cache_fill(ListBase *lb,
|
||||
ListBase BKE_collection_object_cache_get(Collection *collection)
|
||||
{
|
||||
if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
|
||||
static ThreadMutex cache_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex cache_lock;
|
||||
|
||||
BLI_mutex_lock(&cache_lock);
|
||||
std::scoped_lock lock(cache_lock);
|
||||
if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
|
||||
collection_object_cache_fill(&collection->runtime.object_cache, collection, 0, false);
|
||||
collection->flag |= COLLECTION_HAS_OBJECT_CACHE;
|
||||
}
|
||||
BLI_mutex_unlock(&cache_lock);
|
||||
}
|
||||
|
||||
return collection->runtime.object_cache;
|
||||
@@ -884,15 +883,14 @@ ListBase BKE_collection_object_cache_get(Collection *collection)
|
||||
ListBase BKE_collection_object_cache_instanced_get(Collection *collection)
|
||||
{
|
||||
if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE_INSTANCED)) {
|
||||
static ThreadMutex cache_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex cache_lock;
|
||||
|
||||
BLI_mutex_lock(&cache_lock);
|
||||
std::scoped_lock lock(cache_lock);
|
||||
if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE_INSTANCED)) {
|
||||
collection_object_cache_fill(
|
||||
&collection->runtime.object_cache_instanced, collection, 0, true);
|
||||
collection->flag |= COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
|
||||
}
|
||||
BLI_mutex_unlock(&cache_lock);
|
||||
}
|
||||
|
||||
return collection->runtime.object_cache_instanced;
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_string_utf8.h"
|
||||
#include "BLI_string_utils.hh"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
@@ -53,7 +53,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
static ThreadMutex python_driver_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex python_driver_lock;
|
||||
#endif
|
||||
|
||||
static CLG_LogRef LOG = {"bke.fcurve"};
|
||||
@@ -1392,11 +1392,10 @@ static void evaluate_driver_python(PathResolvedRNA *anim_rna,
|
||||
#ifdef WITH_PYTHON
|
||||
/* This evaluates the expression using Python, and returns its result:
|
||||
* - on errors it reports, then returns 0.0f. */
|
||||
BLI_mutex_lock(&python_driver_lock);
|
||||
std::scoped_lock lock(python_driver_lock);
|
||||
|
||||
driver->curval = BPY_driver_exec(anim_rna, driver, driver_orig, anim_eval_context);
|
||||
|
||||
BLI_mutex_unlock(&python_driver_lock);
|
||||
#else /* WITH_PYTHON */
|
||||
UNUSED_VARS(anim_rna, anim_eval_context);
|
||||
#endif /* WITH_PYTHON */
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
# include "BLI_kdopbvh.hh"
|
||||
# include "BLI_kdtree.h"
|
||||
# include "BLI_math_vector.hh"
|
||||
# include "BLI_mutex.hh"
|
||||
# include "BLI_threads.h"
|
||||
# include "BLI_voxel.h"
|
||||
|
||||
@@ -96,7 +97,7 @@ static CLG_LogRef LOG = {"bke.fluid"};
|
||||
/** \name Fluid API
|
||||
* \{ */
|
||||
|
||||
static ThreadMutex object_update_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex object_update_lock;
|
||||
|
||||
# define ADD_IF_LOWER_POS(a, b) min_ff((a) + (b), max_ff((a), (b)))
|
||||
# define ADD_IF_LOWER_NEG(a, b) max_ff((a) + (b), min_ff((a), (b)))
|
||||
@@ -3481,7 +3482,7 @@ static int manta_step(
|
||||
/* Keep track of original total time to correct small errors at end of step. */
|
||||
time_total_old = fds->time_total;
|
||||
|
||||
BLI_mutex_lock(&object_update_lock);
|
||||
std::scoped_lock lock(object_update_lock);
|
||||
|
||||
/* Loop as long as time_per_frame (sum of sub dt's) does not exceed actual frame-length. */
|
||||
while (time_per_frame + FLT_EPSILON < frame_length) {
|
||||
@@ -3535,7 +3536,6 @@ static int manta_step(
|
||||
fds, DEG_get_evaluated_scene(depsgraph), DEG_get_evaluated_view_layer(depsgraph));
|
||||
}
|
||||
|
||||
BLI_mutex_unlock(&object_update_lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3545,12 +3545,10 @@ static void manta_guiding(
|
||||
FluidDomainSettings *fds = fmd->domain;
|
||||
float dt = DT_DEFAULT * (25.0f / FPS) * fds->time_scale;
|
||||
|
||||
BLI_mutex_lock(&object_update_lock);
|
||||
std::scoped_lock lock(object_update_lock);
|
||||
|
||||
update_obstacles(depsgraph, scene, ob, fds, dt, dt, frame, dt);
|
||||
manta_bake_guiding(fds->fluid, fmd, frame);
|
||||
|
||||
BLI_mutex_unlock(&object_update_lock);
|
||||
}
|
||||
|
||||
static void fluid_modifier_processFlow(FluidModifierData *fmd,
|
||||
|
||||
@@ -503,7 +503,7 @@ ImageGPUTextures BKE_image_get_gpu_material_texture(Image *image,
|
||||
* \{ */
|
||||
|
||||
static LinkNode *gpu_texture_free_queue = nullptr;
|
||||
static ThreadMutex gpu_texture_queue_mutex = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex gpu_texture_queue_mutex;
|
||||
|
||||
static void gpu_free_unused_buffers()
|
||||
{
|
||||
@@ -511,14 +511,12 @@ static void gpu_free_unused_buffers()
|
||||
return;
|
||||
}
|
||||
|
||||
BLI_mutex_lock(&gpu_texture_queue_mutex);
|
||||
std::scoped_lock lock(gpu_texture_queue_mutex);
|
||||
|
||||
while (gpu_texture_free_queue != nullptr) {
|
||||
GPUTexture *tex = static_cast<GPUTexture *>(BLI_linklist_pop(&gpu_texture_free_queue));
|
||||
GPU_texture_free(tex);
|
||||
}
|
||||
|
||||
BLI_mutex_unlock(&gpu_texture_queue_mutex);
|
||||
}
|
||||
|
||||
void BKE_image_free_unused_gpu_textures()
|
||||
@@ -543,9 +541,8 @@ static void image_free_gpu(Image *ima, const bool immediate)
|
||||
GPU_texture_free(ima->gputexture[i][eye]);
|
||||
}
|
||||
else {
|
||||
BLI_mutex_lock(&gpu_texture_queue_mutex);
|
||||
std::scoped_lock lock(gpu_texture_queue_mutex);
|
||||
BLI_linklist_prepend(&gpu_texture_free_queue, ima->gputexture[i][eye]);
|
||||
BLI_mutex_unlock(&gpu_texture_queue_mutex);
|
||||
}
|
||||
|
||||
ima->gputexture[i][eye] = nullptr;
|
||||
|
||||
@@ -346,10 +346,10 @@ ViewLayer *BKE_view_layer_find_from_collection(const Scene *scene, LayerCollecti
|
||||
|
||||
static void view_layer_bases_hash_create(ViewLayer *view_layer, const bool do_base_duplicates_fix)
|
||||
{
|
||||
static ThreadMutex hash_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex hash_lock;
|
||||
|
||||
if (view_layer->object_bases_hash == nullptr) {
|
||||
BLI_mutex_lock(&hash_lock);
|
||||
std::scoped_lock lock(hash_lock);
|
||||
|
||||
if (view_layer->object_bases_hash == nullptr) {
|
||||
GHash *hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
|
||||
@@ -383,8 +383,6 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer, const bool do_ba
|
||||
/* Assign pointer only after hash is complete. */
|
||||
view_layer->object_bases_hash = hash;
|
||||
}
|
||||
|
||||
BLI_mutex_unlock(&hash_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ static CLG_LogRef LOG = {"bke.object"};
|
||||
#define VPARENT_THREADING_HACK
|
||||
|
||||
#ifdef VPARENT_THREADING_HACK
|
||||
static ThreadMutex vparent_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex vparent_lock;
|
||||
#endif
|
||||
|
||||
static void copy_object_pose(Object *obn, const Object *ob, const int flag);
|
||||
@@ -3059,11 +3059,10 @@ static void give_parvert(const Object *par, int nr, float vec[3], const bool use
|
||||
numVerts = em->bm->totvert;
|
||||
if (em->bm->elem_table_dirty & BM_VERT) {
|
||||
#ifdef VPARENT_THREADING_HACK
|
||||
BLI_mutex_lock(&vparent_lock);
|
||||
std::scoped_lock lock(vparent_lock);
|
||||
if (em->bm->elem_table_dirty & BM_VERT) {
|
||||
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
|
||||
}
|
||||
BLI_mutex_unlock(&vparent_lock);
|
||||
#else
|
||||
BLI_assert_msg(0, "Not safe for threading");
|
||||
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_mutex.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
|
||||
static constexpr float COM_PREVIEW_SIZE = 140.0f;
|
||||
|
||||
static struct {
|
||||
bool is_initialized = false;
|
||||
ThreadMutex mutex;
|
||||
} g_compositor;
|
||||
static blender::Mutex g_compositor_mutex;
|
||||
|
||||
/* Make sure node tree has previews.
|
||||
* Don't create previews in advance, this is done when adding preview operations.
|
||||
@@ -57,20 +54,11 @@ void COM_execute(Render *render,
|
||||
blender::compositor::Profiler *profiler,
|
||||
blender::compositor::OutputTypes needed_outputs)
|
||||
{
|
||||
/* Initialize mutex, TODO: this mutex init is actually not thread safe and
|
||||
* should be done somewhere as part of blender startup, all the other
|
||||
* initializations can be done lazily. */
|
||||
if (!g_compositor.is_initialized) {
|
||||
BLI_mutex_init(&g_compositor.mutex);
|
||||
g_compositor.is_initialized = true;
|
||||
}
|
||||
|
||||
BLI_mutex_lock(&g_compositor.mutex);
|
||||
std::scoped_lock lock(g_compositor_mutex);
|
||||
|
||||
if (node_tree->runtime->test_break(node_tree->runtime->tbh)) {
|
||||
/* During editing multiple compositor executions can be triggered.
|
||||
* Make sure this is the most recent one. */
|
||||
BLI_mutex_unlock(&g_compositor.mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,16 +73,6 @@ void COM_execute(Render *render,
|
||||
render_context,
|
||||
profiler,
|
||||
needed_outputs);
|
||||
|
||||
BLI_mutex_unlock(&g_compositor.mutex);
|
||||
}
|
||||
|
||||
void COM_deinitialize()
|
||||
{
|
||||
if (g_compositor.is_initialized) {
|
||||
BLI_mutex_lock(&g_compositor.mutex);
|
||||
g_compositor.is_initialized = false;
|
||||
BLI_mutex_unlock(&g_compositor.mutex);
|
||||
BLI_mutex_end(&g_compositor.mutex);
|
||||
}
|
||||
}
|
||||
void COM_deinitialize() {}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "BKE_subdiv_modifier.hh"
|
||||
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_virtual_array.hh"
|
||||
|
||||
#include "DRW_engine.hh"
|
||||
@@ -1754,7 +1754,7 @@ void DRW_subdivide_loose_geom(DRWSubdivCache &subdiv_cache, const MeshBufferCach
|
||||
* This is kind of garbage collection.
|
||||
*/
|
||||
static LinkNode *gpu_subdiv_free_queue = nullptr;
|
||||
static ThreadMutex gpu_subdiv_queue_mutex = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex gpu_subdiv_queue_mutex;
|
||||
|
||||
void DRW_create_subdivision(Object &ob,
|
||||
Mesh &mesh,
|
||||
@@ -1804,34 +1804,33 @@ void DRW_create_subdivision(Object &ob,
|
||||
|
||||
void DRW_subdiv_cache_free(bke::subdiv::Subdiv *subdiv)
|
||||
{
|
||||
BLI_mutex_lock(&gpu_subdiv_queue_mutex);
|
||||
std::scoped_lock lock(gpu_subdiv_queue_mutex);
|
||||
BLI_linklist_prepend(&gpu_subdiv_free_queue, subdiv);
|
||||
BLI_mutex_unlock(&gpu_subdiv_queue_mutex);
|
||||
}
|
||||
|
||||
void DRW_cache_free_old_subdiv()
|
||||
{
|
||||
BLI_mutex_lock(&gpu_subdiv_queue_mutex);
|
||||
{
|
||||
std::scoped_lock lock(gpu_subdiv_queue_mutex);
|
||||
|
||||
while (gpu_subdiv_free_queue != nullptr) {
|
||||
bke::subdiv::Subdiv *subdiv = static_cast<bke::subdiv::Subdiv *>(
|
||||
BLI_linklist_pop(&gpu_subdiv_free_queue));
|
||||
while (gpu_subdiv_free_queue != nullptr) {
|
||||
bke::subdiv::Subdiv *subdiv = static_cast<bke::subdiv::Subdiv *>(
|
||||
BLI_linklist_pop(&gpu_subdiv_free_queue));
|
||||
|
||||
{
|
||||
std::scoped_lock lock(g_subdiv_eval_mutex);
|
||||
if (subdiv->evaluator != nullptr) {
|
||||
g_subdiv_evaluator_users--;
|
||||
{
|
||||
std::scoped_lock lock(g_subdiv_eval_mutex);
|
||||
if (subdiv->evaluator != nullptr) {
|
||||
g_subdiv_evaluator_users--;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef WITH_OPENSUBDIV
|
||||
/* Set the type to CPU so that we do actually free the cache. */
|
||||
subdiv->evaluator->type = OPENSUBDIV_EVALUATOR_CPU;
|
||||
/* Set the type to CPU so that we do actually free the cache. */
|
||||
subdiv->evaluator->type = OPENSUBDIV_EVALUATOR_CPU;
|
||||
#endif
|
||||
bke::subdiv::free(subdiv);
|
||||
bke::subdiv::free(subdiv);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_mutex_unlock(&gpu_subdiv_queue_mutex);
|
||||
|
||||
{
|
||||
std::scoped_lock lock(g_subdiv_eval_mutex);
|
||||
/* Free evaluator cache if there is no more reference to it.. */
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
@@ -4038,7 +4038,7 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
|
||||
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
|
||||
IDProperty *idprop;
|
||||
|
||||
static ThreadMutex lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex mutex;
|
||||
|
||||
BLI_assert(RNA_property_type(prop) == PROP_POINTER);
|
||||
|
||||
@@ -4063,11 +4063,10 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
|
||||
/* NOTE: While creating/writing data in an accessor is really bad design-wise, this is
|
||||
* currently very difficult to avoid in that case. So a global mutex is used to keep ensuring
|
||||
* thread safety. */
|
||||
BLI_mutex_lock(&lock);
|
||||
std::scoped_lock lock(mutex);
|
||||
/* NOTE: We do not need to check again for existence of the pointer after locking here, since
|
||||
* this is also done in #RNA_property_pointer_add itself. */
|
||||
RNA_property_pointer_add(ptr, prop);
|
||||
BLI_mutex_unlock(&lock);
|
||||
return RNA_property_pointer_get(ptr, prop);
|
||||
}
|
||||
return PointerRNA_NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
@@ -180,19 +180,20 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh
|
||||
/* TODO(jbakker): Dualcon crashes when run in parallel. Could be related to incorrect
|
||||
* input data or that the library isn't thread safe.
|
||||
* This was identified when changing the task isolation's during #76553. */
|
||||
static ThreadMutex dualcon_mutex = BLI_MUTEX_INITIALIZER;
|
||||
BLI_mutex_lock(&dualcon_mutex);
|
||||
output = static_cast<DualConOutput *>(dualcon(&input,
|
||||
dualcon_alloc_output,
|
||||
dualcon_add_vert,
|
||||
dualcon_add_quad,
|
||||
flags,
|
||||
mode,
|
||||
rmd->threshold,
|
||||
rmd->hermite_num,
|
||||
rmd->scale,
|
||||
rmd->depth));
|
||||
BLI_mutex_unlock(&dualcon_mutex);
|
||||
static blender::Mutex dualcon_mutex;
|
||||
{
|
||||
std::scoped_lock lock(dualcon_mutex);
|
||||
output = static_cast<DualConOutput *>(dualcon(&input,
|
||||
dualcon_alloc_output,
|
||||
dualcon_add_vert,
|
||||
dualcon_add_quad,
|
||||
flags,
|
||||
mode,
|
||||
rmd->threshold,
|
||||
rmd->hermite_num,
|
||||
rmd->scale,
|
||||
rmd->depth));
|
||||
}
|
||||
result = output->mesh;
|
||||
MEM_freeN(output);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_set.hh"
|
||||
#include "BLI_string.h"
|
||||
@@ -207,8 +208,8 @@ static void stats_background(void * /*arg*/, RenderStats *rs)
|
||||
|
||||
/* Compositor calls this from multiple threads, mutex lock to ensure we don't
|
||||
* get garbled output. */
|
||||
static ThreadMutex mutex = BLI_MUTEX_INITIALIZER;
|
||||
BLI_mutex_lock(&mutex);
|
||||
static blender::Mutex mutex;
|
||||
std::scoped_lock lock(mutex);
|
||||
|
||||
char *message = BLI_sprintfN(RPT_("Fra:%d Mem:%.2fM (Peak %.2fM) | Time:%s | %s"),
|
||||
rs->cfra,
|
||||
@@ -233,8 +234,6 @@ static void stats_background(void * /*arg*/, RenderStats *rs)
|
||||
}
|
||||
|
||||
MEM_freeN(message);
|
||||
|
||||
BLI_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void RE_ReferenceRenderResult(RenderResult *rr)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
#include "RE_texture.h"
|
||||
|
||||
static ThreadMutex sample_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static blender::Mutex sample_mutex;
|
||||
|
||||
enum {
|
||||
POINT_DATA_VEL = 1 << 0,
|
||||
@@ -811,9 +811,8 @@ void RE_point_density_cache(Depsgraph *depsgraph, PointDensity *pd)
|
||||
Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
||||
|
||||
/* Same matrices/resolution as dupli_render_particle_set(). */
|
||||
BLI_mutex_lock(&sample_mutex);
|
||||
std::scoped_lock lock(sample_mutex);
|
||||
cache_pointdensity(depsgraph, scene, pd);
|
||||
BLI_mutex_unlock(&sample_mutex);
|
||||
}
|
||||
|
||||
void RE_point_density_minmax(Depsgraph *depsgraph,
|
||||
@@ -924,9 +923,10 @@ void RE_point_density_sample(Depsgraph *depsgraph,
|
||||
return;
|
||||
}
|
||||
|
||||
BLI_mutex_lock(&sample_mutex);
|
||||
RE_point_density_minmax(depsgraph, pd, min, max);
|
||||
BLI_mutex_unlock(&sample_mutex);
|
||||
{
|
||||
std::scoped_lock lock(sample_mutex);
|
||||
RE_point_density_minmax(depsgraph, pd, min, max);
|
||||
}
|
||||
sub_v3_v3v3(dim, max, min);
|
||||
if (dim[0] <= 0.0f || dim[1] <= 0.0f || dim[2] <= 0.0f) {
|
||||
sample_dummy_point_density(resolution, values);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_mempool.h"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "BKE_main.hh"
|
||||
@@ -78,7 +79,7 @@ struct SeqCacheItem {
|
||||
ImBuf *ibuf;
|
||||
};
|
||||
|
||||
static ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex cache_create_lock;
|
||||
|
||||
static bool seq_cmp_render_data(const RenderData *a, const RenderData *b)
|
||||
{
|
||||
@@ -492,7 +493,7 @@ static void seq_cache_set_temp_cache_linked(Scene *scene, SeqCacheKey *base)
|
||||
|
||||
static void seq_cache_create(Main *bmain, Scene *scene)
|
||||
{
|
||||
BLI_mutex_lock(&cache_create_lock);
|
||||
std::scoped_lock lock(cache_create_lock);
|
||||
if (scene->ed->cache == nullptr) {
|
||||
SeqCache *cache = MEM_callocN<SeqCache>("SeqCache");
|
||||
cache->keys_pool = BLI_mempool_create(sizeof(SeqCacheKey), 0, 64, BLI_MEMPOOL_NOP);
|
||||
@@ -507,7 +508,6 @@ static void seq_cache_create(Main *bmain, Scene *scene)
|
||||
scene->ed->disk_cache_timestamp = time(nullptr);
|
||||
}
|
||||
}
|
||||
BLI_mutex_unlock(&cache_create_lock);
|
||||
}
|
||||
|
||||
static void seq_cache_populate_key(SeqCacheKey *key,
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_mutex.hh"
|
||||
#include "BLI_path_utils.hh"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_sequence_types.h"
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace blender::seq {
|
||||
|
||||
static ThreadMutex presence_lock = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex presence_lock;
|
||||
|
||||
static const char *strip_base_path_get(const Strip *strip)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ bool media_presence_is_missing(Scene *scene, const Strip *strip)
|
||||
return false;
|
||||
}
|
||||
|
||||
BLI_mutex_lock(&presence_lock);
|
||||
std::scoped_lock lock(presence_lock);
|
||||
|
||||
MediaPresence *presence = get_media_presence_cache(scene);
|
||||
|
||||
@@ -137,7 +137,6 @@ bool media_presence_is_missing(Scene *scene, const Strip *strip)
|
||||
}
|
||||
}
|
||||
|
||||
BLI_mutex_unlock(&presence_lock);
|
||||
return missing;
|
||||
}
|
||||
|
||||
@@ -147,7 +146,7 @@ void media_presence_set_missing(Scene *scene, const Strip *strip, bool missing)
|
||||
return;
|
||||
}
|
||||
|
||||
BLI_mutex_lock(&presence_lock);
|
||||
std::scoped_lock lock(presence_lock);
|
||||
|
||||
MediaPresence *presence = get_media_presence_cache(scene);
|
||||
|
||||
@@ -158,36 +157,31 @@ void media_presence_set_missing(Scene *scene, const Strip *strip, bool missing)
|
||||
else {
|
||||
presence->map_seq.add_overwrite(strip, missing);
|
||||
}
|
||||
|
||||
BLI_mutex_unlock(&presence_lock);
|
||||
}
|
||||
|
||||
void media_presence_invalidate_strip(Scene *scene, const Strip *strip)
|
||||
{
|
||||
BLI_mutex_lock(&presence_lock);
|
||||
std::scoped_lock lock(presence_lock);
|
||||
if (scene != nullptr && scene->ed != nullptr && scene->ed->runtime.media_presence != nullptr) {
|
||||
scene->ed->runtime.media_presence->map_seq.remove(strip);
|
||||
}
|
||||
BLI_mutex_unlock(&presence_lock);
|
||||
}
|
||||
|
||||
void media_presence_invalidate_sound(Scene *scene, const bSound *sound)
|
||||
{
|
||||
BLI_mutex_lock(&presence_lock);
|
||||
std::scoped_lock lock(presence_lock);
|
||||
if (scene != nullptr && scene->ed != nullptr && scene->ed->runtime.media_presence != nullptr) {
|
||||
scene->ed->runtime.media_presence->map_sound.remove(sound);
|
||||
}
|
||||
BLI_mutex_unlock(&presence_lock);
|
||||
}
|
||||
|
||||
void media_presence_free(Scene *scene)
|
||||
{
|
||||
BLI_mutex_lock(&presence_lock);
|
||||
std::scoped_lock lock(presence_lock);
|
||||
if (scene != nullptr && scene->ed != nullptr && scene->ed->runtime.media_presence != nullptr) {
|
||||
MEM_delete(scene->ed->runtime.media_presence);
|
||||
scene->ed->runtime.media_presence = nullptr;
|
||||
}
|
||||
BLI_mutex_unlock(&presence_lock);
|
||||
}
|
||||
|
||||
} // namespace blender::seq
|
||||
|
||||
@@ -86,7 +86,7 @@ static ImBuf *seq_render_strip_stack(const RenderData *context,
|
||||
float timeline_frame,
|
||||
int chanshown);
|
||||
|
||||
static ThreadMutex seq_render_mutex = BLI_MUTEX_INITIALIZER;
|
||||
static blender::Mutex seq_render_mutex;
|
||||
DrawViewFn view3d_fn = nullptr; /* nullptr in background mode */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -1994,7 +1994,7 @@ ImBuf *render_give_ibuf(const RenderData *context, float timeline_frame, int cha
|
||||
relations_free_all_anim_ibufs(context->scene, timeline_frame);
|
||||
|
||||
if (!strips.is_empty() && !out) {
|
||||
BLI_mutex_lock(&seq_render_mutex);
|
||||
std::scoped_lock lock(seq_render_mutex);
|
||||
out = seq_render_strip_stack(context, &state, channels, seqbasep, timeline_frame, chanshown);
|
||||
|
||||
if (context->is_prefetch_render) {
|
||||
@@ -2004,7 +2004,6 @@ ImBuf *render_give_ibuf(const RenderData *context, float timeline_frame, int cha
|
||||
seq_cache_put_if_possible(
|
||||
context, strips.last(), timeline_frame, SEQ_CACHE_STORE_FINAL_OUT, out);
|
||||
}
|
||||
BLI_mutex_unlock(&seq_render_mutex);
|
||||
}
|
||||
|
||||
seq_prefetch_start(context, timeline_frame);
|
||||
|
||||
Reference in New Issue
Block a user