diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-03 14:49:54 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-03 14:49:54 +0400 |
commit | db1664ed4c44ff56ce286e0007dfd1587109c7a5 (patch) | |
tree | 9fc331d1dd2a99eaf0f9aaf2c780de21f4c634e2 /intern/cycles/util | |
parent | 67030aaf84229b4d0dc52fbe07e91c2c9d320b0d (diff) |
Cycles:
* Compute MD5 hash to deal with nvidia opencl compiler cache not recognizing
changes in #included files, makes it possible to do kernel compile only
once and remember it for the next time blender is started.
* Kernel tweak to compile with ATI/linux. Enabling any more functionality than
simple clay render still chokes the compiler though, without a specific error
message ..
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_md5.cpp | 23 | ||||
-rw-r--r-- | intern/cycles/util/util_md5.h | 1 | ||||
-rw-r--r-- | intern/cycles/util/util_path.cpp | 25 | ||||
-rw-r--r-- | intern/cycles/util/util_path.h | 2 |
4 files changed, 51 insertions, 0 deletions
diff --git a/intern/cycles/util/util_md5.cpp b/intern/cycles/util/util_md5.cpp index 9fd44740531..90b8a1fe062 100644 --- a/intern/cycles/util/util_md5.cpp +++ b/intern/cycles/util/util_md5.cpp @@ -309,6 +309,29 @@ void MD5Hash::append(const uint8_t *data, int nbytes) memcpy(buf, p, left); } +bool MD5Hash::append_file(const string& filepath) +{ + FILE *f = fopen(filepath.c_str(), "rb"); + + if(!f) + return false; + + const size_t buffer_size = 1024; + uint8_t buffer[buffer_size]; + size_t n; + + do { + n = fread(buffer, 1, buffer_size, f); + append(buffer, n); + } while(n == buffer_size); + + bool success = (ferror(f) == 0); + + fclose(f); + + return success; +} + void MD5Hash::finish(uint8_t digest[16]) { static const uint8_t pad[64] = { diff --git a/intern/cycles/util/util_md5.h b/intern/cycles/util/util_md5.h index 49f421d43d9..5e7e604c4cf 100644 --- a/intern/cycles/util/util_md5.h +++ b/intern/cycles/util/util_md5.h @@ -41,6 +41,7 @@ public: ~MD5Hash(); void append(const uint8_t *data, int size); + bool append_file(const string& filepath); string get_hex(); protected: diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp index 109b842068d..6f76e378dc2 100644 --- a/intern/cycles/util/util_path.cpp +++ b/intern/cycles/util/util_path.cpp @@ -17,6 +17,7 @@ */ #include "util_debug.h" +#include "util_md5.h" #include "util_path.h" #include "util_string.h" @@ -59,5 +60,29 @@ string path_join(const string& dir, const string& file) return (boost::filesystem::path(dir) / boost::filesystem::path(file)).string(); } +string path_files_md5_hash(const string& dir) +{ + /* computes md5 hash of all files in the directory */ + MD5Hash hash; + + if(boost::filesystem::exists(dir)) { + boost::filesystem::directory_iterator it(dir), it_end; + + for(; it != it_end; it++) { + if(boost::filesystem::is_directory(it->status())) { + path_files_md5_hash(it->path().string()); + } + else { + string filepath = it->path().string(); + + hash.append((const uint8_t*)filepath.c_str(), filepath.size()); + hash.append_file(filepath); + } + } + } + + return hash.get_hex(); +} + CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_path.h b/intern/cycles/util/util_path.h index b80bc0e9131..4be0cb86f56 100644 --- a/intern/cycles/util/util_path.h +++ b/intern/cycles/util/util_path.h @@ -35,6 +35,8 @@ string path_filename(const string& path); string path_dirname(const string& path); string path_join(const string& dir, const string& file); +string path_files_md5_hash(const string& dir); + CCL_NAMESPACE_END #endif |