Skip to content

Commit

Permalink
Merge commit 'bbce6ce249f8964e9dbf2e1f13cadad15126f9b9'
Browse files Browse the repository at this point in the history
  • Loading branch information
panzergame committed May 25, 2017
2 parents aee8caa + bbce6ce commit 666ec76
Show file tree
Hide file tree
Showing 165 changed files with 2,832 additions and 1,075 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mark_as_advanced(BUILDINFO_OVERRIDE_TIME)

option(WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
option(WITH_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON)
option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke and audio effects)" ${_init_FFTW3})
option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ${_init_FFTW3})
option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
mark_as_advanced(WITH_SYSTEM_BULLET)
Expand Down Expand Up @@ -1398,10 +1398,20 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
endif()

# Use 'ATTR_FALLTHROUGH' macro to suppress.
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0"))
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
endif()

# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)

if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0"))
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
endif()

if(NOT APPLE)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
endif()
Expand Down
34 changes: 24 additions & 10 deletions build_files/build_environment/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ NO_BUILD=false
NO_CONFIRM=false
USE_CXX11=false

PYTHON_VERSION="3.5.2"
PYTHON_VERSION="3.5.3"
PYTHON_VERSION_MIN="3.5"
PYTHON_FORCE_BUILD=false
PYTHON_FORCE_REBUILD=false
Expand Down Expand Up @@ -366,8 +366,7 @@ ALEMBIC_FORCE_BUILD=false
ALEMBIC_FORCE_REBUILD=false
ALEMBIC_SKIP=false

# Version??
OPENCOLLADA_VERSION="1.3"
OPENCOLLADA_VERSION="1.6.47"
OPENCOLLADA_FORCE_BUILD=false
OPENCOLLADA_FORCE_REBUILD=false
OPENCOLLADA_SKIP=false
Expand Down Expand Up @@ -737,7 +736,10 @@ _boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
BOOST_SOURCE=( "http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download" )
BOOST_BUILD_MODULES="--with-system --with-filesystem --with-thread --with-regex --with-locale --with-date_time --with-wave --with-iostreams --with-python --with-program_options"

OCIO_USE_REPO=true
OCIO_SOURCE=( "https://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION" )
OCIO_SOURCE_REPO=( "https://github.com/imageworks/OpenColorIO.git" )
OCIO_SOURCE_REPO_UID="6de971097c7f552300f669ed69ca0b6cf5a70843"

