Merge branch 'master' into blender2.8

Conflicts:
	source/blender/blenloader/intern/writefile.c
This commit is contained in:
Bastien Montagne 2017-03-17 11:00:41 +01:00
commit 722451e146
18 changed files with 1261 additions and 1213 deletions

View File

@ -855,9 +855,8 @@ int2 CPUSplitKernel::split_kernel_local_size()
return make_int2(1, 1);
}
int2 CPUSplitKernel::split_kernel_global_size(device_memory& /*kg*/, device_memory& /*data*/, DeviceTask *task) {
/* TODO(mai): this needs investigation but cpu gives incorrect render if global size doesnt match tile size */
return task->requested_tile_size;
int2 CPUSplitKernel::split_kernel_global_size(device_memory& /*kg*/, device_memory& /*data*/, DeviceTask * /*task*/) {
return make_int2(64, 1);
}
uint64_t CPUSplitKernel::state_buffer_size(device_memory& kernel_globals, device_memory& /*data*/, size_t num_threads) {

View File

@ -142,6 +142,7 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
/* Number of elements in the global state buffer */
int num_global_elements = global_size[0] * global_size[1];
assert(num_global_elements % WORK_POOL_SIZE == 0);
/* Allocate all required global memory once. */
if(first_tile) {

View File

@ -191,14 +191,14 @@ ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG
/* Linear Congruential Generator */
ccl_device_forceinline float path_rng_1D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension)
ccl_device_forceinline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension)
{
/* implicit mod 2^32 */
rng = (1103515245*(rng) + 12345);
return (float)rng * (1.0f/(float)0xFFFFFFFF);
*rng = (1103515245*(*rng) + 12345);
return (float)*rng * (1.0f/(float)0xFFFFFFFF);
}
ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension, float *fx, float *fy)
ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension, float *fx, float *fy)
{
*fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
*fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);

View File

@ -32,11 +32,6 @@
# define ccl_addr_space
#endif
#if defined(__SPLIT_KERNEL__) && !defined(__COMPUTE_DEVICE_GPU__)
/* TODO(mai): need to investigate how this effects the kernel, as cpu kernel crashes without this right now */
#define __COMPUTE_DEVICE_GPU__
#endif
CCL_NAMESPACE_BEGIN
/* constants */

View File

@ -360,7 +360,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_homogeneous(
ShaderData *sd,
PathRadiance *L,
ccl_addr_space float3 *throughput,
ccl_addr_space RNG *rng,
ccl_addr_space RNG *rng,
bool probalistic_scatter)
{
VolumeShaderCoefficients coeff;

View File

@ -38,11 +38,11 @@ ccl_device void kernel_shader_eval(KernelGlobals *kg,
kernel_split_params.queue_size,
0);
if(ray_index == QUEUE_EMPTY_SLOT) {
return;
char enqueue_flag = 0;
if((ray_index != QUEUE_EMPTY_SLOT) && IS_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE)) {
enqueue_flag = 1;
}
char enqueue_flag = (IS_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE)) ? 1 : 0;
enqueue_ray_index_local(ray_index,
QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS,
enqueue_flag,
@ -52,7 +52,7 @@ ccl_device void kernel_shader_eval(KernelGlobals *kg,
kernel_split_params.queue_index);
/* Continue on with shader evaluation. */
if(IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE)) {
if((ray_index != QUEUE_EMPTY_SLOT) && IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE)) {
Intersection isect = kernel_split_state.isect[ray_index];
ccl_global uint *rng = &kernel_split_state.rng[ray_index];
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];

View File

@ -46,12 +46,12 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg,
}
#endif
char enqueue_flag = 0;
#ifndef __COMPUTE_DEVICE_GPU__
if(ray_index != QUEUE_EMPTY_SLOT) {
#endif
char enqueue_flag = 0;
ccl_global char *ray_state = kernel_split_state.ray_state;
ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];

View File

@ -727,7 +727,7 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
def path_menu(self, searchpaths, operator, *,
props_default=None, prop_filepath="filepath",
filter_ext=None, display_name=None):
filter_ext=None, filter_path=None, display_name=None):
"""
Populate a menu from a list of paths.
@ -761,12 +761,15 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
# collect paths
files = []
for directory in searchpaths:
files.extend([(f, os.path.join(directory, f))
for f in os.listdir(directory)
if (not f.startswith("."))
if ((filter_ext is None) or
(filter_ext(os.path.splitext(f)[1])))
])
files.extend(
[(f, os.path.join(directory, f))
for f in os.listdir(directory)
if (not f.startswith("."))
if ((filter_ext is None) or
(filter_ext(os.path.splitext(f)[1])))
if ((filter_path is None) or
(filter_path(f)))
])
files.sort()

View File

@ -48,9 +48,10 @@ void BKE_blender_version_string(
char *version_str, size_t maxncpy,
short version, short subversion, bool v_prefix, bool include_subversion);
void BKE_blender_userdef_free(struct UserDef *userdef);
void BKE_blender_userdef_set_data(struct UserDef *userdef);
void BKE_blender_userdef_free_data(struct UserDef *userdef);
void BKE_blender_userdef_refresh(void);
/* set this callback when a UI is running */
void BKE_blender_callback_test_break_set(void (*func)(void));
int BKE_blender_test_break(void);

View File

@ -33,6 +33,7 @@ struct ID;
struct Main;
struct MemFile;
struct ReportList;
struct UserDef;
enum {
BKE_BLENDFILE_READ_FAIL = 0, /* no load */
@ -50,8 +51,13 @@ bool BKE_blendfile_read_from_memfile(
struct bContext *C, struct MemFile *memfile,
struct ReportList *reports, int skip_flag);
int BKE_blendfile_read_userdef(const char *filepath, struct ReportList *reports);
int BKE_blendfile_write_userdef(const char *filepath, struct ReportList *reports);
struct UserDef *BKE_blendfile_userdef_read(
const char *filepath, struct ReportList *reports);
struct UserDef *BKE_blendfile_userdef_read_from_memory(
const void *filebuf, int filelength,
struct ReportList *reports);
int BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
/* partial blend file writing */

View File

@ -150,11 +150,18 @@ static void keymap_item_free(wmKeyMapItem *kmi)
MEM_freeN(kmi->ptr);
}
void BKE_blender_userdef_set_data(UserDef *userdef)
{
/* only here free userdef themes... */
BKE_blender_userdef_free_data(&U);
U = *userdef;
}
/**
* When loading a new userdef from file,
* or when exiting Blender.
*/
void BKE_blender_userdef_free(UserDef *userdef)
void BKE_blender_userdef_free_data(UserDef *userdef)
{
#define U _invalid_access_ /* ensure no accidental global access */
#ifdef U /* quiet warning */

View File

@ -227,7 +227,7 @@ static void setup_app_data(
if (bfd->user) {
/* only here free userdef themes... */
BKE_blender_userdef_free(&U);
BKE_blender_userdef_free_data(&U);
U = *bfd->user;
@ -425,31 +425,49 @@ bool BKE_blendfile_read_from_memfile(
}
/* only read the userdef from a .blend */
int BKE_blendfile_read_userdef(const char *filepath, ReportList *reports)
UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports)
{
BlendFileData *bfd;
int retval = BKE_BLENDFILE_READ_FAIL;
UserDef *userdef = NULL;
bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_NONE);
bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF);
if (bfd) {
if (bfd->user) {
retval = BKE_BLENDFILE_READ_OK_USERPREFS;
/* only here free userdef themes... */
BKE_blender_userdef_free(&U);
U = *bfd->user;
MEM_freeN(bfd->user);
userdef = bfd->user;
}
BKE_main_free(bfd->main);
MEM_freeN(bfd);
}
return retval;
return userdef;
}
UserDef *BKE_blendfile_userdef_read_from_memory(
const void *filebuf, int filelength,
ReportList *reports)
{
BlendFileData *bfd;
UserDef *userdef = NULL;
bfd = BLO_read_from_memory(filebuf, filelength, reports, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF);
if (bfd) {
if (bfd->user) {
userdef = bfd->user;
}
BKE_main_free(bfd->main);
MEM_freeN(bfd);
}
else {
BKE_reports_prepend(reports, "Loading failed: ");
}
return userdef;
}
/* only write the userdef in a .blend */
int BKE_blendfile_write_userdef(const char *filepath, ReportList *reports)
int BKE_blendfile_userdef_write(const char *filepath, ReportList *reports)
{
Main *mainb = MEM_callocN(sizeof(Main), "empty main");
int retval = 0;

View File

@ -74,9 +74,12 @@ typedef struct BlendFileData {
/* skip reading some data-block types (may want to skip screen data too). */
typedef enum eBLOReadSkip {
BLO_READ_SKIP_NONE = 0,
BLO_READ_SKIP_USERDEF = (1 << 0),
BLO_READ_SKIP_NONE = 0,
BLO_READ_SKIP_USERDEF = (1 << 0),
BLO_READ_SKIP_DATA = (1 << 1),
} eBLOReadSkip;
#define BLO_READ_SKIP_ALL \
(BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
BlendFileData *BLO_read_from_file(
const char *filepath,

View File

@ -8720,15 +8720,24 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
case ID_ID:
/* Always adds to the most recently loaded ID_LI block, see direct_link_library.
* This is part of the file format definition. */
bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_READ | LIB_TAG_EXTERN, NULL);
if (fd->skip_flags & BLO_READ_SKIP_DATA) {
bhead = blo_nextbhead(fd, bhead);
}
else {
bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_READ | LIB_TAG_EXTERN, NULL);
}
break;
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
case ID_SCRN:
bhead->code = ID_SCR;
/* deliberate pass on to default */
default:
bhead = read_libblock(fd, bfd->main, bhead, LIB_TAG_LOCAL, NULL);
if (fd->skip_flags & BLO_READ_SKIP_DATA) {
bhead = blo_nextbhead(fd, bhead);
}
else {
bhead = read_libblock(fd, bfd->main, bhead, LIB_TAG_LOCAL, NULL);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1640,8 +1640,25 @@ static int convert_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
ListBase selected_editable_bases = CTX_data_collection_get(C, "selected_editable_bases");
/* Ensure we get all meshes calculated with a sufficient data-mask,
* needed since re-evaluating single modifiers causes bugs if they depend
* on other objects data masks too, see: T50950. */
{
for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
Base *base = link->ptr.data;
DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
uint64_t customdata_mask_prev = scene->customdata_mask;
scene->customdata_mask |= CD_MASK_MESH;
BKE_scene_update_tagged(bmain->eval_ctx, bmain, scene);
scene->customdata_mask = customdata_mask_prev;
}
for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
Base *base = link->ptr.data;
ob = base->object;
if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) {
@ -1684,7 +1701,7 @@ static int convert_exec(bContext *C, wmOperator *op)
ED_rigidbody_object_remove(bmain, scene, newob);
}
}
else if (ob->type == OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */
else if (ob->type == OB_MESH) {
ob->flag |= OB_DONE;
if (keep_original) {
@ -1708,7 +1725,6 @@ static int convert_exec(bContext *C, wmOperator *op)
* cases this doesnt give correct results (when MDEF is used for eg)
*/
dm = mesh_get_derived_final(scene, newob, CD_MASK_MESH);
// dm = mesh_create_derived_no_deform(ob1, NULL); /* this was called original (instead of get_derived). man o man why! (ton) */
DM_to_mesh(dm, newob->data, newob, CD_MASK_MESH, true);
@ -1873,7 +1889,7 @@ static int convert_exec(bContext *C, wmOperator *op)
((ID *)ob->data)->tag &= ~LIB_TAG_DOIT; /* flag not to convert this datablock again */
}
}
CTX_DATA_END;
BLI_freelistN(&selected_editable_bases);
if (!keep_original) {
if (mballConverted) {

View File

@ -697,8 +697,11 @@ int wm_homefile_read(
/* load preferences before startup.blend */
if (!from_memory && BLI_exists(filepath_userdef)) {
int done = BKE_blendfile_read_userdef(filepath_userdef, NULL);
if (done != BKE_BLENDFILE_READ_FAIL) {
UserDef *userdef = BKE_blendfile_userdef_read(filepath_userdef, NULL);
if (userdef != NULL) {
BKE_blender_userdef_set_data(userdef);
MEM_freeN(userdef);
read_userdef_from_memory = false;
skip_flags |= BLO_READ_SKIP_USERDEF;
printf("Read prefs: %s\n", filepath_userdef);
@ -1365,7 +1368,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op)
BLI_make_file_string("/", filepath, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_USERPREF_FILE);
printf("trying to save userpref at %s ", filepath);
if (BKE_blendfile_write_userdef(filepath, op->reports) == 0) {
if (BKE_blendfile_userdef_write(filepath, op->reports) == 0) {
printf("fail\n");
return OPERATOR_CANCELLED;
}
@ -1435,7 +1438,7 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
if (wm_homefile_read(C, op->reports, from_memory, filepath)) {
/* Load a file but keep the splash open */
if (RNA_boolean_get(op->ptr, "use_splash")) {
if (!from_memory && RNA_boolean_get(op->ptr, "use_splash")) {
WM_init_splash(C);
}
return OPERATOR_FINISHED;

View File

@ -576,7 +576,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
ED_file_exit(); /* for fsmenu */
UI_exit();
BKE_blender_userdef_free(&U);
BKE_blender_userdef_free_data(&U);
RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */