[Bf-blender-cvs] [d5e929a] master: Code cleanup: remove unused Cycles code from BVH cache.

Brecht Van Lommel noreply at git.blender.org
Sat Feb 6 12:22:27 CET 2016


Commit: d5e929a9d33fd10effe89348c8f0460581335d33
Author: Brecht Van Lommel
Date:   Fri Jan 29 20:01:35 2016 +0100
Branches: master
https://developer.blender.org/rBd5e929a9d33fd10effe89348c8f0460581335d33

Code cleanup: remove unused Cycles code from BVH cache.

===================================================================

M	intern/cycles/render/mesh.cpp
M	intern/cycles/util/CMakeLists.txt
D	intern/cycles/util/util_cache.cpp
D	intern/cycles/util/util_cache.h

===================================================================

diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 57f1946..7054831 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -30,7 +30,6 @@
 
 #include "osl_globals.h"
 
-#include "util_cache.h"
 #include "util_foreach.h"
 #include "util_logging.h"
 #include "util_progress.h"
diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt
index 2354120..9cf949b 100644
--- a/intern/cycles/util/CMakeLists.txt
+++ b/intern/cycles/util/CMakeLists.txt
@@ -10,7 +10,6 @@ set(INC_SYS
 
 set(SRC
 	util_aligned_malloc.cpp
-	util_cache.cpp
 	util_debug.cpp
 	util_logging.cpp
 	util_math_cdf.cpp
@@ -40,7 +39,6 @@ set(SRC_HEADERS
 	util_args.h
 	util_atomic.h
 	util_boundbox.h
-	util_cache.h
 	util_debug.h
 	util_foreach.h
 	util_function.h
diff --git a/intern/cycles/util/util_cache.cpp b/intern/cycles/util/util_cache.cpp
deleted file mode 100644
index 5eebfb1..0000000
--- a/intern/cycles/util/util_cache.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-
-#include "util_cache.h"
-#include "util_debug.h"
-#include "util_foreach.h"
-#include "util_map.h"
-#include "util_md5.h"
-#include "util_path.h"
-#include "util_types.h"
-
-#include <boost/filesystem.hpp> 
-#include <boost/algorithm/string.hpp>
-
-CCL_NAMESPACE_BEGIN
-
-/* CacheData */
-
-CacheData::CacheData(const string& name_)
-{
-	name = name_;
-	f = NULL;
-	have_filename = false;
-}
-
-CacheData::~CacheData()
-{
-	if(f)
-		fclose(f);
-}
-
-const string& CacheData::get_filename()
-{
-	if(!have_filename) {
-		MD5Hash hash;
-
-		foreach(const CacheBuffer& buffer, buffers)
-			if(buffer.size)
-				hash.append((uint8_t*)buffer.data, buffer.size);
-		
-		filename = name + "_" + hash.get_hex();
-		have_filename = true;
-	}
-
-	return filename;
-}
-
-/* Cache */
-
-Cache Cache::global;
-
-string Cache::data_filename(CacheData& key)
-{
-	return path_user_get(path_join("cache", key.get_filename()));
-}
-
-void Cache::insert(CacheData& key, CacheData& value)
-{
-	string filename = data_filename(key);
-	path_create_directories(filename);
-	FILE *f = path_fopen(filename, "wb");
-
-	if(!f) {
-		fprintf(stderr, "Failed to open file %s for writing.\n", filename.c_str());
-		return;
-	}
-
-	foreach(CacheBuffer& buffer, value.buffers) {
-		if(!fwrite(&buffer.size, sizeof(buffer.size), 1, f))
-			fprintf(stderr, "Failed to write to file %s.\n", filename.c_str());
-		if(buffer.size)
-			if(!fwrite(buffer.data, buffer.size, 1, f))
-				fprintf(stderr, "Failed to write to file %s.\n", filename.c_str());
-	}
-	
-	fclose(f);
-}
-
-bool Cache::lookup(CacheData& key, CacheData& value)
-{
-	string filename = data_filename(key);
-	FILE *f = path_fopen(filename, "rb");
-
-	if(!f)
-		return false;
-	
-	value.name = key.name;
-	value.f = f;
-
-	return true;
-}
-
-void Cache::clear_except(const string& name, const set<string>& except)
-{
-	path_cache_clear_except(name, except);
-}
-
-CCL_NAMESPACE_END
-
diff --git a/intern/cycles/util/util_cache.h b/intern/cycles/util/util_cache.h
deleted file mode 100644
index 343fa36..0000000
--- a/intern/cycles/util/util_cache.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UTIL_CACHE_H__
-#define __UTIL_CACHE_H__
-
-/* Disk Cache based on Hashing
- *
- * To be used to cache expensive computations. The hash key is created from an
- * arbitrary number of bytes, by hashing the bytes using MD5, which then gives
- * the file name containing the data. This data then is read from the file
- * again into the appropriate data structures.
- *
- * This way we do not need to accurately track changes, compare dates and
- * invalidate cache entries, at the cost of extra computation. If everything
- * is stored in a global cache, computations can perhaps even be shared between
- * different scenes where it may be hard to detect duplicate work.
- */
-
-#include "util_set.h"
-#include "util_string.h"
-#include "util_vector.h"
-
-CCL_NAMESPACE_BEGIN
-
-class CacheBuffer {
-public:
-	const void *data;
-	size_t size;
-
-	CacheBuffer(const void *data_, size_t size_)
-	{ data = data_; size = size_; }
-};
-
-class CacheData {
-public:
-	vector<CacheBuffer> buffers;
-	string name;
-	string filename;
-	bool have_filename;
-	FILE *f;
-
-	CacheData(const string& name = "");
-	~CacheData();
-
-	const string& get_filename();
-
-	template<typename T> void add(const vector<T>& data)
-	{
-		CacheBuffer buffer(data.size()? &data[0]: NULL, data.size()*sizeof(T));
-		buffers.push_back(buffer);
-	}
-
-	template<typename T> void add(const array<T>& data)
-	{
-		CacheBuffer buffer(data.size()? &data[0]: NULL, data.size()*sizeof(T));
-		buffers.push_back(buffer);
-	}
-
-	void add(const void *data, size_t size)
-	{
-		if(size) {
-			CacheBuffer buffer(data, size);
-			buffers.push_back(buffer);
-		}
-	}
-
-	void add(const int& data)
-	{
-		CacheBuffer buffer(&data, sizeof(int));
-		buffers.push_back(buffer);
-	}
-
-	void add(const float& data)
-	{
-		CacheBuffer buffer(&data, sizeof(float));
-		buffers.push_back(buffer);
-	}
-
-	void add(const size_t& data)
-	{
-		CacheBuffer buffer(&data, sizeof(size_t));
-		buffers.push_back(buffer);
-	}
-
-	template<typename T> bool read(array<T>& data)
-	{
-		size_t size;
-
-		if(!fread(&size, sizeof(size), 1, f)) {
-			fprintf(stderr, "Failed to read vector size from cache.\n");
-			return false;
-		}
-
-		if((size == 0) || (size % sizeof(T)) != 0)
-			return false;
-
-		data.resize(size/sizeof(T));
-
-		if(!fread(&data[0], size, 1, f)) {
-			fprintf(stderr, "Failed to read vector data from cache (%lu).\n", (unsigned long)size);
-			return false;
-		}
-		return true;
-	}
-
-	bool read(int& data)
-	{
-		size_t size;
-
-		if(!fread(&size, sizeof(size), 1, f)) {
-			fprintf(stderr, "Failed to read int size from cache.\n");
-			return false;
-		}
-		if(!fread(&data, sizeof(data), 1, f)) {
-			fprintf(stderr, "Failed to read int from cache.\n");
-			return false;
-		}
-		return true;
-	}
-
-	bool read(float& data)
-	{
-		size_t size;
-
-		if(!fread(&size, sizeof(size), 1, f)) {
-			fprintf(stderr, "Failed to read float size from cache.\n");
-			return false;
-		}
-		if(!fread(&data, sizeof(data), 1, f)) {
-			fprintf(stderr, "Failed to read float from cache.\n");
-			return false;
-		}
-		return true;
-	}
-
-	bool read(size_t& data)
-	{
-		size_t size;
-
-		if(!fread(&size, sizeof(size), 1, f)) {
-			fprintf(stderr, "Failed to read size_t size from cache.\n");
-			return false;
-		}
-		if(!fread(&data, sizeof(data), 1, f)) {
-			fprintf(stderr, "Failed to read size_t from cache.\n");
-			return false;
-		}
-		return true;
-	}
-};
-
-class Cache {
-public:
-	static Cache global;
-
-	void insert(CacheData& key, CacheData& value);
-	bool lookup(CacheData& key, CacheData& value);
-
-	void clear_except(const string& name, const set<string>& except);
-
-protected:
-	string data_filename(CacheData& key);
-};
-
-CCL_NAMESPACE_END
-
-#endif /* __UTIL_CACHE_H__ */
-




More information about the Bf-blender-cvs mailing list