Merge branch 'master' into blender2.8

# Conflicts:
#	source/blender/alembic/intern/abc_exporter.h
#	source/blender/alembic/intern/abc_util.cc
This commit is contained in:
Sybren A. Stüvel
2017-04-07 17:28:22 +02:00
24 changed files with 932 additions and 585 deletions

View File

@@ -560,6 +560,9 @@ static void attr_create_pointiness(Scene *scene,
return;
}
const int num_verts = b_mesh.vertices.length();
if(num_verts == 0) {
return;
}
/* STEP 1: Find out duplicated vertices and point duplicates to a single
* original vertex.
*/
@@ -1164,8 +1167,8 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
}
/* skip empty meshes */
size_t numverts = mesh->verts.size();
size_t numkeys = mesh->curve_keys.size();
const size_t numverts = mesh->verts.size();
const size_t numkeys = mesh->curve_keys.size();
if(!numverts && !numkeys)
return;
@@ -1223,13 +1226,12 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
/* TODO(sergey): Perform preliminary check for number of verticies. */
if(numverts) {
/* find attributes */
/* Find attributes. */
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
Attribute *attr_mN = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
Attribute *attr_N = mesh->attributes.find(ATTR_STD_VERTEX_NORMAL);
bool new_attribute = false;
/* add new attributes if they don't exist already */
/* Add new attributes if they don't exist already. */
if(!attr_mP) {
attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
if(attr_N)
@@ -1237,22 +1239,21 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
new_attribute = true;
}
/* load vertex data from mesh */
/* Load vertex data from mesh. */
float3 *mP = attr_mP->data_float3() + time_index*numverts;
float3 *mN = (attr_mN)? attr_mN->data_float3() + time_index*numverts: NULL;
/* NOTE: We don't copy more that existing amount of vertices to prevent
* possible memory corruption.
*/
BL::Mesh::vertices_iterator v;
int i = 0;
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end() && i < numverts; ++v, ++i) {
mP[i] = get_float3(v->co());
if(mN)
mN[i] = get_float3(v->normal());
}
/* in case of new attribute, we verify if there really was any motion */
if(new_attribute) {
/* In case of new attribute, we verify if there really was any motion. */
if(b_mesh.vertices.length() != numverts ||
memcmp(mP, &mesh->verts[0], sizeof(float3)*numverts) == 0)
{
@@ -1275,7 +1276,6 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
* they had no motion, but we need them anyway now */
float3 *P = &mesh->verts[0];
float3 *N = (attr_N)? attr_N->data_float3(): NULL;
for(int step = 0; step < time_index; step++) {
memcpy(attr_mP->data_float3() + step*numverts, P, sizeof(float3)*numverts);
if(attr_mN)
@@ -1283,6 +1283,16 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
}
}
}
else {
if(b_mesh.vertices.length() != numverts) {
VLOG(1) << "Topology differs, discarding motion blur for object "
<< b_ob.name() << " at time " << time_index;
memcpy(mP, &mesh->verts[0], sizeof(float3)*numverts);
if(mN != NULL) {
memcpy(mN, attr_N->data_float3(), sizeof(float3)*numverts);
}
}
}
}
/* hair motion */

View File

@@ -856,7 +856,7 @@ int2 CPUSplitKernel::split_kernel_local_size()
}
int2 CPUSplitKernel::split_kernel_global_size(device_memory& /*kg*/, device_memory& /*data*/, DeviceTask * /*task*/) {
return make_int2(64, 1);
return make_int2(1, 1);
}
uint64_t CPUSplitKernel::state_buffer_size(device_memory& kernel_globals, device_memory& /*data*/, size_t num_threads) {

View File

@@ -151,7 +151,8 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
/* Calculate max groups */
/* Denotes the maximum work groups possible w.r.t. current requested tile size. */
unsigned int max_work_groups = num_global_elements / WORK_POOL_SIZE + 1;
unsigned int work_pool_size = (device->info.type == DEVICE_CPU) ? WORK_POOL_SIZE_CPU : WORK_POOL_SIZE_GPU;
unsigned int max_work_groups = num_global_elements / work_pool_size + 1;
/* Allocate work_pool_wgs memory. */
work_pool_wgs.resize(max_work_groups * sizeof(unsigned int));
@@ -256,10 +257,8 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
activeRaysAvailable = false;
for(int rayStateIter = 0; rayStateIter < global_size[0] * global_size[1]; ++rayStateIter) {
int8_t state = ray_state.get_data()[rayStateIter];
if(state != RAY_INACTIVE) {
if(state == RAY_INVALID) {
if(!IS_STATE(ray_state.get_data(), rayStateIter, RAY_INACTIVE)) {
if(IS_STATE(ray_state.get_data(), rayStateIter, RAY_INVALID)) {
/* Something went wrong, abort to avoid looping endlessly. */
device->set_error("Split kernel error: invalid ray state");
return false;

View File

@@ -281,6 +281,7 @@ void OpenCLDeviceBase::OpenCLProgram::add_log(string msg, bool debug)
}
else if(!debug) {
printf("%s\n", msg.c_str());
fflush(stdout);
}
else {
VLOG(2) << msg;

View File

@@ -422,9 +422,9 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
return false;
}
#ifdef __SHADOW_TRICKS__
const int skip_object = state->catcher_object;
const int skip_object = state->catcher_object;
#else
const int skip_object = OBJECT_NONE;
const int skip_object = OBJECT_NONE;
#endif
/* Do actual shadow shading. */
/* First of all, we check if integrator requires transparent shadows.

View File

@@ -56,7 +56,13 @@ CCL_NAMESPACE_BEGIN
#define VOLUME_STACK_SIZE 16
#define WORK_POOL_SIZE 64
#define WORK_POOL_SIZE_GPU 64
#define WORK_POOL_SIZE_CPU 1
#ifdef __KERNEL_GPU__
# define WORK_POOL_SIZE WORK_POOL_SIZE_GPU
#else
# define WORK_POOL_SIZE WORK_POOL_SIZE_CPU
#endif
/* device capabilities */
#ifdef __KERNEL_CPU__

View File

@@ -42,18 +42,6 @@ bool starts_with(const std::string &str,
}
}
std::string ltrim(const std::string &str) {
std::string result = str;
result.erase(0, result.find_first_not_of(" \t\r\n"));
return result;
}
std::string rtrim(const std::string &str) {
std::string result = str;
result.erase(result.find_last_not_of(" \t\r\n") + 1);
return result;
}
std::string trim(const std::string &str) {
std::string result = str;
result.erase(0, result.find_first_not_of(" \t\r\n"));