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
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2014-01-11 03:47:58 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-01-11 03:47:58 +0400
commit241fccaf6a113963598e5ad040e7e72c857bea00 (patch)
treefe4072418d5aefcb302350c59140783c4fe5db41 /intern
parent9e1ca2858920f059c957401160d0a9b75b6ff2bf (diff)
Fix T37817: cycles CUDA detection problem on Windows with non-ascii paths.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/device/device_cuda.cpp9
-rw-r--r--intern/cycles/util/util_cache.cpp4
-rw-r--r--intern/cycles/util/util_md5.cpp3
-rw-r--r--intern/cycles/util/util_path.cpp66
-rw-r--r--intern/cycles/util/util_path.h4
5 files changed, 66 insertions, 20 deletions
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 8db915f769c..0fbb48cf431 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -355,7 +355,14 @@ public:
/* open module */
cuda_push_context();
- CUresult result = cuModuleLoad(&cuModule, cubin.c_str());
+ string cubin_data;
+ CUresult result;
+
+ if (path_read_text(cubin, cubin_data))
+ result = cuModuleLoadData(&cuModule, cubin_data.c_str());
+ else
+ result = CUDA_ERROR_FILE_NOT_FOUND;
+
if(cuda_error_(result, "cuModuleLoad"))
cuda_error_message(string_printf("Failed loading CUDA kernel %s.", cubin.c_str()));
diff --git a/intern/cycles/util/util_cache.cpp b/intern/cycles/util/util_cache.cpp
index 35956e498cb..f1c9dcd79ab 100644
--- a/intern/cycles/util/util_cache.cpp
+++ b/intern/cycles/util/util_cache.cpp
@@ -79,7 +79,7 @@ void Cache::insert(CacheData& key, CacheData& value)
{
string filename = data_filename(key);
path_create_directories(filename);
- FILE *f = fopen(filename.c_str(), "wb");
+ FILE *f = path_fopen(filename, "wb");
if(!f) {
fprintf(stderr, "Failed to open file %s for writing.\n", filename.c_str());
@@ -100,7 +100,7 @@ void Cache::insert(CacheData& key, CacheData& value)
bool Cache::lookup(CacheData& key, CacheData& value)
{
string filename = data_filename(key);
- FILE *f = fopen(filename.c_str(), "rb");
+ FILE *f = path_fopen(filename, "rb");
if(!f)
return false;
diff --git a/intern/cycles/util/util_md5.cpp b/intern/cycles/util/util_md5.cpp
index 9dcd69cec99..c53fbd90c67 100644
--- a/intern/cycles/util/util_md5.cpp
+++ b/intern/cycles/util/util_md5.cpp
@@ -24,6 +24,7 @@
/* Minor modifications done to remove some code and change style. */
#include "util_md5.h"
+#include "util_path.h"
#include <string.h>
#include <stdio.h>
@@ -311,7 +312,7 @@ void MD5Hash::append(const uint8_t *data, int nbytes)
bool MD5Hash::append_file(const string& filepath)
{
- FILE *f = fopen(filepath.c_str(), "rb");
+ FILE *f = path_fopen(filepath, "rb");
if(!f) {
fprintf(stderr, "MD5: failed to open file %s\n", filepath.c_str());
diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp
index 7777e2695d2..9ee51f2dcfa 100644
--- a/intern/cycles/util/util_path.cpp
+++ b/intern/cycles/util/util_path.cpp
@@ -19,6 +19,7 @@
#include "util_path.h"
#include "util_string.h"
+#include <OpenImageIO/strutil.h>
#include <OpenImageIO/sysutil.h>
OIIO_NAMESPACE_USING
@@ -38,6 +39,25 @@ CCL_NAMESPACE_BEGIN
static string cached_path = "";
static string cached_user_path = "";
+static boost::filesystem::path to_boost(const string& path)
+{
+#ifdef _MSC_VER
+ std::wstring path_utf16 = Strutil::utf8_to_utf16(path);
+ return boost::filesystem::path(path_utf16);
+#else
+ return boost::filesystem::path(path);
+#endif
+}
+
+static string from_boost(const boost::filesystem::path& path)
+{
+#ifdef _MSC_VER
+ return Strutil::utf16_to_utf8(path.wstring());
+#else
+ return path.string();
+#endif
+}
+
void path_init(const string& path, const string& user_path)
{
cached_path = path;
@@ -45,7 +65,7 @@ void path_init(const string& path, const string& user_path)
#ifdef _MSC_VER
// fix for https://svn.boost.org/trac/boost/ticket/6320
- boost::filesystem::path::imbue( std::locale( "" ) );
+ boost::filesystem::path::imbue( std::locale( "" ) );
#endif
}
@@ -68,20 +88,20 @@ string path_user_get(const string& sub)
string path_filename(const string& path)
{
#if (BOOST_FILESYSTEM_VERSION == 2)
- return boost::filesystem::path(path).filename();
+ return to_boost(path).filename();
#else
- return boost::filesystem::path(path).filename().string();
+ return from_boost(to_boost(path).filename());
#endif
}
string path_dirname(const string& path)
{
- return boost::filesystem::path(path).parent_path().string();
+ return from_boost(to_boost(path).parent_path());
}
string path_join(const string& dir, const string& file)
{
- return (boost::filesystem::path(dir) / boost::filesystem::path(file)).string();
+ return from_boost((to_boost(dir) / to_boost(file)));
}
string path_escape(const string& path)
@@ -93,20 +113,22 @@ string path_escape(const string& path)
bool path_exists(const string& path)
{
- return boost::filesystem::exists(path);
+ return boost::filesystem::exists(to_boost(path));
}
static void path_files_md5_hash_recursive(MD5Hash& hash, const string& dir)
{
- if(boost::filesystem::exists(dir)) {
- boost::filesystem::directory_iterator it(dir), it_end;
+ boost::filesystem::path dirpath = to_boost(dir);
+
+ if(boost::filesystem::exists(dirpath)) {
+ boost::filesystem::directory_iterator it(dirpath), it_end;
for(; it != it_end; it++) {
if(boost::filesystem::is_directory(it->status())) {
- path_files_md5_hash_recursive(hash, it->path().string());
+ path_files_md5_hash_recursive(hash, from_boost(it->path()));
}
else {
- string filepath = it->path().string();
+ string filepath = from_boost(it->path());
hash.append((const uint8_t*)filepath.c_str(), filepath.size());
hash.append_file(filepath);
@@ -127,7 +149,7 @@ string path_files_md5_hash(const string& dir)
void path_create_directories(const string& path)
{
- boost::filesystem::create_directories(path_dirname(path));
+ boost::filesystem::create_directories(to_boost(path_dirname(path)));
}
bool path_write_binary(const string& path, const vector<uint8_t>& binary)
@@ -135,7 +157,7 @@ bool path_write_binary(const string& path, const vector<uint8_t>& binary)
path_create_directories(path);
/* write binary file from memory */
- FILE *f = fopen(path.c_str(), "wb");
+ FILE *f = path_fopen(path, "wb");
if(!f)
return false;
@@ -158,10 +180,10 @@ bool path_write_text(const string& path, string& text)
bool path_read_binary(const string& path, vector<uint8_t>& binary)
{
- binary.resize(boost::filesystem::file_size(path));
+ binary.resize(boost::filesystem::file_size(to_boost(path)));
/* read binary file into memory */
- FILE *f = fopen(path.c_str(), "rb");
+ FILE *f = path_fopen(path, "rb");
if(!f)
return false;
@@ -197,8 +219,8 @@ bool path_read_text(const string& path, string& text)
uint64_t path_modified_time(const string& path)
{
- if(boost::filesystem::exists(path))
- return (uint64_t)boost::filesystem::last_write_time(path);
+ if(boost::filesystem::exists(to_boost(path)))
+ return (uint64_t)boost::filesystem::last_write_time(to_boost(path));
return 0;
}
@@ -230,5 +252,17 @@ string path_source_replace_includes(const string& source_, const string& path)
return source;
}
+FILE *path_fopen(const string& path, const string& mode)
+{
+#ifdef _WIN32
+ std::wstring path_utf16 = Strutil::utf8_to_utf16(path);
+ std::wstring mode_utf16 = Strutil::utf8_to_utf16(mode);
+
+ return _wfopen(path_utf16.c_str(), mode_utf16.c_str());
+#else
+ return fopen(path.c_str(), mode.c_str());
+#endif
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_path.h b/intern/cycles/util/util_path.h
index 9b63a427924..3cffd7d91e9 100644
--- a/intern/cycles/util/util_path.h
+++ b/intern/cycles/util/util_path.h
@@ -22,6 +22,8 @@
* linked libraries, the path to the library may be set with path_init, which
* then makes all paths relative to that. */
+#include <stdio.h>
+
#include "util_string.h"
#include "util_types.h"
#include "util_vector.h"
@@ -50,6 +52,8 @@ uint64_t path_modified_time(const string& path);
string path_source_replace_includes(const string& source, const string& path);
+FILE *path_fopen(const string& path, const string& mode);
+
CCL_NAMESPACE_END
#endif