Files
test/source/blender/draw/tests/draw_testing.cc
Miguel Pozo 88f812bf9a Fix #141253: Bring back the global Draw lock
Alternative solution to #141392 / #141564.

As a recap, the DST global lock (which prevented running drawing code
from multiple threads concurrently) was removed for 4.5 (#134690).
One unforeseen issue is that Images (and their GPUTextures) are shared
across dependency graphs (and therefore multiple threads), meaning we
are running into data race issues with them.

@fclem did #141392 and I continued it #141564. However, this is only a
partial solution, parts of the GPUTexture API and the whole BKE_image
API are still unsafe.
Trying to solve all the possible underlying issues seems unrealistic for
4.5 given the time frame and that the extension of the code affected by
this issue is quite large.

So this PR just brings the 4.4 locking behavior instead, which, while
risky on its own, seems much safer to me than the alternative.

This effectively undoes the improvements from #134690 by disabling
concurrent rendering, but instead of reverting all the code, it just
ensures we hold the lock in the same places we did in 4.4.
This means there's some redundant code that is not technically needed
anymore, like the `submission_mutex`, but it's probably best to make as
few modifications as possible, given how close we are to release and
that this is only intended as a temporary measure.

Pull Request: https://projects.blender.org/blender/blender/pulls/141618
2025-07-09 15:11:29 +02:00

56 lines
934 B
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: Apache-2.0 */
#include "draw_testing.hh"
#include "DRW_engine.hh"
#include "GPU_shader.hh"
namespace blender::draw {
/* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
#ifdef WITH_OPENGL_BACKEND
void DrawOpenGLTest::SetUp()
{
GPUOpenGLTest::SetUp();
DRW_mutexes_init();
}
void DrawOpenGLTest::TearDown()
{
DRW_mutexes_exit();
GPUOpenGLTest::TearDown();
}
#endif
#ifdef WITH_METAL_BACKEND
void DrawMetalTest::SetUp()
{
GPUMetalTest::SetUp();
DRW_mutexes_init();
}
void DrawMetalTest::TearDown()
{
DRW_mutexes_exit();
GPUMetalTest::TearDown();
}
#endif
#ifdef WITH_VULKAN_BACKEND
void DrawVulkanTest::SetUp()
{
GPUVulkanTest::SetUp();
DRW_mutexes_init();
}
void DrawVulkanTest::TearDown()
{
DRW_mutexes_exit();
GPUVulkanTest::TearDown();
}
#endif
} // namespace blender::draw