Commit: 45830999d9e8b62288edc97d98ba6b6f69c051a3 Author: Geraldine Chua Date: Thu May 31 01:21:21 2018 +0800 Branches: soc-2018-volumes https://developer.blender.org/rB45830999d9e8b62288edc97d98ba6b6f69c051a3
Merge branch 'soc-2018-volumes' of git.blender.org:blender into soc-2018-volumes =================================================================== =================================================================== diff --cc intern/cycles/render/image.cpp index 756807d0642,c37d7e02d43..f7e2f6488a1 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@@ -699,52 -698,45 +699,54 @@@ template<TypeDesc::BASETYPE FileFormat bool ImageManager::file_load_image(Image *img, ImageDataType type, int texture_limit, - device_vector<VolumeTile>& tex_img, - device_vector<int>& tex_helper) + device_vector<SparseTile>& tex_img, + device_vector<int>& tex_offsets) { - device_vector<DeviceType> *tex_img_raw + device_vector<DeviceType> *tex_img_dense = new device_vector<DeviceType>(NULL, img->mem_name.c_str(), MEM_TEXTURE); - if(!file_load_image<FileFormat, StorageType, DeviceType>(img, type, texture_limit, *tex_img_raw)) { - return false; + if(!file_load_image<FileFormat, StorageType, DeviceType>(img, + type, + texture_limit, + *tex_img_dense)) + { + /* Release temporary pointer. */ + delete tex_img_dense; + tex_img_dense = NULL; + return false; + } + + DeviceType *data = tex_img_dense->data(); + size_t tile_width = compute_tile_resolution(tex_img_dense->data_width); + size_t tile_height = compute_tile_resolution(tex_img_dense->data_height); + size_t tile_depth = compute_tile_resolution(tex_img_dense->data_depth); + + vector<SparseTile> sparse_grid; + vector<int> offsets; - int active_tile_count = create_sparse_grid(data, ++ /* Sample threshold value for now. */ ++ float4 threshold = make_float4(0.0f); ++ int active_tile_count = create_sparse_grid(data, threshold, + tex_img_dense->data_width, + tex_img_dense->data_height, + tex_img_dense->data_depth, + &sparse_grid, &offsets); + + if(active_tile_count < 1) { + /* to-do (gchua): handle this. */ } - VLOG(1) << "Memory usage of raw volume texture: " - << string_human_readable_size(tex_img_raw->memory_size()); - - DeviceType *data = tex_img_raw->data(); - size_t tile_width = compute_tile_resolution(tex_img_raw->data_width); - size_t tile_height = compute_tile_resolution(tex_img_raw->data_height); - size_t tile_depth = compute_tile_resolution(tex_img_raw->data_depth); - - vector<VolumeTile> sparse_grid; - vector<int> indexes; - create_sparse_grid(data, - tex_img_raw->data_width, - tex_img_raw->data_height, - tex_img_raw->data_depth, - sparse_grid, - indexes); - - VolumeTile *texture_pixels; - int *texture_indexes; + SparseTile *texture_pixels; + int *texture_offsets; { /* Since only active tiles are stored in tex_img, its - * allocated memory will be less than the actual resolution + * allocated memory will be <= the actual resolution * of the volume. We store the true resolution (in tiles) in the - * tex_helper instead, since it needs to be allocated enough + * tex_offsets instead, since it needs to be allocated enough * space to track all tiles anyway. */ thread_scoped_lock device_lock(device_mutex); - texture_pixels = (VolumeTile*)tex_img.alloc(sparse_grid.size()); - texture_indexes = (int*)tex_helper.alloc(tile_width, + texture_pixels = (SparseTile*)tex_img.alloc(active_tile_count); + texture_offsets = (int*)tex_offsets.alloc(tile_width, tile_height, tile_depth); } @@@ -959,44 -944,18 +961,44 @@@ void ImageManager::device_load_image(De type, texture_limit, *tex_img, - *tex_helper)) { - /* todo (gchua): fix this later */ - } + *tex_offsets)) + { + /* Clear pointers. */ + delete tex_img; + delete tex_offsets; + tex_img = NULL; + tex_offsets = NULL; - tex_img->helper = tex_helper; - img->mem = tex_img; - img->mem->interpolation = img->interpolation; - img->mem->extension = img->extension; + /* on failure to load, we set a 1x1 pixels pink image (float4) */ + device_vector<float4> *tex_fail + = new device_vector<float4>(device, img->mem_name.c_str(), MEM_TEXTURE); - thread_scoped_lock device_lock(device_mutex); - tex_img->copy_to_device(); - tex_helper->copy_to_device(); + thread_scoped_lock device_lock(device_mutex); + float *pixels = (float*)tex_fail->alloc(1, 1); + + pixels[0] = TEX_IMAGE_MISSING_R; + pixels[1] = TEX_IMAGE_MISSING_G; + pixels[2] = TEX_IMAGE_MISSING_B; + pixels[3] = TEX_IMAGE_MISSING_A; + + img->mem = tex_fail; + img->mem->interpolation = img->interpolation; + img->mem->extension = img->extension; + tex_fail->copy_to_device(); + } + else { + img->mem = tex_img; + img->mem->interpolation = img->interpolation; + img->mem->extension = img->extension; - img->mem->offsets = tex_offsets; ++ img->mem->offets = tex_offsets; + /* Need to set interpolation so that tex_alloc() will treat + * tex_offsets as a image instead of data texture. */ + tex_offsets->interpolation = img->interpolation; + + thread_scoped_lock device_lock(device_mutex); + tex_img->copy_to_device(); + tex_offsets->copy_to_device(); + } } img->need_load = false; diff --cc release/datafiles/locale index 469c949d1ca,469c949d1ca..d3349b42856 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@@ -1,1 -1,1 +1,1 @@@ --Subproject commit 469c949d1ca882be19daa128842f813b72a944d8 ++Subproject commit d3349b42856d00c278f72f2a5909a6c96b9cdb5e diff --cc release/scripts/addons index c88411ff777,c88411ff777..4b91309b122 --- a/release/scripts/addons +++ b/release/scripts/addons @@@ -1,1 -1,1 +1,1 @@@ --Subproject commit c88411ff7776a2db5d6ef6117a1b2faa42a95611 ++Subproject commit 4b91309b122bcdcddd1854b1137407b2c4f55c7e diff --cc release/scripts/addons_contrib index 310578043de,310578043de..cd57934bd04 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@@ -1,1 -1,1 +1,1 @@@ --Subproject commit 310578043dec1aae382eb6a447ae1d103792d7e6 ++Subproject commit cd57934bd04c174fc3402888d01a74e6e6653b2f diff --cc source/tools index 7695e14cfc5,7695e14cfc5..266ca839763 --- a/source/tools +++ b/source/tools @@@ -1,1 -1,1 +1,1 @@@ --Subproject commit 7695e14cfc5820ac66546e0e515914d85ab81af3 ++Subproject commit 266ca8397638d2e098f7eeadd291766f77da2ed3 _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs