[Bf-blender-cvs] [475b43a] master: Fix T49175: GLSL material crash with environment maps.

2016-08-31 Thread Brecht Van Lommel
Commit: 475b43ad4a7f04c07226d97d46c6d2b18fa13f51
Author: Brecht Van Lommel
Date:   Wed Aug 31 02:17:11 2016 +0200
Branches: master
https://developer.blender.org/rB475b43ad4a7f04c07226d97d46c6d2b18fa13f51

Fix T49175: GLSL material crash with environment maps.

===

M   source/blender/nodes/shader/nodes/node_shader_material.c

===

diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c 
b/source/blender/nodes/shader/nodes/node_shader_material.c
index 8b21b1f..6850cdb 100644
--- a/source/blender/nodes/shader/nodes/node_shader_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_material.c
@@ -223,12 +223,27 @@ static void node_shader_init_material(bNodeTree 
*UNUSED(ntree), bNode *node)
 /* XXX this is also done as a local static function in gpu_codegen.c,
  * but we need this to hack around the crappy material node.
  */
-static GPUNodeLink *gpu_get_input_link(GPUNodeStack *in)
+static GPUNodeLink *gpu_get_input_link(GPUMaterial *mat, GPUNodeStack *in)
 {
-   if (in->link)
+   if (in->link) {
return in->link;
-   else
-   return GPU_uniform(in->vec);
+   }
+   else {
+   GPUNodeLink *result = NULL;
+
+   /* note GPU_uniform() is only intended to be used as a 
parameter to
+* GPU_link(), returning it directly results in leaks or double 
frees */
+   if (in->type == GPU_FLOAT)
+   GPU_link(mat, "set_value", GPU_uniform(in->vec), 
);
+   else if (in->type == GPU_VEC3)
+   GPU_link(mat, "set_rgb", GPU_uniform(in->vec), );
+   else if (in->type == GPU_VEC4)
+   GPU_link(mat, "set_rgba", GPU_uniform(in->vec), 
);
+   else
+   BLI_assert(0);
+
+   return result;
+   }
 }
 
 static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData 
*UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
@@ -251,18 +266,18 @@ static int gpu_shader_material(GPUMaterial *mat, bNode 
*node, bNodeExecData *UNU
 
/* write values */
if (hasinput[MAT_IN_COLOR])
-   shi.rgb = gpu_get_input_link([MAT_IN_COLOR]);
+   shi.rgb = gpu_get_input_link(mat, [MAT_IN_COLOR]);

if (hasinput[MAT_IN_SPEC])
-   shi.specrgb = gpu_get_input_link([MAT_IN_SPEC]);
+   shi.specrgb = gpu_get_input_link(mat, [MAT_IN_SPEC]);

if (hasinput[MAT_IN_REFL])
-   shi.refl = gpu_get_input_link([MAT_IN_REFL]);
+   shi.refl = gpu_get_input_link(mat, [MAT_IN_REFL]);

/* retrieve normal */
if (hasinput[MAT_IN_NORMAL]) {
GPUNodeLink *tmp;
-   shi.vn = gpu_get_input_link([MAT_IN_NORMAL]);
+   shi.vn = gpu_get_input_link(mat, [MAT_IN_NORMAL]);
if (GPU_material_use_world_space_shading(mat)) {
GPU_link(mat, "vec_math_negate", shi.vn, 
);
GPU_link(mat, "direction_transform_m4v3", 
shi.vn, GPU_builtin(GPU_VIEW_MATRIX), );
@@ -276,15 +291,15 @@ static int gpu_shader_material(GPUMaterial *mat, bNode 
*node, bNodeExecData *UNU
 
if (node->type == SH_NODE_MATERIAL_EXT) {
if (hasinput[MAT_IN_MIR])
-   shi.mir = gpu_get_input_link([MAT_IN_MIR]);
+   shi.mir = gpu_get_input_link(mat, 
[MAT_IN_MIR]);
if (hasinput[MAT_IN_AMB])
-   shi.amb = gpu_get_input_link([MAT_IN_AMB]);
+   shi.amb = gpu_get_input_link(mat, 
[MAT_IN_AMB]);
if (hasinput[MAT_IN_EMIT])
-   shi.emit = gpu_get_input_link([MAT_IN_EMIT]);
+   shi.emit = gpu_get_input_link(mat, 
[MAT_IN_EMIT]);
if (hasinput[MAT_IN_SPECTRA])
-   shi.spectra = 
gpu_get_input_link([MAT_IN_SPECTRA]);
+   shi.spectra = gpu_get_input_link(mat, 
[MAT_IN_SPECTRA]);
if (hasinput[MAT_IN_ALPHA])
-   shi.alpha = 
gpu_get_input_link([MAT_IN_ALPHA]);
+   shi.alpha = gpu_get_input_link(mat, 
[MAT_IN_ALPHA]);
}
 
GPU_shaderesult_set(, ); /* clears shr */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bfd8da7] master: Fix T49210: Issue with User Count on Images in some shader nodetrees when rendering previews

2016-08-31 Thread Bastien Montagne
Commit: bfd8da753d34881c6f1205938ce9e6e25e3bf4e8
Author: Bastien Montagne
Date:   Wed Aug 31 16:42:14 2016 +0200
Branches: master
https://developer.blender.org/rBbfd8da753d34881c6f1205938ce9e6e25e3bf4e8

Fix T49210: Issue with User Count on Images in some shader nodetrees when 
rendering previews

Our usercount handling was really... infuriating :|

Here, localization (i.e. 'shalow' copy that should not touch to usercounts) was 
incrementing
usercounts of the sole Textures IDs of lamps and worlds (on the weak and 
fallacious pretext
that related BKE_free... functions would decrement those counts)... Seriously...

So now, localize funcs do not increment any usercount anymore (since matching 
BKE_free... ones do
not decrement any either), and we do not call anymore that stupid unlink when 
freeing temp
localized copies of lamps/materials at end of preview generation.

Note that we probably still have a lot to do to cleanup that copy/localize 
code, pretty sure
we can dedpulicate a lot more.

===

M   source/blender/blenkernel/intern/lamp.c
M   source/blender/blenkernel/intern/world.c
M   source/blender/editors/render/render_preview.c

===

diff --git a/source/blender/blenkernel/intern/lamp.c 
b/source/blender/blenkernel/intern/lamp.c
index e9d039a..d098366 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -154,8 +154,6 @@ Lamp *localize_lamp(Lamp *la)
if (lan->mtex[a]) {
lan->mtex[a] = MEM_mallocN(sizeof(MTex), 
"localize_lamp");
memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
-   /* free lamp decrements */
-   id_us_plus((ID *)lan->mtex[a]->tex);
}
}

diff --git a/source/blender/blenkernel/intern/world.c 
b/source/blender/blenkernel/intern/world.c
index de1e318..caa9a1e 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -158,8 +158,6 @@ World *localize_world(World *wrld)
if (wrld->mtex[a]) {
wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), 
"localize_world");
memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
-   /* free world decrements */
-   id_us_plus((ID *)wrldn->mtex[a]->tex);
}
}
 
