Fix T47856: Cycles problem when running from multi-byte path
This is a mix of regression and old unsupported configuration. Regression was caused by some checks added on Blender side which was checking whether python function returned error or not. This made it impossible to enable Cycles when running from a file path which can't be encoded with MBCS codepage. Non-regression issue was that it wasn't possible to use pre-compiled CUDA kernels when running from a path with non-ascii multi-byte characters. This commit fixes regression and CUDA parts, but OSL still can't be used from a non-ascii location because it uses non-widechar API to work with file paths by the looks of it. Not sure we can solve this just from our side by using some codepage trick (UTF-16?) since even oslc fails to compile shader when there are non-ascii characters in the path.
This commit is contained in:
@@ -202,13 +202,26 @@ void OSLShaderManager::shading_system_init()
|
||||
if(ss_shared_users == 0) {
|
||||
services_shared = new OSLRenderServices();
|
||||
|
||||
string shader_path = path_get("shader");
|
||||
#ifdef _WIN32
|
||||
/* Annoying thing, Cycles stores paths in UTF-8 codepage, so it can
|
||||
* operate with file paths with any character. This requires to use wide
|
||||
* char functions, but OSL uses old fashioned ANSI functions which means:
|
||||
*
|
||||
* - We have to convert our paths to ANSI before passing to OSL
|
||||
* - OSL can't be used when there's a multi-byte character in the path
|
||||
* to the shaders folder.
|
||||
*/
|
||||
shader_path = string_to_ansi(shader_path);
|
||||
#endif
|
||||
|
||||
ss_shared = new OSL::ShadingSystem(services_shared, ts_shared, &errhandler);
|
||||
ss_shared->attribute("lockgeom", 1);
|
||||
ss_shared->attribute("commonspace", "world");
|
||||
ss_shared->attribute("searchpath:shader", path_get("shader"));
|
||||
ss_shared->attribute("searchpath:shader", shader_path);
|
||||
ss_shared->attribute("greedyjit", 1);
|
||||
|
||||
VLOG(1) << "Using shader search path: " << path_get("shader");
|
||||
VLOG(1) << "Using shader search path: " << shader_path;
|
||||
|
||||
/* our own ray types */
|
||||
static const char *raytypes[] = {
|
||||
|
Reference in New Issue
Block a user