Skip to content

Commit 41ae48c

Browse files
committed
Python: Expose internal OIDN (for viewport render, especially)
1 parent ff89428 commit 41ae48c

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

include/luxcore/luxcoreimpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class FilmImpl : public Film {
100100
void WaitAsyncExecuteImagePipeline();
101101
bool HasDoneAsyncExecuteImagePipeline();
102102

103+
void ApplyOIDN(const u_int index);
104+
103105
friend class RenderSessionImpl;
104106

105107
private:

src/luxcore/luxcoreimpl.cpp

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
* Copyright 1998-2020 by authors (see AUTHORS.txt) *
2+
* Copyright 1998-2025 by authors (see AUTHORS.txt) *
33
* *
44
* This file is part of LuxCoreRender. *
55
* *
@@ -32,6 +32,7 @@
3232
#include "slg/engines/tilepathocl/tilepathocl.h"
3333
#include "slg/engines/rtpathocl/rtpathocl.h"
3434
#include "slg/engines/filesaver/filesaver.h"
35+
#include "slg/film/imagepipeline/plugins/intel_oidn.h"
3536
#include "luxcore/luxcore.h"
3637
#include "luxcore/luxcoreimpl.h"
3738

@@ -445,7 +446,7 @@ void FilmImpl::DeleteAllImagePipelines() {
445446
renderSession->renderSession->renderConfig->DeleteAllFilmImagePipelinesProperties();
446447
} else
447448
standAloneFilm->SetImagePipelines(NULL);
448-
449+
449450
API_END();
450451
}
451452

@@ -467,7 +468,7 @@ void FilmImpl::AsyncExecuteImagePipeline(const u_int index) {
467468
renderSession->renderSession->film->AsyncExecuteImagePipeline(index);
468469
} else
469470
standAloneFilm->AsyncExecuteImagePipeline(index);
470-
471+
471472
API_END();
472473
}
473474

@@ -494,12 +495,28 @@ bool FilmImpl::HasDoneAsyncExecuteImagePipeline() {
494495
result = renderSession->renderSession->film->HasDoneAsyncExecuteImagePipeline();
495496
} else
496497
result = standAloneFilm->HasDoneAsyncExecuteImagePipeline();
497-
498+
498499
API_RETURN("{}", result);
499-
500+
500501
return result;
501502
}
502503

504+
505+
void FilmImpl::ApplyOIDN(const u_int index) {
506+
API_BEGIN("{}", index);
507+
slg::IntelOIDN oidn("RT", 6000, 0.f, true);
508+
509+
if (renderSession) {
510+
std::unique_lock<std::mutex> lock(renderSession->renderSession->filmMutex);
511+
512+
oidn.Apply(*renderSession->renderSession->film, index);
513+
} else {
514+
oidn.Apply(*standAloneFilm, index);
515+
}
516+
517+
API_END();
518+
}
519+
503520
//------------------------------------------------------------------------------
504521
// CameraImpl
505522
//------------------------------------------------------------------------------
@@ -1500,7 +1517,7 @@ RenderState *RenderSessionImpl::GetRenderState() {
15001517
API_BEGIN_NOARGS();
15011518

15021519
RenderState *result = new RenderStateImpl(renderSession->GetRenderState());
1503-
1520+
15041521
API_RETURN("{}", (void *)result);
15051522

15061523
return result;
@@ -1620,7 +1637,7 @@ Film &RenderSessionImpl::GetFilm() {
16201637
API_BEGIN_NOARGS();
16211638

16221639
Film &result = *film;
1623-
1640+
16241641
API_RETURN("{}", (void *)&result);
16251642

16261643
return result;
@@ -1685,8 +1702,9 @@ void RenderSessionImpl::UpdateStats() {
16851702
double totalPerf = 0.0;
16861703
for(IntersectionDevice *dev: idevices) {
16871704
const string &devName = dev->GetName();
1688-
1689-
// Append a device index for the case where the same device is used multiple times
1705+
1706+
// Append a device index for the case where the same device is used
1707+
// multiple times
16901708
unsigned int index = devCounters[devName]++;
16911709
const string uniqueName = devName + "-" + ToString(index);
16921710
devicesNames.Add(uniqueName);
@@ -1706,7 +1724,7 @@ void RenderSessionImpl::UpdateStats() {
17061724
stats.Set(Property(prefix + ".memory.used")((u_longlong)hardDev->GetUsedMemory()));
17071725
} else {
17081726
stats.Set(Property(prefix + ".memory.total")(0ull));
1709-
stats.Set(Property(prefix + ".memory.used")(0ull));
1727+
stats.Set(Property(prefix + ".memory.used")(0ull));
17101728
}
17111729
}
17121730
stats.Set(devicesNames);

src/pyluxcore/pyluxcore.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
* Copyright 1998-2020 by authors (see AUTHORS.txt) *
2+
* Copyright 1998-2025 by authors (see AUTHORS.txt) *
33
* *
44
* This file is part of LuxCoreRender. *
55
* *
@@ -47,6 +47,8 @@ using namespace std;
4747
using namespace luxcore;
4848
namespace py = pybind11;
4949

50+
51+
5052
namespace luxcore {
5153

5254
//------------------------------------------------------------------------------
@@ -952,6 +954,13 @@ static float Film_GetFilmY2(luxcore::detail::FilmImpl *film, const size_t imageP
952954
return film->GetFilmY(imagePipelineIndex);
953955
}
954956

957+
static void Film_ApplyOIDN(
958+
luxcore::detail::FilmImpl *film,
959+
const size_t imagePipelineIndex
960+
) {
961+
film->ApplyOIDN(imagePipelineIndex);
962+
}
963+
955964
//------------------------------------------------------------------------------
956965
// Glue for Camera class
957966
//------------------------------------------------------------------------------
@@ -2406,6 +2415,7 @@ PYBIND11_MODULE(pyluxcore, m) {
24062415
.def("AsyncExecuteImagePipeline", &luxcore::detail::FilmImpl::AsyncExecuteImagePipeline)
24072416
.def("HasDoneAsyncExecuteImagePipeline", &luxcore::detail::FilmImpl::HasDoneAsyncExecuteImagePipeline)
24082417
.def("WaitAsyncExecuteImagePipeline", &luxcore::detail::FilmImpl::WaitAsyncExecuteImagePipeline)
2418+
.def("ApplyOIDN", &Film_ApplyOIDN)
24092419
;
24102420

24112421
//--------------------------------------------------------------------------

0 commit comments

Comments
 (0)