Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intern/cycles/device/opencl/opencl_base.cpp20
-rw-r--r--intern/cycles/device/opencl/opencl_split.cpp2
-rw-r--r--intern/cycles/kernel/kernel_globals.h2
-rw-r--r--intern/cycles/kernel/kernels/opencl/kernel.cl2
-rw-r--r--intern/cycles/render/image.cpp59
-rw-r--r--intern/cycles/render/image.h5
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc52
-rw-r--r--source/blender/alembic/intern/abc_mesh.h5
-rw-r--r--source/blender/editors/object/object_relations.c4
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c2
-rw-r--r--tests/python/bl_alembic_import_test.py16
-rw-r--r--tests/python/bl_load_py_modules.py27
12 files changed, 128 insertions, 68 deletions
diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp
index aa22086be29..7bdf81462b8 100644
--- a/intern/cycles/device/opencl/opencl_base.cpp
+++ b/intern/cycles/device/opencl/opencl_base.cpp
@@ -519,20 +519,26 @@ void OpenCLDeviceBase::tex_alloc(const char *name,
<< string_human_readable_size(mem.memory_size()) << ")";
memory_manager.alloc(name, mem);
+ /* Set the pointer to non-null to keep code that inspects its value from thinking its unallocated. */
+ mem.device_pointer = 1;
textures[name] = Texture(&mem, interpolation, extension);
textures_need_update = true;
}
void OpenCLDeviceBase::tex_free(device_memory& mem)
{
- if(memory_manager.free(mem)) {
- textures_need_update = true;
- }
+ if(mem.device_pointer) {
+ mem.device_pointer = 0;
- foreach(TexturesMap::value_type& value, textures) {
- if(value.second.mem == &mem) {
- textures.erase(value.first);
- break;
+ if(memory_manager.free(mem)) {
+ textures_need_update = true;
+ }
+
+ foreach(TexturesMap::value_type& value, textures) {
+ if(value.second.mem == &mem) {
+ textures.erase(value.first);
+ break;
+ }
}
}
}
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index df7c064a24f..16a96213100 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -119,7 +119,7 @@ public:
typedef struct _tex_info_t {
uint buffer, padding;
- ulong offset;
+ uint64_t offset;
uint width, height, depth, options;
} _tex_info_t;
diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h
index c078f09e1d7..9d55183d94b 100644
--- a/intern/cycles/kernel/kernel_globals.h
+++ b/intern/cycles/kernel/kernel_globals.h
@@ -119,7 +119,7 @@ typedef type name##_t;
typedef struct tex_info_t {
uint buffer, padding;
- ulong offset;
+ uint64_t offset;
uint width, height, depth, options;
} tex_info_t;
diff --git a/intern/cycles/kernel/kernels/opencl/kernel.cl b/intern/cycles/kernel/kernels/opencl/kernel.cl
index 83d63b4fba3..b7108f3d0f8 100644
--- a/intern/cycles/kernel/kernels/opencl/kernel.cl
+++ b/intern/cycles/kernel/kernels/opencl/kernel.cl
@@ -178,7 +178,7 @@ __kernel void kernel_ocl_convert_to_half_float(
kernel_film_convert_to_half_float(kg, rgba, buffer, sample_scale, x, y, offset, stride);
}
-__kernel void kernel_ocl_zero_buffer(ccl_global float4 *buffer, ulong size, ulong offset)
+__kernel void kernel_ocl_zero_buffer(ccl_global float4 *buffer, uint64_t size, uint64_t offset)
{
size_t i = ccl_global_id(0) + ccl_global_id(1) * ccl_global_size(0);
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index cfdf26c6787..80ec77f8b4a 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -716,7 +716,12 @@ void ImageManager::device_load_image(Device *device,
if(dscene->tex_float4_image[slot] == NULL)
dscene->tex_float4_image[slot] = new device_vector<float4>();
device_vector<float4>& tex_img = *dscene->tex_float4_image[slot];
- device_tex_free_safe(device, tex_img);
+
+ if(tex_img.device_pointer) {
+ thread_scoped_lock device_lock(device_mutex);
+ device->tex_free(tex_img);
+ }
+
if(!file_load_image<TypeDesc::FLOAT, float>(img,
type,
texture_limit,
@@ -743,7 +748,12 @@ void ImageManager::device_load_image(Device *device,
if(dscene->tex_float_image[slot] == NULL)
dscene->tex_float_image[slot] = new device_vector<float>();
device_vector<float>& tex_img = *dscene->tex_float_image[slot];
- device_tex_free_safe(device, tex_img);
+
+ if(tex_img.device_pointer) {
+ thread_scoped_lock device_lock(device_mutex);
+ device->tex_free(tex_img);
+ }
+
if(!file_load_image<TypeDesc::FLOAT, float>(img,
type,
texture_limit,
@@ -767,7 +777,12 @@ void ImageManager::device_load_image(Device *device,
if(dscene->tex_byte4_image[slot] == NULL)
dscene->tex_byte4_image[slot] = new device_vector<uchar4>();
device_vector<uchar4>& tex_img = *dscene->tex_byte4_image[slot];
- device_tex_free_safe(device, tex_img);
+
+ if(tex_img.device_pointer) {
+ thread_scoped_lock device_lock(device_mutex);
+ device->tex_free(tex_img);
+ }
+
if(!file_load_image<TypeDesc::UINT8, uchar>(img,
type,
texture_limit,
@@ -794,7 +809,12 @@ void ImageManager::device_load_image(Device *device,
if(dscene->tex_byte_image[slot] == NULL)
dscene->tex_byte_image[slot] = new device_vector<uchar>();
device_vector<uchar>& tex_img = *dscene->tex_byte_image[slot];
- device_tex_free_safe(device, tex_img);
+
+ if(tex_img.device_pointer) {
+ thread_scoped_lock device_lock(device_mutex);
+ device->tex_free(tex_img);
+ }
+
if(!file_load_image<TypeDesc::UINT8, uchar>(img,
type,
texture_limit,
@@ -817,7 +837,12 @@ void ImageManager::device_load_image(Device *device,
if(dscene->tex_half4_image[slot] == NULL)
dscene->tex_half4_image[slot] = new device_vector<half4>();
device_vector<half4>& tex_img = *dscene->tex_half4_image[slot];
- device_tex_free_safe(device, tex_img);
+
+ if(tex_img.device_pointer) {
+ thread_scoped_lock device_lock(device_mutex);
+ device->tex_free(tex_img);
+ }
+
if(!file_load_image<TypeDesc::HALF, half>(img,
type,
texture_limit,
@@ -843,7 +868,12 @@ void ImageManager::device_load_image(Device *device,
if(dscene->tex_half_image[slot] == NULL)
dscene->tex_half_image[slot] = new device_vector<half>();
device_vector<half>& tex_img = *dscene->tex_half_image[slot];
- device_tex_free_safe(device, tex_img);
+
+ if(tex_img.device_pointer) {
+ thread_scoped_lock device_lock(device_mutex);
+ device->tex_free(tex_img);
+ }
+
if(!file_load_image<TypeDesc::HALF, half>(img,
type,
texture_limit,
@@ -927,7 +957,11 @@ void ImageManager::device_free_image(Device *device, DeviceScene *dscene, ImageD
tex_img = NULL;
}
if(tex_img) {
- device_tex_free_safe(device, *tex_img);
+ if(tex_img->device_pointer) {
+ thread_scoped_lock device_lock(device_mutex);
+ device->tex_free(*tex_img);
+ }
+
delete tex_img;
}
}
@@ -1063,16 +1097,5 @@ void ImageManager::device_free(Device *device, DeviceScene *dscene)
dscene->tex_half_image.clear();
}
-void ImageManager::device_tex_free_safe(Device *device, device_memory& mem)
-{
- if(mem.device_pointer) {
- thread_scoped_lock device_lock(device_mutex);
- device->tex_free(mem);
- }
- else {
- device->tex_free(mem);
- }
-}
-
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index abd1abbd729..c86d1cbedbf 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -160,11 +160,6 @@ private:
DeviceScene *dscene,
ImageDataType type,
int slot);
-
- /* Will do locking when needed and make sure possible memory manager from
- * the device implementation is aware of freed texture.
- */
- void device_tex_free_safe(Device *device, device_memory& mem);
};
CCL_NAMESPACE_END
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 25cf5f49b14..b978fe971d6 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -681,17 +681,17 @@ static void assign_materials(Main *bmain, Object *ob, const std::map<std::string
std::string mat_name = it->first;
mat_iter = mat_map.find(mat_name.c_str());
- Material *assigned_name;
+ Material *assigned_mat;
if (mat_iter == mat_map.end()) {
- assigned_name = BKE_material_add(bmain, mat_name.c_str());
- mat_map[mat_name] = assigned_name;
+ assigned_mat = BKE_material_add(bmain, mat_name.c_str());
+ mat_map[mat_name] = assigned_mat;
}
else {
- assigned_name = mat_iter->second;
+ assigned_mat = mat_iter->second;
}
- assign_material(ob, assigned_name, it->second, BKE_MAT_ASSIGN_OBDATA);
+ assign_material(ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA);
}
}
}
@@ -977,8 +977,6 @@ static void read_mesh_sample(ImportSettings *settings,
if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) {
read_custom_data(schema.getArbGeomParams(), config, selector);
}
-
- /* TODO: face sets */
}
CDStreamConfig get_config(DerivedMesh *dm)
@@ -1117,6 +1115,16 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
CDDM_calc_normals(new_dm);
CDDM_calc_edges(new_dm);
+ /* Here we assume that the number of materials doesn't change, i.e. that
+ * the material slots that were created when the object was loaded from
+ * Alembic are still valid now. */
+ size_t num_polys = new_dm->getNumPolys(new_dm);
+ if (num_polys > 0) {
+ MPoly *dmpolies = new_dm->getPolyArray(new_dm);
+ std::map<std::string, int> mat_map;
+ assign_facesets_to_mpoly(sample_sel, 0, dmpolies, num_polys, mat_map);
+ }
+
return new_dm;
}
@@ -1127,8 +1135,11 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
return dm;
}
-void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
- const ISampleSelector &sample_sel)
+void AbcMeshReader::assign_facesets_to_mpoly(
+ const ISampleSelector &sample_sel,
+ size_t poly_start,
+ MPoly *mpoly, int totpoly,
+ std::map<std::string, int> & r_mat_map)
{
std::vector<std::string> face_sets;
m_schema.getFaceSetNames(face_sets);
@@ -1137,21 +1148,21 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_star
return;
}
- std::map<std::string, int> mat_map;
int current_mat = 0;
for (int i = 0; i < face_sets.size(); ++i) {
const std::string &grp_name = face_sets[i];
- if (mat_map.find(grp_name) == mat_map.end()) {
- mat_map[grp_name] = 1 + current_mat++;
+ if (r_mat_map.find(grp_name) == r_mat_map.end()) {
+ r_mat_map[grp_name] = 1 + current_mat++;
}
- const int assigned_mat = mat_map[grp_name];
+ const int assigned_mat = r_mat_map[grp_name];
const IFaceSet faceset = m_schema.getFaceSet(grp_name);
if (!faceset.valid()) {
+ std::cerr << " Face set " << grp_name << " invalid for " << m_object_name << "\n";
continue;
}
@@ -1163,16 +1174,25 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_star
for (size_t l = 0; l < num_group_faces; l++) {
size_t pos = (*group_faces)[l] + poly_start;
- if (pos >= mesh->totpoly) {
+ if (pos >= totpoly) {
std::cerr << "Faceset overflow on " << faceset.getName() << '\n';
break;
}
- MPoly &poly = mesh->mpoly[pos];
+ MPoly &poly = mpoly[pos];
poly.mat_nr = assigned_mat - 1;
}
}
+}
+
+void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
+ const ISampleSelector &sample_sel)
+{
+ std::map<std::string, int> mat_map;
+ assign_facesets_to_mpoly(sample_sel,
+ poly_start, mesh->mpoly, mesh->totpoly,
+ mat_map);
utils::assign_materials(bmain, m_object, mat_map);
}
@@ -1228,8 +1248,6 @@ static void read_subd_sample(ImportSettings *settings,
if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) {
read_custom_data(schema.getArbGeomParams(), config, selector);
}
-
- /* TODO: face sets */
}
/* ************************************************************************** */
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index 941407d2208..e0b2365e134 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -113,6 +113,11 @@ public:
private:
void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
const Alembic::AbcGeom::ISampleSelector &sample_sel);
+
+ void assign_facesets_to_mpoly(const Alembic::Abc::ISampleSelector &sample_sel,
+ size_t poly_start,
+ MPoly *mpoly, int totpoly,
+ std::map<std::string, int> & r_mat_map);
};
/* ************************************************************************** */
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index e7c3ed38296..7e10cbeeb82 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2053,7 +2053,9 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
IDP_RelinkProperty(scene->gpd->id.properties);
}
- IDP_RelinkProperty(scene->world->id.properties);
+ if (scene->world) {
+ IDP_RelinkProperty(scene->world->id.properties);
+ }
if (scene->clip) {
IDP_RelinkProperty(scene->clip->id.properties);
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 5c2f1aba8e1..e5431c0fba9 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -101,7 +101,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct EvaluationContext *UN
#ifdef WITH_ALEMBIC
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
- /* Only used to check wehther we are operating on org data or not... */
+ /* Only used to check whether we are operating on org data or not... */
Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
DerivedMesh *org_dm = dm;
diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py
index 9f758b0b161..65a0867d5c1 100644
--- a/tests/python/bl_alembic_import_test.py
+++ b/tests/python/bl_alembic_import_test.py
@@ -179,22 +179,24 @@ class SimpleImportTest(AbstractAlembicTest):
res = bpy.ops.wm.alembic_import(filepath=str(abc), as_background_job=False)
self.assertEqual({'FINISHED'}, res)
- cube = bpy.context.active_object
+ plane = bpy.context.active_object
# Check that the file loaded ok.
bpy.context.scene.frame_set(6)
- self.assertAlmostEqual(-1, cube.data.vertices[0].co.x)
- self.assertAlmostEqual(-1, cube.data.vertices[0].co.y)
- self.assertAlmostEqual(0.5905638933181763, cube.data.vertices[0].co.z)
+ mesh = plane.to_mesh(bpy.context.scene, True, 'RENDER')
+ self.assertAlmostEqual(-1, mesh.vertices[0].co.x)
+ self.assertAlmostEqual(-1, mesh.vertices[0].co.y)
+ self.assertAlmostEqual(0.5905638933181763, mesh.vertices[0].co.z)
# Change path from absolute to relative. This should not break the animation.
bpy.context.scene.frame_set(1)
bpy.data.cache_files[fname].filepath = relpath
bpy.context.scene.frame_set(6)
- self.assertAlmostEqual(1, cube.data.vertices[3].co.x)
- self.assertAlmostEqual(1, cube.data.vertices[3].co.y)
- self.assertAlmostEqual(0.5905638933181763, cube.data.vertices[3].co.z)
+ mesh = plane.to_mesh(bpy.context.scene, True, 'RENDER')
+ self.assertAlmostEqual(1, mesh.vertices[3].co.x)
+ self.assertAlmostEqual(1, mesh.vertices[3].co.y)
+ self.assertAlmostEqual(0.5905638933181763, mesh.vertices[3].co.z)
def test_import_long_names(self):
# This file contains very long names. The longest name is 4047 chars.
diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py
index 7ffececd1d9..2d8a908406f 100644
--- a/tests/python/bl_load_py_modules.py
+++ b/tests/python/bl_load_py_modules.py
@@ -123,6 +123,8 @@ def load_addons():
def load_modules():
+ VERBOSE = os.environ.get("BLENDER_VERBOSE") is not None
+
modules = []
module_paths = []
@@ -162,6 +164,14 @@ def load_modules():
del module_names
#
+ # test we tested all files except for presets and templates
+ ignore_paths = [
+ os.sep + "presets" + os.sep,
+ os.sep + "templates" + os.sep,
+ ] + ([(os.sep + f + os.sep) for f in BLACKLIST] +
+ [(os.sep + f + ".py") for f in BLACKLIST])
+
+ #
# now submodules
for m in modules:
filepath = m.__file__
@@ -199,7 +209,14 @@ def load_modules():
# import failure.
# - We want to catch all failures of this script instead of stopping on
# a first big failure.
- traceback.print_exc()
+ do_print = True
+ if not VERBOSE:
+ for ignore in ignore_paths:
+ if ignore in submod_full:
+ do_print = False
+ break
+ if do_print:
+ traceback.print_exc()
#
# check which filepaths we didn't load
@@ -218,14 +235,6 @@ def load_modules():
for f in loaded_files:
source_files.remove(f)
- #
- # test we tested all files except for presets and templates
- ignore_paths = [
- os.sep + "presets" + os.sep,
- os.sep + "templates" + os.sep,
- ] + ([(os.sep + f + os.sep) for f in BLACKLIST] +
- [(os.sep + f + ".py") for f in BLACKLIST])
-
for f in source_files:
for ignore in ignore_paths:
if ignore in f: