LuxCoreRender / LuxCore

LuxCore source repository
Apache License 2.0
1.16k stars 145 forks source link

Disabling CUDA with -DLUXRAYS_DISABLE_CUDA still leaves some includes and components enabled #455

Closed Randrianasulu closed 4 years ago

Randrianasulu commented 4 years ago

Try to build current git (3b57fcec27d835cde0337e2090a5fda0aade7b2a) with

cmake -DLUXRAYS_DISABLE_CUDA=ON

It will leave some OPTIX/CUPA parts enabled.

I hard-disabled those parts .... I hope hack patch as txt will be attachinged ...)

Randrianasulu commented 4 years ago
cat disable_oidn_cuda_optix_python37.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 736bdeaa1..948c30a6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,7 +95,7 @@ include_directories("${LuxRays_INCLUDE_DIR}")
 include_directories("${LuxRays_SOURCE_DIR}/deps/json-3.7.3/include")
 include_directories("${LuxRays_SOURCE_DIR}/deps/cuew/include")
 include_directories("${LuxRays_SOURCE_DIR}/deps/clew/include")
-include_directories("${LuxRays_SOURCE_DIR}/deps/optix-7.1.0/include")
+#include_directories("${LuxRays_SOURCE_DIR}/deps/optix-7.1.0/include")
 include_directories("${LuxRays_SOURCE_DIR}/deps/spdlog-1.8.0/include")

 # Find dependencies
@@ -118,7 +118,7 @@ if (NOT EMBREE_FOUND)
 endif()

 if (NOT OIDN_FOUND)
-       MESSAGE(FATAL_ERROR "--> Could not locate required Intel Oidn files - Please check ${OIDN_SEARCH_PATH}")
+#      MESSAGE(FATAL_ERROR "--> Could not locate required Intel Oidn files - Please check ${OIDN_SEARCH_PATH}")
 endif()

 if (NOT TBB_FOUND)
@@ -156,7 +156,7 @@ if (BUILD_LUXCORE_DLL)
        set(LUXCORE_LIBRARY luxcore)
        ADD_DEFINITIONS("-DLUXCORE_DLL")
 else()
-       set(LUXCORE_LIBRARY luxcore slg-core slg-film slg-kernels luxrays bcd opensubdiv openvdb ${BLOSC_LIBRARY} ${EMBREE_LIBRARY} ${OIDN_LIBRARY} ${TBB_LIBRARY} ${TIFF_LIBRARIES} ${TIFF_LIBRARIES} ${OPENEXR_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES})
+       set(LUXCORE_LIBRARY luxcore slg-core slg-film slg-kernels luxrays bcd opensubdiv openvdb atomic python3.7m ${BLOSC_LIBRARY} ${EMBREE_LIBRARY} ${TBB_LIBRARY} ${TIFF_LIBRARIES} ${TIFF_LIBRARIES} ${OPENEXR_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES})
 endif()

 ################################################################################
@@ -189,7 +189,7 @@ if(NOT APPLE OR OSX_BUILD_DEMOS)

        if (NOT WIN32 OR NOT BUILD_LUXCORE_DLL)
                # Internal tests can not be compiled on WIN32 with DLL enabled
-               add_subdirectory(tests/luxcoreimplserializationdemo)
+               #add_subdirectory(tests/luxcoreimplserializationdemo)
        endif()
 endif()

diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 1cb27ea48..3882f1842 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -66,7 +66,7 @@ set(Boost_MINIMUM_VERSION       "1.56.0")

 # For Windows builds, PYTHON_V must be defined as "3x" (x=Python minor version, e.g. "35")
 # For other platforms, specifying python minor version is not needed
-set(LUXRAYS_BOOST_COMPONENTS thread program_options filesystem serialization iostreams regex system python${PYTHON_V} chrono serialization numpy${PYTHON_V})
+set(LUXRAYS_BOOST_COMPONENTS thread program_options filesystem serialization iostreams regex system python37 chrono serialization)
 find_package(Boost ${Boost_MINIMUM_VERSION} COMPONENTS ${LUXRAYS_BOOST_COMPONENTS})
 if (NOT Boost_FOUND)
         # Try again with the other type of libs
