Skip to content

Commit 70262cc

Browse files
committed
Revert "RT CPU: flush scene objects pending deletion when rendering is paused"
This reverts commit 6104bed.
1 parent 6104bed commit 70262cc

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

include/slg/engines/rtpathcpu/rtpathcpu.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class RTPathCPUSampler;
5858
class RTPathCPURenderEngine : public PathCPURenderEngine {
5959
public:
6060
RTPathCPURenderEngine(RenderConfigRef cfg);
61-
virtual ~RTPathCPURenderEngine() = default;
61+
~RTPathCPURenderEngine();
6262

6363
virtual RenderEngineType GetType() const { return GetObjectType(); }
6464
virtual std::string GetTag() const { return GetObjectTag(); }
@@ -80,11 +80,15 @@ class RTPathCPURenderEngine : public PathCPURenderEngine {
8080
friend class RTPathCPURenderThread;
8181
friend class RTPathCPUSampler;
8282

83+
struct completion_t {
84+
void operator()() noexcept { }
85+
};
86+
8387
protected:
8488
static luxrays::PropertiesUPtr GetDefaultProps();
8589

8690
virtual bool IsRTMode() const { return true; }
87-
91+
8892
CPURenderThreadUPtr NewRenderThread(const u_int index,
8993
luxrays::IntersectionDevice *device) {
9094
return std::make_unique<RTPathCPURenderThread>(this, index, device);
@@ -109,12 +113,10 @@ class RTPathCPURenderEngine : public PathCPURenderEngine {
109113

110114
std::mutex firstFrameMutex;
111115
std::condition_variable firstFrameCondition;
112-
std::atomic<u_int> firstFrameThreadDoneCount;
116+
u_int firstFrameThreadDoneCount;
113117
bool firstFrameDone;
114118

115-
using CompletionFunction = std::function<void()>;
116-
std::unique_ptr<std::barrier<CompletionFunction>> threadsSyncBarrier; // General sync
117-
std::unique_ptr<std::barrier<CompletionFunction>> threadsPauseBarrier; // Dedicated to pause event
119+
std::barrier<completion_t> *threadsSyncBarrier;
118120
std::atomic<bool> threadsPauseMode;
119121
};
120122

include/slg/scene/scene.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class Scene {
262262
void SetEnableParsePrint(bool status) { enableParsePrint = status; }
263263

264264
void moveToTrash(luxrays::NamedObjectUPtr&&);
265-
void EmptyTrash();
265+
void emptyTrash();
266266

267267
// Serialization
268268
static SceneUPtr LoadSerialized(const std::string &fileName);

src/slg/engines/rtpathcpu/rtpathcpu.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "slg/slg.h"
2020
#include "slg/samplers/rtpathcpusampler.h"
2121
#include <memory>
22-
#include <barrier>
23-
#include <csignal>
2422
#include "slg/engines/rtpathcpu/rtpathcpu.h"
2523

2624
using namespace std;
@@ -31,25 +29,14 @@ using namespace slg;
3129
// RTPathCPURenderEngine
3230
//------------------------------------------------------------------------------
3331

34-
3532
RTPathCPURenderEngine::RTPathCPURenderEngine(RenderConfigRef rcfg) :
3633
PathCPURenderEngine(rcfg) {
37-
38-
auto nullHandler = [&]() noexcept {
39-
};
40-
41-
auto onPause = [&]() noexcept {
42-
renderConfig.GetScene().EmptyTrash();
43-
};
44-
45-
threadsSyncBarrier = std::make_unique<std::barrier<CompletionFunction>>(
46-
renderThreads.size() + 1, nullHandler
47-
);
48-
threadsPauseBarrier = std::make_unique<std::barrier<CompletionFunction>>(
49-
renderThreads.size() + 1, onPause
50-
);
34+
threadsSyncBarrier = new std::barrier(renderThreads.size() + 1, completion_t());
5135
}
5236

37+
RTPathCPURenderEngine::~RTPathCPURenderEngine() {
38+
delete threadsSyncBarrier;
39+
}
5340

5441
void RTPathCPURenderEngine::StartLockLess() {
5542
auto& cfg = renderConfig.GetConfig();
@@ -83,7 +70,7 @@ void RTPathCPURenderEngine::PauseThreads() {
8370
threadsPauseMode = true;
8471

8572
// Wait for the threads
86-
threadsPauseBarrier->arrive_and_wait();
73+
threadsSyncBarrier->arrive_and_wait();
8774
}
8875

8976
void RTPathCPURenderEngine::ResumeThreads() {

src/slg/engines/rtpathcpu/rtpathcputhread.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ RTPathCPURenderThread::RTPathCPURenderThread(RTPathCPURenderEngine *engine, cons
3636
PathCPURenderThread(engine, index, device) {
3737
}
3838

39-
RTPathCPURenderThread::~RTPathCPURenderThread() = default;
39+
RTPathCPURenderThread::~RTPathCPURenderThread() {
40+
}
4041

4142
void RTPathCPURenderThread::StartRenderThread() {
4243
// Avoid to allocate the film thread because I'm going to use the global one
@@ -82,7 +83,7 @@ void RTPathCPURenderThread::RTRenderFunc(std::stop_token stop_token) {
8283
// Check if we are in pause or edit mode
8384
if (engine->threadsPauseMode) {
8485
// Synchronize all threads -> This waits for RTPathCPURenderEngine::PauseThreads()
85-
engine->threadsPauseBarrier->arrive_and_wait();
86+
engine->threadsSyncBarrier->arrive_and_wait();
8687

8788
while (!stop_token.stop_requested() && engine->threadsPauseMode)
8889
std::this_thread::sleep_for(100ms);

src/slg/scene/scene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ void Scene::moveToTrash(NamedObjectUPtr&& oldObj) {
462462
}
463463

464464

465-
void Scene::EmptyTrash() {
465+
void Scene::emptyTrash() {
466466
std::lock_guard lk(trashMtx);
467467
trashBin.clear();
468468
}

0 commit comments

Comments
 (0)