Merge branch 'master' into blender2.8

This commit is contained in:
2016-10-02 18:53:01 +02:00
42 changed files with 451 additions and 194 deletions

View File

@@ -993,7 +993,7 @@ public:
cuda_assert(cuCtxSynchronize());
if(task.get_cancel()) {
canceled = false;
canceled = true;
break;
}
}

View File

@@ -2346,7 +2346,9 @@ public:
}
}
void path_trace(SplitRenderTile& rtile, int2 max_render_feasible_tile_size)
void path_trace(DeviceTask *task,
SplitRenderTile& rtile,
int2 max_render_feasible_tile_size)
{
/* cast arguments to cl types */
cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer);
@@ -2739,6 +2741,7 @@ public:
/* Record number of time host intervention has been made */
unsigned int numHostIntervention = 0;
unsigned int numNextPathIterTimes = PathIteration_times;
bool canceled = false;
while(activeRaysAvailable) {
/* Twice the global work size of other kernels for
* ckPathTraceKernel_shadow_blocked_direct_lighting. */
@@ -2757,6 +2760,10 @@ public:
ENQUEUE_SPLIT_KERNEL(direct_lighting, global_size, local_size);
ENQUEUE_SPLIT_KERNEL(shadow_blocked, global_size_shadow_blocked, local_size);
ENQUEUE_SPLIT_KERNEL(next_iteration_setup, global_size, local_size);
if(task->get_cancel()) {
canceled = true;
break;
}
}
/* Read ray-state into Host memory to decide if we should exit
@@ -2794,22 +2801,28 @@ public:
*/
numNextPathIterTimes += PATH_ITER_INC_FACTOR;
}
if(task->get_cancel()) {
canceled = true;
break;
}
}
/* Execute SumALLRadiance kernel to accumulate radiance calculated in
* per_sample_output_buffers into RenderTile's output buffer.
*/
size_t sum_all_radiance_local_size[2] = {16, 16};
size_t sum_all_radiance_global_size[2];
sum_all_radiance_global_size[0] =
(((d_w - 1) / sum_all_radiance_local_size[0]) + 1) *
sum_all_radiance_local_size[0];
sum_all_radiance_global_size[1] =
(((d_h - 1) / sum_all_radiance_local_size[1]) + 1) *
sum_all_radiance_local_size[1];
ENQUEUE_SPLIT_KERNEL(sum_all_radiance,
sum_all_radiance_global_size,
sum_all_radiance_local_size);
if (!canceled) {
size_t sum_all_radiance_local_size[2] = {16, 16};
size_t sum_all_radiance_global_size[2];
sum_all_radiance_global_size[0] =
(((d_w - 1) / sum_all_radiance_local_size[0]) + 1) *
sum_all_radiance_local_size[0];
sum_all_radiance_global_size[1] =
(((d_h - 1) / sum_all_radiance_local_size[1]) + 1) *
sum_all_radiance_local_size[1];
ENQUEUE_SPLIT_KERNEL(sum_all_radiance,
sum_all_radiance_global_size,
sum_all_radiance_local_size);
}
#undef ENQUEUE_SPLIT_KERNEL
#undef GLUE
@@ -3182,7 +3195,8 @@ public:
tile_iter < to_path_trace_render_tiles.size();
++tile_iter)
{
path_trace(to_path_trace_render_tiles[tile_iter],
path_trace(task,
to_path_trace_render_tiles[tile_iter],
max_render_feasible_tile_size);
}
}
@@ -3198,7 +3212,7 @@ public:
/* buffer_rng_state_stride is stride itself. */
SplitRenderTile split_tile(tile);
split_tile.buffer_rng_state_stride = tile.stride;
path_trace(split_tile, max_render_feasible_tile_size);
path_trace(task, split_tile, max_render_feasible_tile_size);
}
tile.sample = tile.start_sample + tile.num_samples;

View File