OPENEXR_USE_REPO=false
OPENEXR_SOURCE=( "http://download.savannah.nongnu.org/releases/openexr/openexr-$OPENEXR_VERSION.tar.gz" )
Expand Down Expand Up @@ -786,7 +788,7 @@ ALEMBIC_SOURCE=( "https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.
# ALEMBIC_SOURCE_REPO_BRANCH="master"

OPENCOLLADA_SOURCE=( "https://github.com/KhronosGroup/OpenCOLLADA.git" )
OPENCOLLADA_REPO_UID="3335ac164e68b2512a40914b14c74db260e6ff7d"
OPENCOLLADA_REPO_UID="22b1f4ff026881b4d2804d397730286ab7e3d090"
OPENCOLLADA_REPO_BRANCH="master"

FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
Expand Down Expand Up @@ -1268,7 +1270,7 @@ compile_OCIO() {
fi

# To be changed each time we make edits that would modify the compiled result!
ocio_magic=1
ocio_magic=2
_init_ocio

# Clean install if needed!
Expand All @@ -1285,14 +1287,27 @@ compile_OCIO() {
if [ ! -d $_src ]; then
INFO "Downloading OpenColorIO-$OCIO_VERSION"
mkdir -p $SRC
download OCIO_SOURCE[@] $_src.tar.gz

INFO "Unpacking OpenColorIO-$OCIO_VERSION"
tar -C $SRC --transform "s,(.*/?)imageworks-OpenColorIO[^/]*(.*),\1OpenColorIO-$OCIO_VERSION\2,x" \
-xf $_src.tar.gz
if [ "$OCIO_USE_REPO" = true ]; then
git clone ${OCIO_SOURCE_REPO[0]} $_src
else
download OCIO_SOURCE[@] $_src.tar.gz
INFO "Unpacking OpenColorIO-$OCIO_VERSION"
tar -C $SRC --transform "s,(.*/?)imageworks-OpenColorIO[^/]*(.*),\1OpenColorIO-$OCIO_VERSION\2,x" \
-xf $_src.tar.gz
fi

fi

cd $_src

if [ "$OCIO_USE_REPO" = true ]; then
# XXX For now, always update from latest repo...
git pull origin master
git checkout $OCIO_SOURCE_REPO_UID
git reset --hard
fi

# Always refresh the whole build!
if [ -d build ]; then
rm -rf build
Expand Down Expand Up @@ -1498,7 +1513,6 @@ compile_OPENEXR() {
if [ "$OPENEXR_USE_REPO" = true ]; then
# XXX For now, always update from latest repo...
git pull origin master
# Stick to same rev as windows' libs...
git checkout $OPENEXR_SOURCE_REPO_UID
git reset --hard
oiio_src_path="../OpenEXR"
Expand Down
3 changes: 3 additions & 0 deletions intern/cycles/blender/blender_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ void BlenderSync::sync_integrator()
integrator->ao_bounces = get_int(cscene, "ao_bounces_render");
}
}
else {
integrator->ao_bounces = 0;
}

if(integrator->modified(previntegrator))
integrator->tag_update(scene);
Expand Down
26 changes: 24 additions & 2 deletions intern/cycles/device/device_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class CPUDevice : public Device

KernelFunctions<void(*)(int, TilesInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int, bool)> filter_divide_shadow_kernel;
KernelFunctions<void(*)(int, TilesInfo*, int, int, int, int, float*, float*, int*, int, int, bool)> filter_get_feature_kernel;
KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel;
KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel;

KernelFunctions<void(*)(int, int, float*, float*, float*, int*, int, int, float, float)> filter_nlm_calc_difference_kernel;
Expand Down Expand Up @@ -210,6 +211,7 @@ class CPUDevice : public Device
REGISTER_KERNEL(shader),
REGISTER_KERNEL(filter_divide_shadow),
REGISTER_KERNEL(filter_get_feature),
REGISTER_KERNEL(filter_detect_outliers),
REGISTER_KERNEL(filter_combine_halves),
REGISTER_KERNEL(filter_nlm_calc_difference),
REGISTER_KERNEL(filter_nlm_blur),
Expand Down Expand Up @@ -530,9 +532,8 @@ class CPUDevice : public Device

bool denoising_combine_halves(device_ptr a_ptr, device_ptr b_ptr,
device_ptr mean_ptr, device_ptr variance_ptr,
int r, int4 rect, DenoisingTask *task)
int r, int4 rect, DenoisingTask * /*task*/)
{
(void) task;
for(int y = rect.y; y < rect.w; y++) {
for(int x = rect.x; x < rect.z; x++) {
filter_combine_halves_kernel()(x, y,
Expand Down Expand Up @@ -594,6 +595,26 @@ class CPUDevice : public Device
return true;
}

bool denoising_detect_outliers(device_ptr image_ptr,
device_ptr variance_ptr,
device_ptr depth_ptr,
device_ptr output_ptr,
DenoisingTask *task)
{
for(int y = task->rect.y; y < task->rect.w; y++) {
for(int x = task->rect.x; x < task->rect.z; x++) {
filter_detect_outliers_kernel()(x, y,
(float*) image_ptr,
(float*) variance_ptr,
(float*) depth_ptr,
(float*) output_ptr,
&task->rect.x,
task->buffer.pass_stride);
}
}
return true;
}

void path_trace(DeviceTask &task, RenderTile &tile, KernelGlobals *kg)
{
float *render_buffer = (float*)tile.buffer;
Expand Down Expand Up @@ -632,6 +653,7 @@ class CPUDevice : public Device
denoising.functions.non_local_means = function_bind(&CPUDevice::denoising_non_local_means, this, _1, _2, _3, _4, &denoising);
denoising.functions.combine_halves = function_bind(&CPUDevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising);
denoising.functions.get_feature = function_bind(&CPUDevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising);
denoising.functions.detect_outliers = function_bind(&CPUDevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising);
denoising.functions.set_tiles = function_bind(&CPUDevice::denoising_set_tiles, this, _1, &denoising);

denoising.filter_area = make_int4(tile.x, tile.y, tile.w, tile.h);
Expand Down
52 changes: 47 additions & 5 deletions intern/cycles/device/device_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class CUDADevice : public Device
cuDevice = 0;
cuContext = 0;

cuModule = 0;
cuFilterModule = 0;

split_kernel = NULL;

need_bindless_mapping = false;
Expand Down Expand Up @@ -487,6 +490,16 @@ class CUDADevice : public Device

bool load_kernels(const DeviceRequestedFeatures& requested_features)
{
/* TODO(sergey): Support kernels re-load for CUDA devices.
*
* Currently re-loading kernel will invalidate memory pointers,
* causing problems in cuCtxSynchronize.
*/
if(cuFilterModule && cuModule) {
VLOG(1) << "Skipping kernel reload, not currently supported.";
return true;
}

/* check if cuda init succeeded */
if(cuContext == 0)
return false;
Expand Down Expand Up @@ -949,7 +962,7 @@ class CUDADevice : public Device
cuda_push_context();

int4 rect = task->rect;
int w = rect.z-rect.x;
int w = align_up(rect.z-rect.x, 4);
int h = rect.w-rect.y;
int r = task->nlm_state.r;
int f = task->nlm_state.f;
Expand Down Expand Up @@ -1148,8 +1161,6 @@ class CUDADevice : public Device
device_ptr mean_ptr, device_ptr variance_ptr,
int r, int4 rect, DenoisingTask *task)
{
(void) task;

if(have_error())
return false;

Expand Down Expand Up @@ -1179,8 +1190,6 @@ class CUDADevice : public Device
device_ptr sample_variance_ptr, device_ptr sv_variance_ptr,
device_ptr buffer_variance_ptr, DenoisingTask *task)
{
(void) task;

if(have_error())
return false;

Expand Down Expand Up @@ -1248,6 +1257,38 @@ class CUDADevice : public Device
return !have_error();
}

bool denoising_detect_outliers(device_ptr image_ptr,
device_ptr variance_ptr,
device_ptr depth_ptr,
device_ptr output_ptr,
DenoisingTask *task)
{
if(have_error())
return false;

cuda_push_context();

CUfunction cuFilterDetectOutliers;
cuda_assert(cuModuleGetFunction(&cuFilterDetectOutliers, cuFilterModule, "kernel_cuda_filter_detect_outliers"));
cuda_assert(cuFuncSetCacheConfig(cuFilterDetectOutliers, CU_FUNC_CACHE_PREFER_L1));
CUDA_GET_BLOCKSIZE(cuFilterDetectOutliers,
task->rect.z-task->rect.x,
task->rect.w-task->rect.y);

void *args[] = {&image_ptr,
&variance_ptr,
&depth_ptr,
&output_ptr,
&task->rect,
&task->buffer.pass_stride};

CUDA_LAUNCH_KERNEL(cuFilterDetectOutliers, args);
cuda_assert(cuCtxSynchronize());

cuda_pop_context();
return !have_error();
}

void denoise(RenderTile &rtile, const DeviceTask &task)
{
DenoisingTask denoising(this);
Expand All @@ -1258,6 +1299,7 @@ class CUDADevice : public Device
denoising.functions.non_local_means = function_bind(&CUDADevice::denoising_non_local_means, this, _1, _2, _3, _4, &denoising);
denoising.functions.combine_halves = function_bind(&CUDADevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising);
denoising.functions.get_feature = function_bind(&CUDADevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising);
denoising.functions.detect_outliers = function_bind(&CUDADevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising);
denoising.functions.set_tiles = function_bind(&CUDADevice::denoising_set_tiles, this, _1, &denoising);

denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h);
Expand Down
22 changes: 18 additions & 4 deletions intern/cycles/device/device_denoising.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ bool DenoisingTask::run_denoising()
nlm_state.temporary_2_ptr = *nlm_temporary_2;
nlm_state.temporary_3_ptr = *nlm_temporary_3;

int mean_from[] = { 0, 1, 2, 6, 7, 8, 12 };
int variance_from[] = { 3, 4, 5, 9, 10, 11, 13 };
int pass_to[] = { 1, 2, 3, 0, 5, 6, 7 };
int mean_from[] = { 0, 1, 2, 12, 6, 7, 8 };
int variance_from[] = { 3, 4, 5, 13, 9, 10, 11};
int pass_to[] = { 1, 2, 3, 0, 5, 6, 7};
for(int pass = 0; pass < 7; pass++) {
device_sub_ptr feature_pass(device, buffer.mem, pass_to[pass]*buffer.pass_stride, buffer.pass_stride, MEM_READ_WRITE);
/* Get the unfiltered pass and its variance from the RenderBuffers. */
Expand All @@ -159,11 +159,25 @@ bool DenoisingTask::run_denoising()
int mean_to[] = { 8, 9, 10};
int variance_to[] = {11, 12, 13};
int num_color_passes = 3;

device_only_memory<float> temp_color;
temp_color.resize(3*buffer.pass_stride);
device->mem_alloc("Denoising temporary color", temp_color, MEM_READ_WRITE);

for(int pass = 0; pass < num_color_passes; pass++) {
device_sub_ptr color_pass (device, buffer.mem, mean_to[pass]*buffer.pass_stride, buffer.pass_stride, MEM_READ_WRITE);
device_sub_ptr color_pass(device, temp_color, pass*buffer.pass_stride, buffer.pass_stride, MEM_READ_WRITE);
device_sub_ptr color_var_pass(device, buffer.mem, variance_to[pass]*buffer.pass_stride, buffer.pass_stride, MEM_READ_WRITE);
functions.get_feature(mean_from[pass], variance_from[pass], *color_pass, *color_var_pass);
}

{
device_sub_ptr depth_pass (device, buffer.mem, 0, buffer.pass_stride, MEM_READ_WRITE);
device_sub_ptr color_var_pass(device, buffer.mem, variance_to[0]*buffer.pass_stride, 3*buffer.pass_stride, MEM_READ_WRITE);
device_sub_ptr output_pass (device, buffer.mem, mean_to[0]*buffer.pass_stride, 3*buffer.pass_stride, MEM_READ_WRITE);
functions.detect_outliers(temp_color.device_pointer, *color_var_pass, *depth_pass, *output_pass);
}

device->mem_free(temp_color);
}

storage.w = filter_area.z;
Expand Down
5 changes: 5 additions & 0 deletions intern/cycles/device/device_denoising.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class DenoisingTask {
device_ptr mean_ptr,
device_ptr variance_ptr
)> get_feature;
function<bool(device_ptr image_ptr,
device_ptr variance_ptr,
device_ptr depth_ptr,
device_ptr output_ptr
)> detect_outliers;
function<bool(device_ptr*)> set_tiles;
} functions;

Expand Down
5 changes: 5 additions & 0 deletions intern/cycles/device/opencl/opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ class OpenCLDeviceBase : public Device
device_ptr mean_ptr,
device_ptr variance_ptr,
DenoisingTask *task);
bool denoising_detect_outliers(device_ptr image_ptr,
device_ptr variance_ptr,
device_ptr depth_ptr,
device_ptr output_ptr,
DenoisingTask *task);
bool denoising_set_tiles(device_ptr *buffers,
DenoisingTask *task);

Expand Down
Loading

0 comments on commit 666ec76

Please sign in to comment.