@@ -109,12 +109,12 @@ if (EMBREE_FOUND)
 endif ()

 # Intel Oidn
-set(OIDN_ROOT                "${OIDN_SEARCH_PATH}")
-find_package(Oidn REQUIRED)
+#set(OIDN_ROOT                "${OIDN_SEARCH_PATH}")
+#find_package(Oidn REQUIRED)

-if (OIDN_FOUND)
-       include_directories(BEFORE SYSTEM ${OIDN_INCLUDE_PATH})
-endif ()
+#if (OIDN_FOUND)
+#      include_directories(BEFORE SYSTEM ${OIDN_INCLUDE_PATH})
+#endif ()

 # Intel TBB
 set(TBB_ROOT                   "${TBB_SEARCH_PATH}")
diff --git a/include/slg/film/imagepipeline/plugins/intel_oidn.h b/include/slg/film/imagepipeline/plugins/intel_oidn.h
index 2ad57e407..51f6aa5f4 100644
--- a/include/slg/film/imagepipeline/plugins/intel_oidn.h
+++ b/include/slg/film/imagepipeline/plugins/intel_oidn.h
@@ -15,6 +15,7 @@
  * See the License for the specific language governing permissions and     *
  * limitations under the License.                                          *
  ***************************************************************************/
+#if 0

 #ifndef _SLG_INTEL_OIDN_H
 #define        _SLG_INTEL_OIDN_H
@@ -25,6 +26,7 @@

 #include <OpenImageDenoise/oidn.hpp>

+
 #include "luxrays/luxrays.h"
 #include "luxrays/core/color/color.h"
 #include "slg/film/film.h"
@@ -73,4 +75,5 @@ BOOST_CLASS_VERSION(slg::IntelOIDN, 3)

 BOOST_CLASS_EXPORT_KEY(slg::IntelOIDN)

-#endif /* _SLG_INTEL_OIDN_H */
\ No newline at end of file
+#endif /* _SLG_INTEL_OIDN_H */
+#endif
\ No newline at end of file
diff --git a/include/slg/film/imagepipeline/plugins/optixdenoiser.h b/include/slg/film/imagepipeline/plugins/optixdenoiser.h
index 5c748a56a..351949297 100644
--- a/include/slg/film/imagepipeline/plugins/optixdenoiser.h
+++ b/include/slg/film/imagepipeline/plugins/optixdenoiser.h
@@ -25,7 +25,9 @@

 #include <boost/serialization/export.hpp>

+#if 0
 #include <OpenImageDenoise/oidn.hpp>
+#endif

 #include "luxrays/luxrays.h"
 #include "luxrays/core/color/color.h"
diff --git a/src/luxcore/luxcore.cpp b/src/luxcore/luxcore.cpp
index 869141ab3..fc1b302ed 100644
--- a/src/luxcore/luxcore.cpp
+++ b/src/luxcore/luxcore.cpp
@@ -203,6 +203,7 @@ Properties luxcore::GetOpenCLDeviceDescs() {
                                Property(prefix + ".localmemory")((unsigned long long)deviceLocalMem) <<
                                Property(prefix + ".constmemory")((unsigned long long)deviceConstMem);

+#if 0
                if (desc->GetType() & DEVICE_TYPE_CUDA_ALL) {
                        const CUDADeviceDescription *cudaDesc = (CUDADeviceDescription *)desc;

@@ -210,6 +211,7 @@ Properties luxcore::GetOpenCLDeviceDescs() {
                                        Property(prefix + ".cuda.compute.major")(cudaDesc->GetCUDAComputeCapabilityMajor()) <<
                                        Property(prefix + ".cuda.compute.minor")(cudaDesc->GetCUDAComputeCapabilityMinor());
                }
+#endif // cuda disable
        }
 #endif

diff --git a/src/luxrays/accelerators/optixaccel.cpp b/src/luxrays/accelerators/optixaccel.cpp
index 540d48c2d..87f63f84c 100644
--- a/src/luxrays/accelerators/optixaccel.cpp
+++ b/src/luxrays/accelerators/optixaccel.cpp
@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and     *
  * limitations under the License.                                          *
  ***************************************************************************/
-
+#if 0
 #include "luxrays/accelerators/optixaccel.h"
 #include "luxrays/utils/utils.h"
 #include "luxrays/core/context.h"
@@ -57,3 +57,4 @@ bool OptixAccel::Intersect(const Ray *initialRay, RayHit *rayHit) const {
 }

 }
+#endif // optix disable
\ No newline at end of file
diff --git a/src/luxrays/accelerators/optixaccelhw.cpp b/src/luxrays/accelerators/optixaccelhw.cpp
index 132b20d4b..3326e59ff 100644
--- a/src/luxrays/accelerators/optixaccelhw.cpp
+++ b/src/luxrays/accelerators/optixaccelhw.cpp
@@ -14,7 +14,9 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
  * See the License for the specific language governing permissions and     *
  * limitations under the License.                                          *
+
  ***************************************************************************/
+#if 0

 #include "luxrays/core/context.h"
 #include "luxrays/core/exttrianglemesh.h"
@@ -760,3 +762,4 @@ HardwareIntersectionKernel *OptixAccel::NewHardwareIntersectionKernel(HardwareIn
 }

 }
+#endif
\ No newline at end of file
diff --git a/src/luxrays/core/context.cpp b/src/luxrays/core/context.cpp
index d8098a3b9..d479be5dc 100644
--- a/src/luxrays/core/context.cpp
+++ b/src/luxrays/core/context.cpp
@@ -147,13 +147,14 @@ Context::Context(LuxRaysDebugHandler handler, const Properties &config) : cfg(co

                LR_LOG(this, "Device " << i << " has out of core memory support: " <<
                        desc->HasOutOfCoreMemorySupport());
-
+#if !defined(LUXRAYS_DISABLE_CUDA)
                if (desc->GetType() & DEVICE_TYPE_CUDA_ALL) {
                        const CUDADeviceDescription *cudaDesc = (CUDADeviceDescription *)desc;

                        LR_LOG(this, "Device " << i << " CUDA compute capability: " <<
                                        cudaDesc->GetCUDAComputeCapabilityMajor() << "." << cudaDesc->GetCUDAComputeCapabilityMinor());
                }
+#endif
        }
 }

diff --git a/src/luxrays/core/dataset.cpp b/src/luxrays/core/dataset.cpp
index 6e02a1a2c..76b43410d 100644
--- a/src/luxrays/core/dataset.cpp
+++ b/src/luxrays/core/dataset.cpp
@@ -28,7 +28,9 @@
 #include "luxrays/accelerators/bvhaccel.h"
 #include "luxrays/accelerators/mbvhaccel.h"
 #include "luxrays/accelerators/embreeaccel.h"
+#if 0
 #include "luxrays/accelerators/optixaccel.h"
+#endif // optix
 #include "luxrays/core/geometry/bsphere.h"

 using namespace luxrays;
@@ -129,9 +131,11 @@ const Accelerator *DataSet::GetAccelerator(const AcceleratorType accelType) {
                        case ACCEL_EMBREE:
                                accel = new EmbreeAccel(context);
                                break;
+#if 0
                        case ACCEL_OPTIX:
                                accel = new OptixAccel(context);
                                break;
+#endif // optix disable
                        default:
                                throw runtime_error("Unknown AcceleratorType in DataSet::AddAccelerator()");
                }
diff --git a/src/slg/engines/oclrenderengine.cpp b/src/slg/engines/oclrenderengine.cpp
index 2d283a421..314d4d488 100644
--- a/src/slg/engines/oclrenderengine.cpp
+++ b/src/slg/engines/oclrenderengine.cpp
@@ -22,6 +22,8 @@
 #include "luxrays/utils/thread.h"
 #if !defined(LUXRAYS_DISABLE_OPENCL)
 #include "luxrays/devices/ocldevice.h"
+#endif
+#if 0
 #include "luxrays/devices/cudadevice.h"
 #endif

@@ -62,12 +64,12 @@ OCLRenderEngine::OCLRenderEngine(const RenderConfig *rcfg,
        vector<DeviceDescription *> oclDescs = ctx->GetAvailableDeviceDescriptions();
        DeviceDescription::Filter(DEVICE_TYPE_OPENCL_ALL, oclDescs);

-       vector<DeviceDescription *> cudaDescs = ctx->GetAvailableDeviceDescriptions();
-       DeviceDescription::Filter(DEVICE_TYPE_CUDA_ALL, cudaDescs);
+//     vector<DeviceDescription *> cudaDescs = ctx->GetAvailableDeviceDescriptions();
+//     DeviceDescription::Filter(DEVICE_TYPE_CUDA_ALL, cudaDescs);

        vector<DeviceDescription *> descs;
        descs.insert(descs.end(), oclDescs.begin(), oclDescs.end());
-       descs.insert(descs.end(), cudaDescs.begin(), cudaDescs.end());
+//     descs.insert(descs.end(), cudaDescs.begin(), cudaDescs.end());

        // Device info
        bool haveSelectionString = (oclDeviceConfig.length() > 0);
@@ -119,6 +121,7 @@ OCLRenderEngine::OCLRenderEngine(const RenderConfig *rcfg,
        }

        // Enable/Disable Optix according cuda.optix.devices.select string
+#if 0
        if ((cudaDeviceCount > 0) && (cudaOptixDeviceConfig.length() > 0)) {
                size_t cudaDeviceIndex = 0;
                for (size_t i = 0; i < descs.size(); ++i) {
@@ -139,6 +142,7 @@ OCLRenderEngine::OCLRenderEngine(const RenderConfig *rcfg,
                        }
                }
        }
+#endif

        oclRenderThreadCount = selectedDeviceDescs.size();
 #endif
diff --git a/src/slg/engines/pathoclbase/pathoclbase.cpp b/src/slg/engines/pathoclbase/pathoclbase.cpp
index 029538fba..962b0a735 100644
--- a/src/slg/engines/pathoclbase/pathoclbase.cpp
+++ b/src/slg/engines/pathoclbase/pathoclbase.cpp
@@ -67,7 +67,7 @@ PathOCLBaseRenderEngine::PathOCLBaseRenderEngine(const RenderConfig *rcfg,
        //--------------------------------------------------------------------------
        // Add CUDA devices
        //--------------------------------------------------------------------------
-
+#if 0
        SLG_LOG("CUDA devices used:");
        for (size_t i = 0; i < devs.size(); ++i) {
                if (devs[i]->GetDeviceDesc()->GetType() & DEVICE_TYPE_CUDA_ALL) {
@@ -84,7 +84,7 @@ PathOCLBaseRenderEngine::PathOCLBaseRenderEngine(const RenderConfig *rcfg,
                        hwDev->SetAdditionalCompileOpts(compileOpts);
                }
        }
-
+#endif // cuda disable
        //--------------------------------------------------------------------------
        // Add OpenCL devices
        //--------------------------------------------------------------------------
diff --git a/src/slg/film/film.cpp b/src/slg/film/film.cpp
index eb486c117..d412d0027 100644
--- a/src/slg/film/film.cpp
+++ b/src/slg/film/film.cpp
@@ -25,6 +25,7 @@

 #include "slg/film/film.h"
 #include "slg/film/sampleresult.h"
+#include "slg/film/imagepipeline/imagepipeline.h"
 #include "slg/utils/varianceclamping.h"
 #include "slg/film/denoiser/filmdenoiser.h"

@@ -183,7 +184,9 @@ Film::Film(const u_int w, const u_int h, const u_int *sr) : filmDenoiser(this) {
        // Initialize variables to nullptr
        SetUpHW();
 }
+#if 0
 #include <slg/film/imagepipeline/plugins/optixdenoiser.h>
+#endif // optix disable
 Film::~Film() {
        if (imagePipelineThread) {
                imagePipelineThread->interrupt();
diff --git a/src/slg/film/filmimagepipeline.cpp b/src/slg/film/filmimagepipeline.cpp
index 1eed57cfe..c7543a6ff 100644
--- a/src/slg/film/filmimagepipeline.cpp
+++ b/src/slg/film/filmimagepipeline.cpp
@@ -68,16 +68,25 @@ void Film::SetImagePipelines(std::vector<ImagePipeline *> &newImagePiepelines) {
 }

 void Film::MergeSampleBuffers(const u_int imagePipelineIndex) {
+       bool rpcs;
        const ImagePipeline *ip = (imagePipelineIndex < imagePipelines.size()) ? imagePipelines[imagePipelineIndex] : NULL;
-
+       //printf("1 - channel->clear \n");
        channel_IMAGEPIPELINEs[imagePipelineIndex]->Clear();
+       //printf("2 - channel->getPixels \n");
        Spectrum *p = (Spectrum *)channel_IMAGEPIPELINEs[imagePipelineIndex]->GetPixels();
-
+       //printf("3 - channel->getPixels DONE\n");
        // Merge RADIANCE_PER_PIXEL_NORMALIZED and RADIANCE_PER_SCREEN_NORMALIZED buffers

        if (HasChannel(RADIANCE_PER_PIXEL_NORMALIZED)) {
+       //printf("Radiance groupcount \n");
+       //printf("%i\n", radianceGroupCount);
                for (u_int i = 0; i < radianceGroupCount; ++i) {
-                       if (!ip || ip->radianceChannelScales[i].enabled) {
+//             printf("%i\n", i);
+
+                       if (ip)
+                       rpcs = ip->radianceChannelScales[i].enabled;
+                       if (!ip  || rpcs /*  ip->radianceChannelScales[i].enabled */) {
+//                     printf ("Before for loop  ... \n");
                                #pragma omp parallel for
                                for (
                                                // Visual C++ 2013 supports only OpenMP 2.5
@@ -99,10 +108,12 @@ void Film::MergeSampleBuffers(const u_int imagePipelineIndex) {
                }
        }

+//printf("Merged RADIANCE_PER_PIXEL_NORMALIZED and RADIANCE_PER_SCREEN_NORMALIZED buffers \n");
+
        if (HasChannel(RADIANCE_PER_SCREEN_NORMALIZED)) {
                const double RADIANCE_PER_SCREEN_NORMALIZED_SampleCount = samplesCounts.GetSampleCount_RADIANCE_PER_SCREEN_NORMALIZED();
                const float factor = (RADIANCE_PER_SCREEN_NORMALIZED_SampleCount > 0) ? (pixelCount / RADIANCE_PER_SCREEN_NORMALIZED_SampleCount) : 1.f;
-
+//             printf("Radiance per screen normalized loop \n");
                for (u_int i = 0; i < radianceGroupCount; ++i) {
                        if (!ip || ip->radianceChannelScales[i].enabled) {
                                #pragma omp parallel for
diff --git a/src/slg/film/filmimagepipelinehw.cpp b/src/slg/film/filmimagepipelinehw.cpp
index 559662091..136fdd1c4 100644
--- a/src/slg/film/filmimagepipelinehw.cpp
+++ b/src/slg/film/filmimagepipelinehw.cpp
@@ -24,7 +24,9 @@
 #include "slg/film/imagepipeline/imagepipeline.h"
 #include "slg/film/imagepipeline/radiancechannelscale.h"
 #include "slg/kernels/kernels.h"
+#if 0
 #include "luxrays/devices/cudadevice.h"
+#endif

 using namespace std;
 using namespace luxrays;
@@ -78,11 +80,13 @@ void Film::CreateHWContext() {
                        for (size_t i = 0; i < descs.size(); ++i) {
                                DeviceDescription *desc = descs[i];

+#if 0
                                if (desc->GetType() == DEVICE_TYPE_CUDA_GPU) {
                                        selectedDeviceDesc = desc;
                                        break;
-
                                }
+#endif
+
                                if (desc->GetType() == DEVICE_TYPE_OPENCL_GPU) {
                                        selectedDeviceDesc = desc;
                                        // I continue to scan other devices to check if there is a
@@ -96,11 +100,12 @@ void Film::CreateHWContext() {

        if (selectedDeviceDesc) {
                // Force the Optix usage also on no-RTX GPUs for Optix denoiser plugin
+#if 0
                if (selectedDeviceDesc->GetType() == DEVICE_TYPE_CUDA_GPU) {
                        CUDADeviceDescription *cudaDeviceDesc = (CUDADeviceDescription *)selectedDeviceDesc;
                        cudaDeviceDesc->SetCUDAUseOptix(true);
                }
-
+#endif
                // Allocate the device
                vector<luxrays::DeviceDescription *> selectedDeviceDescs;
                selectedDeviceDescs.push_back(selectedDeviceDesc);
diff --git a/src/slg/film/filmparse.cpp b/src/slg/film/filmparse.cpp
index 892184183..1c86a26e9 100644
--- a/src/slg/film/filmparse.cpp
+++ b/src/slg/film/filmparse.cpp
@@ -721,12 +721,12 @@ ImagePipeline *Film::CreateImagePipeline(const Properties &props, const string &
                        } else if (type == "PATTERNS") {
                                const u_int type = props.Get(Property(prefix + ".index")(0)).Get<u_int>();
                                imagePipeline->AddPlugin(new PatternsPlugin(type));
-                       } else if (type == "INTEL_OIDN") {
+                       } else if /* (type == "INTEL_OIDN")  {
                                const string filterType = props.Get(Property(prefix + ".filter.type")("RT")).Get<string>();
                                const int oidnMemLimit = props.Get(Property(prefix + ".oidnmemory")(6000)).Get<int>();
                                const float sharpness = Clamp(props.Get(Property(prefix + ".sharpness")(.1f)).Get<float>(), 0.f, 1.f);
                                imagePipeline->AddPlugin(new IntelOIDN(filterType, oidnMemLimit, sharpness));
-                       } else if (type == "WHITE_BALANCE") {
+                       } else if */ (type == "WHITE_BALANCE") {
                                const float temperature = Clamp(props.Get(Property(prefix + ".temperature")(6500.f)).Get<float>(), 1000.f, 40000.f);
                                const bool reverse = props.Get(Property(prefix + ".reverse")(true)).Get<bool>();
                                const bool normalize = props.Get(Property(prefix + ".normalize")(false)).Get<bool>();
diff --git a/src/slg/film/imagepipeline/plugins/intel_oidn.cpp b/src/slg/film/imagepipeline/plugins/intel_oidn.cpp
index 735f2bb0d..ce313ba8a 100644
--- a/src/slg/film/imagepipeline/plugins/intel_oidn.cpp
+++ b/src/slg/film/imagepipeline/plugins/intel_oidn.cpp
@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and     *
  * limitations under the License.                                          *
  ***************************************************************************/
-
+#if 0
 #include <math.h>

 #include <boost/format.hpp>
@@ -109,4 +109,5 @@ void IntelOIDN::Apply(Film &film, const u_int index) {
        }

        SLG_LOG("IntelOIDNPlugin single execution took a total of " << (boost::format("%.3f") % (WallClockTime() - totalStartTime)) << "secs");
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
Dade916 commented 4 years ago

I should have fixed this problem.