From be5f561005b41340c6d6cb929a3a851d41d62b97 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 10 Dec 2022 00:17:09 +1100 Subject: [PATCH] Cycles shared library Differential Revision: https://developer.blender.org/D16736 --- CMakeLists.txt | 3 + src/CMakeLists.txt | 82 +++++++++++++++++++++- src/app/CMakeLists.txt | 15 +++- src/app/cycles_standalone.cpp | 2 +- src/bvh/CMakeLists.txt | 4 ++ src/cycles.h | 63 +++++++++++++++++ src/cycles_config.h.in | 109 ++++++++++++++++++++++++++++++ src/device/CMakeLists.txt | 4 ++ src/device/oneapi/device_impl.cpp | 2 +- src/graph/CMakeLists.txt | 4 ++ src/hydra/CMakeLists.txt | 28 ++++++-- src/hydra/config.h | 2 +- src/integrator/CMakeLists.txt | 5 ++ src/integrator/denoiser_optix.cpp | 12 ++-- src/scene/CMakeLists.txt | 4 ++ src/scene/alembic.cpp | 8 +-- src/scene/alembic.h | 2 +- src/scene/mesh_subdivision.cpp | 36 +++++----- src/scene/scene.cpp | 4 +- src/scene/volume.cpp | 2 +- src/session/CMakeLists.txt | 4 ++ src/subd/CMakeLists.txt | 4 ++ src/util/CMakeLists.txt | 4 ++ src/util/boundbox.h | 28 ++++---- 24 files changed, 371 insertions(+), 60 deletions(-) create mode 100644 src/cycles.h create mode 100644 src/cycles_config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 2658d5ed3..558b17a3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,6 +167,9 @@ option(WITH_CYCLES_HYDRA_RENDER_DELEGATE "Build Cycles Hydra render delegate" ON # Error Checking option(WITH_STRICT_BUILD_OPTIONS "When requirements for a build option are not met, error instead of disabling the option" OFF) +# Cycles Shared Library +option(WITH_CYCLES_SHARED_LIBRARY "Build the Cycles library as a shared library. App and the Hydra delegate will link to this instead of static-linking." ON) + ########################################################################### # Configuration. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f0d3df2b..9599949d9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -194,9 +194,14 @@ add_definitions( ${OPENIMAGEIO_DEFINITIONS} ) +set(CCL_NAMESPACE_BEGIN "namespace\ cycles\ {") +set(CCL_NAMESPACE_END "}") +set(CCL_NS "cycles") + add_definitions( - -DCCL_NAMESPACE_BEGIN=namespace\ ccl\ { + -DCCL_NAMESPACE_BEGIN=namespace\ cycles\ { -DCCL_NAMESPACE_END=} + -DCCL_NS=cycles ) include_directories( @@ -365,6 +370,7 @@ if(WITH_CYCLES_PATH_GUIDING) # 4 = 3 + training the guiding fields # 5 = 4 + querying the trained guiding for sampling (full path guiding) add_definitions(-DPATH_GUIDING_LEVEL=5) + set(PATH_GUIDING_LEVEL "5") include_directories( SYSTEM @@ -454,3 +460,77 @@ endif() if(NOT WITH_BLENDER) delayed_do_install() endif() + +# Cycles API + +if(WITH_CYCLES_SHARED_LIBRARY) + set(LIB) + + set(SRC_HEADERS + cycles.h + ) + + set(OBJECT_LIB + $ + $ + $ + $ + $ + $ + $ + $ + $ + ) + + if(WITH_CYCLES_OSL) + list(APPEND OBJECT_LIB $) + endif() + + if(CYCLES_STANDALONE_REPOSITORY) + list(APPEND LIB extern_sky) + else() + list(APPEND LIB bf_intern_sky) + endif() + + cycles_external_libraries_append(LIB) + + add_library(cycles_library SHARED ${SRC_HEADERS} ${OBJECT_LIB}) + set_target_properties(cycles_library PROPERTIES OUTPUT_NAME "cycles") + set_target_properties(cycles_library PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS true) + target_link_libraries(cycles_library PRIVATE ${LIB}) + + install(TARGETS + cycles_library + DESTINATION ${CMAKE_INSTALL_PREFIX} + ) +endif() + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + configure_file(cycles_config.h.in cycles_config.h @ONLY) + + install(FILES + ${CMAKE_BINARY_DIR}/src/cycles_config.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include + ) + + install(FILES + cycles.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include + ) + + if(CYCLES_STANDALONE_REPOSITORY) + install(FILES + ../third_party/atomic/atomic_ops.h + ../third_party/sky/include/sky_model.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include + ) + + install(FILES + ../third_party/atomic/intern/atomic_ops_msvc.h + ../third_party/atomic/intern/atomic_ops_utils.h + ../third_party/atomic/intern/atomic_ops_unix.h + ../third_party/atomic/intern/atomic_ops_ext.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/intern + ) + endif() +endif() diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 796fe3253..edd64990f 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -12,6 +12,9 @@ set(INC_SYS ) set(LIB +) + +set(CYCLES_LIB cycles_device cycles_kernel cycles_scene @@ -22,6 +25,8 @@ set(LIB cycles_util ) +set(USD_LIB) + if(WITH_ALEMBIC) add_definitions(-DWITH_ALEMBIC) list(APPEND INC_SYS @@ -33,7 +38,7 @@ if(WITH_ALEMBIC) endif() if(WITH_CYCLES_OSL) - list(APPEND LIB cycles_kernel_osl) + list(APPEND CYCLES_LIB cycles_kernel_osl) endif() if(CYCLES_STANDALONE_REPOSITORY) @@ -60,7 +65,7 @@ if(WITH_USD) list(APPEND INC_SYS ${USD_INCLUDE_DIRS} ) - list(APPEND LIB + list(APPEND USD_LIB cycles_hydra ${USD_LIBRARIES} ) @@ -98,7 +103,11 @@ if(WITH_CYCLES_STANDALONE) add_executable(cycles ${SRC} ${INC} ${INC_SYS}) unset(SRC) - target_link_libraries(cycles PRIVATE ${LIB}) + if(WITH_CYCLES_SHARED_LIBRARY) + target_link_libraries(cycles PUBLIC cycles_library ${USD_LIB}) + else() + target_link_libraries(cycles PRIVATE ${CYCLES_LIB} ${LIB} ${USD_LIB}) + endif() if(APPLE) if(WITH_CYCLES_STANDALONE_GUI) diff --git a/src/app/cycles_standalone.cpp b/src/app/cycles_standalone.cpp index 8b40adc8d..2709ce16f 100644 --- a/src/app/cycles_standalone.cpp +++ b/src/app/cycles_standalone.cpp @@ -528,7 +528,7 @@ static void options_parse(int argc, const char **argv) CCL_NAMESPACE_END -using namespace ccl; +using namespace cycles; int main(int argc, const char **argv) { diff --git a/src/bvh/CMakeLists.txt b/src/bvh/CMakeLists.txt index 0c3499df4..926ba733d 100644 --- a/src/bvh/CMakeLists.txt +++ b/src/bvh/CMakeLists.txt @@ -64,3 +64,7 @@ if(WITH_CYCLES_EMBREE) endif() cycles_add_library(cycles_bvh "${LIB}" ${SRC} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/bvh) +endif() diff --git a/src/cycles.h b/src/cycles.h new file mode 100644 index 000000000..1550bddef --- /dev/null +++ b/src/cycles.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2023 Blender Foundation */ + +#ifndef __CYCLES_H__ +#define __CYCLES_H__ + +#include "cycles_config.h" + +#include "bvh/params.h" +#include "device/device.h" +#include "graph/node.h" +#include "graph/node_type.h" +#include "kernel/types.h" +#include "scene/background.h" +#include "scene/attribute.h" +#include "scene/camera.h" +#include "scene/curves.h" +#include "scene/film.h" +#include "scene/geometry.h" +#include "scene/shader_graph.h" +#include "scene/hair.h" +#include "scene/image.h" +#include "scene/image_vdb.h" +#include "scene/integrator.h" +#include "scene/light.h" +#include "scene/mesh.h" +#include "scene/pass.h" +#include "scene/pointcloud.h" +#include "scene/shader.h" +#include "scene/shader_graph.h" +#include "scene/shader_nodes.h" +#include "scene/object.h" +#include "scene/osl.h" +#include "scene/scene.h" +#include "scene/shader_nodes.h" +#include "scene/volume.h" +#include "session/buffers.h" +#include "session/display_driver.h" +#include "session/output_driver.h" +#include "session/session.h" +#include "subd/dice.h" +#include "util/args.h" +#include "util/array.h" +#include "util/foreach.h" +#include "util/function.h" +#include "util/half.h" +#include "util/hash.h" +#include "util/image.h" +#include "util/log.h" +#include "util/murmurhash.h" +#include "util/openimagedenoise.h" +#include "util/path.h" +#include "util/param.h" +#include "util/progress.h" +#include "util/string.h" +#include "util/thread.h" +#include "util/time.h" +#include "util/transform.h" +#include "util/unique_ptr.h" +#include "util/vector.h" +#include "util/version.h" + +#endif /* __CYCLES_H__ */ diff --git a/src/cycles_config.h.in b/src/cycles_config.h.in new file mode 100644 index 000000000..21358fe1f --- /dev/null +++ b/src/cycles_config.h.in @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2023 Blender Foundation */ + +#ifndef __CYCLES_CONFIG_H__ +#define __CYCLES_CONFIG_H__ + +#define CCL_NAMESPACE_BEGIN @CCL_NAMESPACE_BEGIN@ +#define CCL_NAMESPACE_END @CCL_NAMESPACE_END@ +#define CCL_NS @CCL_NS@ +#define CCL_NAMESPACE_USING_DIRECTIVE using namespace CCL_NS; + +#cmakedefine WITH_CYCLES_DEBUG +#cmakedefine WITH_CYCLES_STANDALONE_GUI + +#cmakedefine WITH_CYCLES_PTEX +#ifdef WITH_CYCLES_PTEX +# define WITH_PTEX +#endif + +#cmakedefine WITH_CYCLES_OSL +#ifdef WITH_CYCLES_OSL +# define WITH_OSL +#endif + +#cmakedefine WITH_CYCLES_DEVICE_CUDA +#ifdef WITH_CYCLES_DEVICE_CUDA +# define WITH_CUDA +#endif + +#cmakedefine WITH_CYCLES_DEVICE_OPTIX +#ifdef WITH_CYCLES_DEVICE_OPTIX +# define WITH_OPTIX +#endif + +#cmakedefine WITH_CYCLES_DEVICE_HIP +#ifdef WITH_CYCLES_DEVICE_HIP +# define WITH_HIP +#endif + +#cmakedefine WITH_CYCLES_DEVICE_METAL +#ifdef WITH_CYCLES_DEVICE_METAL +# define WITH_METAL +#endif + +#cmakedefine WITH_CYCLES_DEVICE_ONEAPI +#ifdef WITH_CYCLES_DEVICE_ONEAPI +# define WITH_ONEAPI +#endif + +#cmakedefine WITH_CYCLES_EMBREE +#ifdef WITH_CYCLES_EMBREE +# define WITH_EMBREE +#endif + +#cmakedefine WITH_CYCLES_OPENIMAGEDENOISE +#ifdef WITH_CYCLES_OPENIMAGEDENOISE +# define WITH_OPENIMAGEDENOISE +#endif + +#cmakedefine WITH_CYCLES_LOGGING +#ifdef WITH_CYCLES_LOGGING +# define CYCLES_GFLAGS_NAMESPACE=@GFLAGS_NAMESPACE@ +#endif + +#cmakedefine WITH_CYCLES_ALEMBIC +#ifdef WITH_CYCLES_ALEMBIC +# define WITH_ALEMBIC +#endif + +#cmakedefine WITH_CYCLES_OPENVDB +#ifdef WITH_CYCLES_OPENVDB +# define WITH_OPENVDB +#endif + +#cmakedefine WITH_CYCLES_NANOVDB +#ifdef WITH_CYCLES_NANOVDB +# define WITH_NANOVDB +#endif + +#cmakedefine WITH_CYCLES_OPENSUBDIV +#ifdef WITH_CYCLES_OPENSUBDIV +# define WITH_OPENSUBDIV +#endif + +#cmakedefine WITH_CYCLES_OPENCOLORIO +#ifdef WITH_CYCLES_OPENCOLORIO +# define WITH_OPENCOLORIO +# define WITH_OCIO +#endif + +#cmakedefine WITH_CYCLES_PATH_GUIDING +#ifdef WITH_CYCLES_PATH_GUIDING +# define WITH_PATH_GUIDING +# define PATH_GUIDING_LEVEL=@PATH_GUIDING_LEVEL@ +#endif + +#cmakedefine WITH_CYCLES_DEBUG_NAN + +#cmakedefine WITH_CYCLES_USD +#ifdef WITH_CYCLES_USD +# define WITH_USD +#endif + +#cmakedefine WITH_CYCLES_BLENDER +#ifdef WITH_CYCLES_BLENDER +# define WITH_BLENDER_GUARDEDALLOC +#endif + +#endif /* __CYCLES_CONFIG_H__ */ diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index 8ec15c6f3..0ddfd8d70 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -216,3 +216,7 @@ source_group("metal" FILES ${SRC_METAL}) source_group("optix" FILES ${SRC_OPTIX}) source_group("oneapi" FILES ${SRC_ONEAPI}) source_group("common" FILES ${SRC_BASE} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/device) +endif() diff --git a/src/device/oneapi/device_impl.cpp b/src/device/oneapi/device_impl.cpp index 0aec8268b..81aeaad3b 100644 --- a/src/device/oneapi/device_impl.cpp +++ b/src/device/oneapi/device_impl.cpp @@ -148,7 +148,7 @@ void OneapiDevice::generic_alloc(device_memory &mem) string_human_readable_size(max_memory_on_device_) + " is already allocated"); } - mem.device_pointer = reinterpret_cast(device_pointer); + mem.device_pointer = reinterpret_cast(device_pointer); mem.device_size = memory_size; stats.mem_alloc(memory_size); diff --git a/src/graph/CMakeLists.txt b/src/graph/CMakeLists.txt index d183b77c6..e8c22bbd9 100644 --- a/src/graph/CMakeLists.txt +++ b/src/graph/CMakeLists.txt @@ -29,3 +29,7 @@ include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) cycles_add_library(cycles_graph "${LIB}" ${SRC} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/graph) +endif() diff --git a/src/hydra/CMakeLists.txt b/src/hydra/CMakeLists.txt index cfd25ce77..646bbbde7 100644 --- a/src/hydra/CMakeLists.txt +++ b/src/hydra/CMakeLists.txt @@ -14,10 +14,13 @@ set(INC_SYS ${PYTHON_INCLUDE_DIRS} ) -set(LIB +set(CYCLES_LIB cycles_scene cycles_session cycles_graph +) + +set(LIB ${Epoxy_LIBRARIES} ) cycles_external_libraries_append(LIB) @@ -107,12 +110,23 @@ target_compile_definitions(cycles_hydra $<$:NOMINMAX=1> ) -target_link_libraries(cycles_hydra - PUBLIC - ${USD_LIBRARIES} - PRIVATE - ${LIB} -) +if(WITH_CYCLES_SHARED_LIBRARY) + target_link_libraries(cycles_hydra + PUBLIC + ${USD_LIBRARIES} + cycles_library + PRIVATE + ${LIB} + ) +else() + target_link_libraries(cycles_hydra + PUBLIC + ${USD_LIBRARIES} + PRIVATE + ${CYCLES_LIB} + ${LIB} + ) +endif() if(WITH_CYCLES_HYDRA_RENDER_DELEGATE) set(HdCyclesPluginName hdCycles) diff --git a/src/hydra/config.h b/src/hydra/config.h index 479980e0c..d6a45f9d3 100644 --- a/src/hydra/config.h +++ b/src/hydra/config.h @@ -6,7 +6,7 @@ #include -#define CCL_NS ccl +#define CCL_NS cycles #define CCL_NAMESPACE_USING_DIRECTIVE using namespace CCL_NS; #define HD_CYCLES_NS HdCycles diff --git a/src/integrator/CMakeLists.txt b/src/integrator/CMakeLists.txt index 0559a3e94..bef40a9e5 100644 --- a/src/integrator/CMakeLists.txt +++ b/src/integrator/CMakeLists.txt @@ -36,6 +36,7 @@ set(SRC_HEADERS denoiser_gpu.h denoiser_oidn.h denoiser_optix.h + guiding.h path_trace.h tile.h pass_accessor.h @@ -78,3 +79,7 @@ include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) cycles_add_library(cycles_integrator "${LIB}" ${SRC} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/integrator) +endif() diff --git a/src/integrator/denoiser_optix.cpp b/src/integrator/denoiser_optix.cpp index 956c2144f..ef353fde2 100644 --- a/src/integrator/denoiser_optix.cpp +++ b/src/integrator/denoiser_optix.cpp @@ -104,7 +104,7 @@ static OptixResult optixUtilDenoiserInvokeTiled(OptixDenoiser denoiser, std::vector> tiles(numLayers); std::vector> prevTiles(numLayers); for (unsigned int l = 0; l < numLayers; l++) { - if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(layers[l].input, + if (const OptixResult res = CCL_NS::optixUtilDenoiserSplitImage(layers[l].input, layers[l].output, overlapWindowSizeInPixels, tileWidth, @@ -114,7 +114,7 @@ static OptixResult optixUtilDenoiserInvokeTiled(OptixDenoiser denoiser, if (layers[l].previousOutput.data) { OptixImage2D dummyOutput = layers[l].previousOutput; - if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(layers[l].previousOutput, + if (const OptixResult res = CCL_NS::optixUtilDenoiserSplitImage(layers[l].previousOutput, dummyOutput, overlapWindowSizeInPixels, tileWidth, @@ -127,7 +127,7 @@ static OptixResult optixUtilDenoiserInvokeTiled(OptixDenoiser denoiser, std::vector albedoTiles; if (guideLayer->albedo.data) { OptixImage2D dummyOutput = guideLayer->albedo; - if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(guideLayer->albedo, + if (const OptixResult res = CCL_NS::optixUtilDenoiserSplitImage(guideLayer->albedo, dummyOutput, overlapWindowSizeInPixels, tileWidth, @@ -139,7 +139,7 @@ static OptixResult optixUtilDenoiserInvokeTiled(OptixDenoiser denoiser, std::vector normalTiles; if (guideLayer->normal.data) { OptixImage2D dummyOutput = guideLayer->normal; - if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(guideLayer->normal, + if (const OptixResult res = CCL_NS::optixUtilDenoiserSplitImage(guideLayer->normal, dummyOutput, overlapWindowSizeInPixels, tileWidth, @@ -150,7 +150,7 @@ static OptixResult optixUtilDenoiserInvokeTiled(OptixDenoiser denoiser, std::vector flowTiles; if (guideLayer->flow.data) { OptixImage2D dummyOutput = guideLayer->flow; - if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(guideLayer->flow, + if (const OptixResult res = CCL_NS::optixUtilDenoiserSplitImage(guideLayer->flow, dummyOutput, overlapWindowSizeInPixels, tileWidth, @@ -763,7 +763,7 @@ bool OptiXDenoiser::denoise_run(const DenoiseContext &context, const DenoisePass OptixDenoiserParams params = {}; /* All parameters are disabled/zero. */ optix_device_assert(denoiser_device_, - ccl::optixUtilDenoiserInvokeTiled( + CCL_NS::optixUtilDenoiserInvokeTiled( optix_denoiser_, static_cast(denoiser_queue_.get())->stream(), ¶ms, diff --git a/src/scene/CMakeLists.txt b/src/scene/CMakeLists.txt index 2aa1c0b1a..25b329c09 100644 --- a/src/scene/CMakeLists.txt +++ b/src/scene/CMakeLists.txt @@ -149,3 +149,7 @@ include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) cycles_add_library(cycles_scene "${LIB}" ${SRC} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/scene) +endif() diff --git a/src/scene/alembic.cpp b/src/scene/alembic.cpp index fa790127f..e77a9a09b 100644 --- a/src/scene/alembic.cpp +++ b/src/scene/alembic.cpp @@ -703,7 +703,7 @@ static void update_attributes(AttributeSet &attributes, CachedData &cached_data, continue; } - const ccl::array &attr_data = result.get_data(); + const CCL_NS::array &attr_data = result.get_data(); /* weak way of detecting if the topology has changed * todo: reuse code from device_update patch */ @@ -757,9 +757,9 @@ AlembicProcedural::AlembicProcedural() : Procedural(get_node_type()) AlembicProcedural::~AlembicProcedural() { - ccl::set geometries_set; - ccl::set objects_set; - ccl::set abc_objects_set; + CCL_NS::set geometries_set; + CCL_NS::set objects_set; + CCL_NS::set abc_objects_set; foreach (Node *node, objects) { AlembicObject *abc_object = static_cast(node); diff --git a/src/scene/alembic.h b/src/scene/alembic.h index adb85ac5a..b1bdc6ff2 100644 --- a/src/scene/alembic.h +++ b/src/scene/alembic.h @@ -30,7 +30,7 @@ struct MatrixSamplesData { Alembic::AbcCoreAbstract::TimeSamplingPtr time_sampling; }; -/* Helpers to detect if some type is a `ccl::array`. */ +/* Helpers to detect if some type is a `CCL_NS::array`. */ template struct is_array : public std::false_type { }; diff --git a/src/scene/mesh_subdivision.cpp b/src/scene/mesh_subdivision.cpp index 3e45f3ad7..91f9bd452 100644 --- a/src/scene/mesh_subdivision.cpp +++ b/src/scene/mesh_subdivision.cpp @@ -24,14 +24,14 @@ CCL_NAMESPACE_END # include # include -/* specializations of TopologyRefinerFactory for ccl::Mesh */ +/* specializations of TopologyRefinerFactory for CCL_NS::Mesh */ namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { namespace Far { template<> -bool TopologyRefinerFactory::resizeComponentTopology(TopologyRefiner &refiner, - ccl::Mesh const &mesh) +bool TopologyRefinerFactory::resizeComponentTopology(TopologyRefiner &refiner, + CCL_NS::Mesh const &mesh) { setNumBaseVertices(refiner, mesh.get_verts().size()); setNumBaseFaces(refiner, mesh.get_num_subd_faces()); @@ -44,12 +44,12 @@ bool TopologyRefinerFactory::resizeComponentTopology(TopologyRefiner } template<> -bool TopologyRefinerFactory::assignComponentTopology(TopologyRefiner &refiner, - ccl::Mesh const &mesh) +bool TopologyRefinerFactory::assignComponentTopology(TopologyRefiner &refiner, + CCL_NS::Mesh const &mesh) { - const ccl::array &subd_face_corners = mesh.get_subd_face_corners(); - const ccl::array &subd_start_corner = mesh.get_subd_start_corner(); - const ccl::array &subd_num_corners = mesh.get_subd_num_corners(); + const CCL_NS::array &subd_face_corners = mesh.get_subd_face_corners(); + const CCL_NS::array &subd_start_corner = mesh.get_subd_start_corner(); + const CCL_NS::array &subd_num_corners = mesh.get_subd_num_corners(); for (int i = 0; i < mesh.get_num_subd_faces(); i++) { IndexArray face_verts = getBaseFaceVertices(refiner, i); @@ -66,8 +66,8 @@ bool TopologyRefinerFactory::assignComponentTopology(TopologyRefiner } template<> -bool TopologyRefinerFactory::assignComponentTags(TopologyRefiner &refiner, - ccl::Mesh const &mesh) +bool TopologyRefinerFactory::assignComponentTags(TopologyRefiner &refiner, + CCL_NS::Mesh const &mesh) { /* Historical maximum crease weight used at Pixar, influencing the maximum in OpenSubDiv. */ static constexpr float CREASE_SCALE = 10.0f; @@ -81,7 +81,7 @@ bool TopologyRefinerFactory::assignComponentTags(TopologyRefiner &ref } for (int i = 0; i < num_creases; i++) { - ccl::Mesh::SubdEdgeCrease crease = mesh.get_subd_crease(i); + CCL_NS::Mesh::SubdEdgeCrease crease = mesh.get_subd_crease(i); Index edge = findBaseEdge(refiner, crease.v[0], crease.v[1]); if (edge != INDEX_INVALID) { @@ -112,8 +112,8 @@ bool TopologyRefinerFactory::assignComponentTags(TopologyRefiner &ref const float sharpness0 = refiner.getLevel(0).getEdgeSharpness(vert_edges[0]); const float sharpness1 = refiner.getLevel(0).getEdgeSharpness(vert_edges[1]); - sharpness += ccl::min(sharpness0, sharpness1); - sharpness = ccl::min(sharpness, CREASE_SCALE); + sharpness += CCL_NS::min(sharpness0, sharpness1); + sharpness = CCL_NS::min(sharpness, CREASE_SCALE); } if (sharpness != 0.0f) { @@ -125,16 +125,16 @@ bool TopologyRefinerFactory::assignComponentTags(TopologyRefiner &ref } template<> -bool TopologyRefinerFactory::assignFaceVaryingTopology(TopologyRefiner & /*refiner*/, - ccl::Mesh const & /*mesh*/) +bool TopologyRefinerFactory::assignFaceVaryingTopology(TopologyRefiner & /*refiner*/, + CCL_NS::Mesh const & /*mesh*/) { return true; } template<> -void TopologyRefinerFactory::reportInvalidTopology(TopologyError /*err_code*/, +void TopologyRefinerFactory::reportInvalidTopology(TopologyError /*err_code*/, char const * /*msg*/, - ccl::Mesh const & /*mesh*/) + CCL_NS::Mesh const & /*mesh*/) { } } /* namespace Far */ @@ -334,7 +334,7 @@ class OsdData { friend class Mesh; }; -/* ccl::Patch implementation that uses OpenSubdiv for eval */ +/* CCL_NS::Patch implementation that uses OpenSubdiv for eval */ struct OsdPatch : Patch { OsdData *osd_data; diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index e4552713a..e677b4fc3 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -254,8 +254,8 @@ void Scene::device_update(Device *device_, Progress &progress) */ if (film->update_lightgroups(this)) { - light_manager->tag_update(this, ccl::LightManager::LIGHT_MODIFIED); - object_manager->tag_update(this, ccl::ObjectManager::OBJECT_MODIFIED); + light_manager->tag_update(this, CCL_NS::LightManager::LIGHT_MODIFIED); + object_manager->tag_update(this, CCL_NS::ObjectManager::OBJECT_MODIFIED); } if (film->exposure_is_modified()) { integrator->tag_modified(); diff --git a/src/scene/volume.cpp b/src/scene/volume.cpp index 573800fcf..249cb90fe 100644 --- a/src/scene/volume.cpp +++ b/src/scene/volume.cpp @@ -302,7 +302,7 @@ static bool is_non_empty_leaf(const openvdb::MaskGrid::TreeType &tree, const ope } #endif -void VolumeMeshBuilder::generate_vertices_and_quads(vector &vertices_is, +void VolumeMeshBuilder::generate_vertices_and_quads(vector &vertices_is, vector &quads) { #ifdef WITH_OPENVDB diff --git a/src/session/CMakeLists.txt b/src/session/CMakeLists.txt index 9f4b4e3cc..7a7ee918a 100644 --- a/src/session/CMakeLists.txt +++ b/src/session/CMakeLists.txt @@ -36,3 +36,7 @@ include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) cycles_add_library(cycles_session "${LIB}" ${SRC} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/session) +endif() diff --git a/src/subd/CMakeLists.txt b/src/subd/CMakeLists.txt index c7674adba..98d082b65 100644 --- a/src/subd/CMakeLists.txt +++ b/src/subd/CMakeLists.txt @@ -32,3 +32,7 @@ include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) cycles_add_library(cycles_subd "${LIB}" ${SRC} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/subd) +endif() diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index ea5a5de65..35c4102e1 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -146,3 +146,7 @@ include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) cycles_add_library(cycles_util "${LIB}" ${SRC} ${SRC_HEADERS}) + +if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_SHARED_LIBRARY) + delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/include/util) +endif() diff --git a/src/util/boundbox.h b/src/util/boundbox.h index 982f538f5..4b760afca 100644 --- a/src/util/boundbox.h +++ b/src/util/boundbox.h @@ -43,15 +43,15 @@ class BoundBox { { /* the order of arguments to min is such that if pt is nan, it will not * influence the resulting bounding box */ - min = ccl::min(pt, min); - max = ccl::max(pt, max); + min = CCL_NS::min(pt, min); + max = CCL_NS::max(pt, max); } __forceinline void grow(const float3 &pt, float border) { float3 shift = make_float3(border, border, border); - min = ccl::min(pt - shift, min); - max = ccl::max(pt + shift, max); + min = CCL_NS::min(pt - shift, min); + max = CCL_NS::max(pt + shift, max); } __forceinline void grow(const BoundBox &bbox) @@ -65,8 +65,8 @@ class BoundBox { /* the order of arguments to min is such that if pt is nan, it will not * influence the resulting bounding box */ if (isfinite(pt.x) && isfinite(pt.y) && isfinite(pt.z)) { - min = ccl::min(pt, min); - max = ccl::max(pt, max); + min = CCL_NS::min(pt, min); + max = CCL_NS::max(pt, max); } } @@ -74,8 +74,8 @@ class BoundBox { { if (isfinite(pt.x) && isfinite(pt.y) && isfinite(pt.z) && isfinite(border)) { float3 shift = make_float3(border, border, border); - min = ccl::min(pt - shift, min); - max = ccl::max(pt + shift, max); + min = CCL_NS::min(pt - shift, min); + max = CCL_NS::max(pt + shift, max); } } @@ -87,8 +87,8 @@ class BoundBox { __forceinline void intersect(const BoundBox &bbox) { - min = ccl::max(min, bbox.min); - max = ccl::min(max, bbox.max); + min = CCL_NS::max(min, bbox.min); + max = CCL_NS::min(max, bbox.max); } /* todo: avoid using this */ @@ -255,10 +255,10 @@ class BoundBox2D { { BoundBox2D result; - result.left = ccl::clamp(left, mn, mx); - result.right = ccl::clamp(right, mn, mx); - result.bottom = ccl::clamp(bottom, mn, mx); - result.top = ccl::clamp(top, mn, mx); + result.left = CCL_NS::clamp(left, mn, mx); + result.right = CCL_NS::clamp(right, mn, mx); + result.bottom = CCL_NS::clamp(bottom, mn, mx); + result.top = CCL_NS::clamp(top, mn, mx); return result; } -- 2.30.2