diff --git a/source/blender/editors/render/render_preview.c 
b/source/blender/editors/render/render_preview.c
index b4f3426..ddbf59b 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -526,7 +526,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene 
*scene, ID *id, int id_ty
BKE_node_preview_init_tree(origwrld->nodetree, 
sp->sizex, sp->sizey, true);
}
}
-   
+
return sce;
}

@@ -863,8 +863,6 @@ static void shader_preview_free(void *customdata)

/* get rid of copied world */
BLI_remlink(_main->world, sp->worldcopy);
-   /* T32865 - we need to unlink the texture copies, unlike for 
materials */
-   BKE_libblock_relink_ex(pr_main, sp->worldcopy, NULL, NULL, 
true);
BKE_world_free(sp->worldcopy);

properties = IDP_GetProperties((ID *)sp->worldcopy, false);
@@ -881,7 +879,6 @@ static void shader_preview_free(void *customdata)

/* get rid of copied lamp */
BLI_remlink(_main->lamp, sp->lampcopy);
-   BKE_libblock_relink_ex(pr_main, sp->lampcopy, NULL, NULL, true);
BKE_lamp_free(sp->lampcopy);

properties = IDP_GetProperties((ID *)sp->lampcopy, false);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8fb9f2d] master: [Windows] Add support for code signing the final binaries.

2016-08-31 Thread lazydodo
Commit: 8fb9f2dbe9cb69476bf1f98c8503e5acd446c5b0
Author: lazydodo
Date:   Wed Aug 31 06:26:05 2016 -0600
Branches: master
https://developer.blender.org/rB8fb9f2dbe9cb69476bf1f98c8503e5acd446c5b0

[Windows] Add support for code signing the final binaries.

The option is controlled with the WITH_WINDOWS_CODESIGN option and needs:

- Signtool must be found on the system, the standard windows sdk folders will 
be searched for it.
- The path to the pfx file (WINDOWS_CODESIGN_PFX)
- The password for the pfx , this can either be set by the 
WINDOWS_CODESIGN_PFX_PASSWORD variable but given that ends up in CMakeCache.txt 
(which might be undesirable) there is a backup option of setting the 
PFXPASSWORD environment variable on the system.

Reviewers: sergey, juicyfruit

Reviewed By: juicyfruit

Tags: #bf_blender, #platform:_windows

Differential Revision: https://developer.blender.org/D2182

===

