diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 8db915f..0fbb48c 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 35956e4..f1c9dcd 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 9dcd69c..c53fbd9 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 #include @@ -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 e1f016b..8a8326c 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 #include OIIO_NAMESPACE_USING @@ -130,7 +131,7 @@ bool path_write_binary(const string& path, const vector& 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; @@ -156,7 +157,7 @@ bool path_read_binary(const string& path, vector& binary) binary.resize(boost::filesystem::file_size(path)); /* read binary file into memory */ - FILE *f = fopen(path.c_str(), "rb"); + FILE *f = path_fopen(path, "rb"); if(!f) return false; @@ -225,5 +226,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 + string path_utf16 = Strutil::utf8_to_utf16(path); + string 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 9b63a42..3cffd7d 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 + #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