@@ -1,6 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation
* Modifications Copyright 2011, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,6 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation
* Modifications Copyright 2011, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -12,6 +12,8 @@
* 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.
*
* Aligned nodes intersection SSE code is adopted from Embree,
*/
struct QBVHStackItem {

View File

@@ -1,8 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation,
* and code copyright 2009-2012 Intel Corporation
*
* Modifications Copyright 2011-2014, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,8 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation,
* and code copyright 2009-2012 Intel Corporation
*
* Modifications Copyright 2011-2014, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,8 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation,
* and code copyright 2009-2012 Intel Corporation
*
* Modifications Copyright 2011-2014, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,8 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation,
* and code copyright 2009-2012 Intel Corporation
*
* Modifications Copyright 2011-2014, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,8 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation,
* and code copyright 2009-2012 Intel Corporation
*
* Modifications Copyright 2011-2014, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,6 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation
* Modifications Copyright 2011, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,6 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation
* Modifications Copyright 2011, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,6 +1,5 @@
/*
* Adapted from code Copyright 2009-2010 NVIDIA Corporation
* Modifications Copyright 2011, Blender Foundation.
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -164,6 +164,9 @@ ccl_device float3 svm_math_blackbody_color(float t) {
ccl_device_inline float3 svm_math_gamma_color(float3 color, float gamma)
{
if(gamma == 0.0f)
return make_float3(1.0f, 1.0f, 1.0f);
if(color.x > 0.0f)
color.x = powf(color.x, gamma);
if(color.y > 0.0f)

View File

@@ -89,6 +89,19 @@ void ConstantFolder::make_zero() const
}
}
void ConstantFolder::make_one() const
{
if(output->type() == SocketType::FLOAT) {
make_constant(1.0f);
}
else if(SocketType::is_float3(output->type())) {
make_constant(make_float3(1.0f, 1.0f, 1.0f));
}
else {
assert(0);
}
}
void ConstantFolder::bypass(ShaderOutput *new_output) const
{
assert(new_output);
@@ -321,6 +334,15 @@ void ConstantFolder::fold_math(NodeMath type, bool clamp) const
make_zero();
}
break;
case NODE_MATH_POWER:
/* 1 ^ X == X ^ 0 == 1 */
if(is_one(value1_in) || is_zero(value2_in)) {
make_one();
}
/* X ^ 1 == X */
else if(is_one(value2_in)) {
try_bypass_or_make_constant(value1_in, clamp);
}
default:
break;
}

View File

@@ -43,6 +43,7 @@ public:
void make_constant_clamp(float value, bool clamp) const;
void make_constant_clamp(float3 value, bool clamp) const;
void make_zero() const;
void make_one() const;
/* Bypass node, relinking to another output socket. */
void bypass(ShaderOutput *output) const;

View File

@@ -109,7 +109,7 @@ namespace Far {
template<>
void TopologyRefinerFactory<ccl::Mesh>::reportInvalidTopology(TopologyError /*err_code*/,
char const */*msg*/, ccl::Mesh const& /*mesh*/)
char const * /*msg*/, ccl::Mesh const& /*mesh*/)
{
}
} /* namespace Far */

View File

@@ -3896,6 +3896,19 @@ void GammaNode::constant_fold(const ConstantFolder& folder)
if(folder.all_inputs_constant()) {
folder.make_constant(svm_math_gamma_color(color, gamma));
}
else {
ShaderInput *color_in = input("Color");
ShaderInput *gamma_in = input("Gamma");
/* 1 ^ X == X ^ 0 == 1 */
if(folder.is_one(color_in) || folder.is_zero(gamma_in)) {
folder.make_one();
}
/* X ^ 1 == X */
else if(folder.is_one(gamma_in)) {
folder.try_bypass_or_make_constant(color_in, false);
}
}
}
void GammaNode::compile(SVMCompiler& compiler)

View File

@@ -930,6 +930,72 @@ TEST(render_graph, constant_fold_gamma)
graph.finalize(&scene);
}
/*
* Tests: Gamma with one constant 0 input.
*/
TEST(render_graph, constant_fold_gamma_part_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Gamma_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Gamma_xC::Color to constant (1, 1, 1).");
builder
.add_attribute("Attribute")
/* constant on the left */
.add_node(ShaderNodeBuilder<GammaNode>("Gamma_Cx")
.set("Color", make_float3(0.0f, 0.0f, 0.0f)))
.add_connection("Attribute::Fac", "Gamma_Cx::Gamma")
/* constant on the right */
.add_node(ShaderNodeBuilder<GammaNode>("Gamma_xC")
.set("Gamma", 0.0f))
.add_connection("Attribute::Color", "Gamma_xC::Color")
/* output sum */
.add_node(ShaderNodeBuilder<MixNode>("Out")
.set(&MixNode::type, NODE_MIX_ADD)
.set(&MixNode::use_clamp, true)
.set("Fac", 1.0f))
.add_connection("Gamma_Cx::Color", "Out::Color1")
.add_connection("Gamma_xC::Color", "Out::Color2")
.output_color("Out::Color");
graph.finalize(&scene);
}
/*
* Tests: Gamma with one constant 1 input.
*/
TEST(render_graph, constant_fold_gamma_part_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Gamma_Cx::Color to constant (1, 1, 1).");
CORRECT_INFO_MESSAGE(log, "Folding Gamma_xC::Color to socket Attribute::Color.");
builder
.add_attribute("Attribute")
/* constant on the left */
.add_node(ShaderNodeBuilder<GammaNode>("Gamma_Cx")
.set("Color", make_float3(1.0f, 1.0f, 1.0f)))
.add_connection("Attribute::Fac", "Gamma_Cx::Gamma")
/* constant on the right */
.add_node(ShaderNodeBuilder<GammaNode>("Gamma_xC")
.set("Gamma", 1.0f))
.add_connection("Attribute::Color", "Gamma_xC::Color")
/* output sum */
.add_node(ShaderNodeBuilder<MixNode>("Out")
.set(&MixNode::type, NODE_MIX_ADD)
.set(&MixNode::use_clamp, true)
.set("Fac", 1.0f))
.add_connection("Gamma_Cx::Color", "Out::Color1")
.add_connection("Gamma_xC::Color", "Out::Color2")
.output_color("Out::Color");
graph.finalize(&scene);
}
/*
* Tests: BrightnessContrast with all constant inputs.
*/
@@ -1142,6 +1208,40 @@ TEST(render_graph, constant_fold_part_math_div_0)
graph.finalize(&scene);
}
/*
* Tests: partial folding for Math Power with known 0.
*/
TEST(render_graph, constant_fold_part_math_pow_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X ^ 0 == 1 */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to constant (1).");
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_POWER, 0.0f);
graph.finalize(&scene);
}
/*
* Tests: partial folding for Math Power with known 1.
*/
TEST(render_graph, constant_fold_part_math_pow_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* 1 ^ X == 1; X ^ 1 == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to constant (1)");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to socket Attribute::Fac.");
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_POWER, 1.0f);
graph.finalize(&scene);
}
/*
* Tests: Vector Math with all constant inputs.
*/

View File

@@ -778,7 +778,9 @@ static string line_directive(const string& path, int line)
}
string path_source_replace_includes(const string& source, const string& path)
string path_source_replace_includes(const string& source,
const string& path,
const string& source_filename)
{
/* Our own little c preprocessor that replaces #includes with the file
* contents, to work around issue of opencl drivers not supporting
@@ -807,12 +809,12 @@ string path_source_replace_includes(const string& source, const string& path)
* and avoids having list of include directories.x
*/
text = path_source_replace_includes(
text, path_dirname(filepath));
text = path_source_replace_includes(text, path);
text, path_dirname(filepath), filename);
text = path_source_replace_includes(text, path, filename);
/* Use line directives for better error messages. */
line = line_directive(filepath, 1)
+ token.replace(0, n_end + 1, "\n" + text + "\n")
+ line_directive(path, i);
+ line_directive(path_join(path, source_filename), i);
}
}
}

View File

@@ -66,7 +66,9 @@ bool path_read_text(const string& path, string& text);
bool path_remove(const string& path);
/* source code utility */
string path_source_replace_includes(const string& source, const string& path);
string path_source_replace_includes(const string& source,
const string& path,
const string& source_filename="");
/* cache utility */
void path_cache_clear_except(const string& name, const set<string>& except);