M   CMakeLists.txt
M   build_files/cmake/macros.cmake
M   build_files/cmake/platform/platform_win32_msvc.cmake
M   source/blenderplayer/CMakeLists.txt
M   source/creator/CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d7276f4..709f824 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -512,6 +512,15 @@ mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
 option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
 mark_as_advanced(WITH_WINDOWS_FIND_MODULES)
 
+option(WITH_WINDOWS_CODESIGN "Use signtool to sign the final binary." OFF)
+mark_as_advanced(WITH_WINDOWS_CODESIGN)
+
+set(WINDOWS_CODESIGN_PFX CACHE FILEPATH  "Path to pfx file to use for 
codesigning.")
+mark_as_advanced(WINDOWS_CODESIGN_PFX)
+
+set(WINDOWS_CODESIGN_PFX_PASSWORD CACHE STRING  "password for pfx file used 
for codesigning.")
+mark_as_advanced(WINDOWS_CODESIGN_PFX_PASSWORD)
+
 # avoid using again
 option_defaults_clear()
 
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index dc8b158..fabb35c 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -1578,3 +1578,26 @@ macro(openmp_delayload
endif(WITH_OPENMP)
endif(MSVC)
 endmacro()
+
+MACRO(WINDOWS_SIGN_TARGET target)
+   if (WITH_WINDOWS_CODESIGN)
+   if (!SIGNTOOL_EXE)
+   error("Codesigning is enabled, but signtool is not 
found")
+   else()
+   if (WINDOWS_CODESIGN_PFX_PASSWORD)
+   set(CODESIGNPASSWORD /p 
${WINDOWS_CODESIGN_PFX_PASSWORD})
+   else()
+   if ($ENV{PFXPASSWORD})
+   set(CODESIGNPASSWORD /p 
$ENV{PFXPASSWORD})
+   else()
+   message( FATAL_ERROR 
"WITH_WINDOWS_CODESIGN is on but WINDOWS_CODESIGN_PFX_PASSWORD not set, and 
environment variable PFXPASSWORD not found, unable to sign code.")
+   endif()
+   endif()
+   add_custom_command(TARGET ${target}
+   POST_BUILD
+   COMMAND ${SIGNTOOL_EXE} sign /f 
${WINDOWS_CODESIGN_PFX} ${CODESIGNPASSWORD} $
+   VERBATIM
+   )
+   endif()
+   endif()
+ENDMACRO()
\ No newline at end of file
diff --git a/build_files/cmake/platform/platform_win32_msvc.cmake 
b/build_files/cmake/platform/platform_win32_msvc.cmake
index eaa6e41..2772944 100644
--- a/build_files/cmake/platform/platform_win32_msvc.cmake
+++ b/build_files/cmake/platform/platform_win32_msvc.cmake
@@ -471,3 +471,15 @@ endif()
 
 # used in many places so include globally, like OpenGL
 blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
+
+#find signtool  
+SET(ProgramFilesX86_NAME "ProgramFiles(x86)") #env dislikes the ( ) 
+find_program(SIGNTOOL_EXE signtool
+HINTS
+  "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/10/bin/x86/"
+  "$ENV{ProgramFiles}/Windows Kits/10/bin/x86/"
+  "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/8.1/bin/x86/"
+  "$ENV{ProgramFiles}/Windows Kits/8.1/bin/x86/"
+  "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/8.0/bin/x86/"
+  "$ENV{ProgramFiles}/Windows Kits/8.0/bin/x86/"
+)
diff --git a/source/blenderplayer/CMakeLists.txt 
b/source/blenderplayer/CMakeLists.txt
index 2748de0..58bebc6 100644
--- a/source/blenderplayer/CMakeLists.txt
+++ b/source/blenderplayer/CMakeLists.txt
@@ -58,7 +58,7 @@ if(WIN32 AND NOT UNIX)
blenderplayer ${EXETYPE}
bad_level_call_stubs/stubs.c
${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc)
-
+   WINDOWS_SIGN_TARGET(blenderplayer)
install(TARGETS blenderplayer

[Bf-blender-cvs] [6018191] asset-engine: Claude: add Pillar 'login' to Blender CLoud.

2016-08-31 Thread Bastien Montagne
Commit: 6018191d79e08a0e7a79413b9d5f4f231e3269ee
Author: Bastien Montagne
Date:   Wed Aug 31 12:51:18 2016 +0200
Branches: asset-engine
https://developer.blender.org/rB6018191d79e08a0e7a79413b9d5f4f231e3269ee

Claude: add Pillar 'login' to Blender CLoud.

Reusing again mostly code from NlenderCloud add-on, adapted to asset engine 
system...

===

M   release/scripts/startup/bl_operators/claude/__init__.py
M   release/scripts/startup/bl_operators/claude/pillar.py

===

diff --git a/release/scripts/startup/bl_operators/claude/__init__.py 
b/release/scripts/startup/bl_operators/claude/__init__.py
index 1a64ae2..17ab18c 100644
--- a/release/scripts/startup/bl_operators/claude/__init__.py
+++ b/release/scripts/startup/bl_operators/claude/__init__.py
@@ -67,9 +67,8 @@ import time
 import random
 
 import pillarsdk
-from . import pillar, cache
 
-REQUIRED_ROLES_FOR_TEXTURE_BROWSER = {'subscriber', 'demo'}
+REQUIRED_ROLES_FOR_CLAUDE = {'subscriber', 'demo'}
 
 
 ##
@@ -117,6 +116,80 @@ class ClaudeJob:
 def __del__(self):
 self.cancel()
 
+class ClaudeJobCheckCredentials(ClaudeJob):
+@staticmethod
+async def check():
+"""
+Check credentials with Pillar, and if ok returns the user ID.
+Returns None if the user cannot be found, or if the user is not a 
Cloud subscriber.
+"""
+try:
+user_id = await 
pillar.check_pillar_credentials(REQUIRED_ROLES_FOR_CLAUDE)
+except pillar.NotSubscribedToCloudError:
+print('Not subsribed.')
+return None
+except pillar.CredentialsNotSyncedError:
+print('Credentials not synced, re-syncing automatically.')
+#~ self.log.info('Credentials not synced, re-syncing 
automatically.')
+else:
+print('Credentials okay.')
+#~ self.log.info('Credentials okay.')
+return user_id
+
+try:
+user_id = await pillar.refresh_pillar_credentials(required_roles)
+except pillar.NotSubscribedToCloudError:
+print('Not subsribed.')
+return None
+except pillar.UserNotLoggedInError:
+print('User not logged in on Blender ID.')
+#~ self.log.error('User not logged in on Blender ID.')
+else:
+print('Credentials refreshed and ok.')
+#~ self.log.info('Credentials refreshed and ok.')
+return user_id
+
+return None
+
+def start(self):
+self.check_task = asyncio.run_coroutine_threadsafe(self.check(), 
self.loop)
+self.progress = 0.0
+self.status = {'VALID', 'RUNNING'}
+
+def update(self):
+if self.evt_cancel.is_set():
+self.cancel()
+return
+
+self.status = {'VALID', 'RUNNING'}
+user_id = ...
+if self.check_task is not None:
+if not self.check_task.done():
+return ...
+print("cred check finished, we should have cloud access...")
+user_id = self.check_task.result()
+print(user_id)
+self.check_task = None
+self.progress = 1.0
+
+if self.check_task is None:
+self.status = {'VALID'}
+return user_id
+
+def cancel(self):
+print("CANCELLING...")
+super().cancel()
+if self.check_task is not None and not self.check_task.done():
+self.check_task.cancel()
+self.status = {'VALID'}
+
+def __init__(self, executor, job_id):
+super().__init__(executor, job_id)
+
+self.check_task = None
+
+self.start()
+
 
 class ClaudeJobList(ClaudeJob):
 @staticmethod
@@ -135,12 +208,22 @@ class ClaudeJobList(ClaudeJob):
 self.ls_task = 
asyncio.run_coroutine_threadsafe(self.ls(self.evt_cancel, self.curr_node), 
self.loop)
 self.status = {'VALID', 'RUNNING'}
 
-def update(self, dirs):
+def update(self, user_id, dirs):
 if self.evt_cancel.is_set():
 self.cancel()
 return
 
 self.status = {'VALID', 'RUNNING'}
+
+if user_id is None:
+print("Invalid user ID, cannot proceed...")
+self.cancel()
+return
+
+if user_id is ...:
+print("Awaiting a valid user ID...")
+return
+
 if self.ls_task is not None:
 if not self.ls_task.done():
 dirs[:] = [".."]
@@ -161,7 +244,7 @@ class ClaudeJobList(ClaudeJob):
 self.ls_task.cancel()
 self.status = {'VALID'}
 
-def __init__(self, executor, job_id, curr_node):
+def __init__(self, executor, job_id, user_id, curr_node):
 super().__init__(executor, job_id)
 self.curr_node = curr_node
 
@@ -242,10 +325,14 @@ class AssetEngineClaude(AssetEngine):
 
 def __init__(self):
 

[Bf-blender-cvs] [f346687] asset-engine: Merge branch 'master' into asset-engine

2016-08-31 Thread Bastien Montagne
Commit: f346687ef23118cdaf2556f00b1326114ab09a93
Author: Bastien Montagne
Date:   Wed Aug 31 10:17:05 2016 +0200
Branches: asset-engine
https://developer.blender.org/rBf346687ef23118cdaf2556f00b1326114ab09a93

Merge branch 'master' into asset-engine

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs