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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2017-10-06 22:47:41 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2017-10-07 15:53:14 +0300
commit23098cda9936d785988b689ee69e58e900f17cb2 (patch)
treeed49843e81afbe9c38707324f37bf7e14b234a9b /intern/cycles/device/device_cpu.cpp
parentd013b56dde47580d1907e3a994bc49cfaaa9f90c (diff)
Code refactor: make texture code more consistent between devices.
* Use common TextureInfo struct for all devices, except CUDA fermi. * Move image sampling code to kernels/*/kernel_*_image.h files. * Use arrays for data textures on Fermi too, so device_vector<Struct> works.
Diffstat (limited to 'intern/cycles/device/device_cpu.cpp')
-rw-r--r--intern/cycles/device/device_cpu.cpp68
1 files changed, 60 insertions, 8 deletions
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 19e3c0a9075..ac6d3246d38 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -163,6 +163,9 @@ public:
TaskPool task_pool;
KernelGlobals kernel_globals;
+ device_vector<TextureInfo> texture_info;
+ bool need_texture_info;
+
#ifdef WITH_OSL
OSLGlobals osl_globals;
#endif
@@ -235,6 +238,8 @@ public:
VLOG(1) << "Will be using split kernel.";
}
+ need_texture_info = false;
+
#define REGISTER_SPLIT_KERNEL(name) split_kernels[#name] = KernelFunctions<void(*)(KernelGlobals*, KernelData*)>(KERNEL_FUNCTIONS(name))
REGISTER_SPLIT_KERNEL(path_init);
REGISTER_SPLIT_KERNEL(scene_intersect);
@@ -261,6 +266,7 @@ public:
~CPUDevice()
{
task_pool.stop();
+ tex_free(texture_info);
}
virtual bool show_samples() const
@@ -268,6 +274,15 @@ public:
return (TaskScheduler::num_threads() == 1);
}
+ void load_texture_info()
+ {
+ if(need_texture_info) {
+ tex_free(texture_info);
+ tex_alloc("__texture_info", texture_info, INTERPOLATION_NONE, EXTENSION_REPEAT);
+ need_texture_info = false;
+ }
+ }
+
void mem_alloc(const char *name, device_memory& mem, MemoryType /*type*/)
{
if(name) {
@@ -333,14 +348,47 @@ public:
VLOG(1) << "Texture allocate: " << name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
- kernel_tex_copy(&kernel_globals,
- name,
- mem.data_pointer,
- mem.data_width,
- mem.data_height,
- mem.data_depth,
- interpolation,
- extension);
+
+ if(interpolation == INTERPOLATION_NONE) {
+ /* Data texture. */
+ kernel_tex_copy(&kernel_globals,
+ name,
+ mem.data_pointer,
+ mem.data_width,
+ mem.data_height,
+ mem.data_depth,
+ interpolation,
+ extension);
+ }
+ else {
+ /* Image Texture. */
+ int flat_slot = 0;
+ if(string_startswith(name, "__tex_image")) {
+ int pos = string(name).rfind("_");
+ flat_slot = atoi(name + pos + 1);
+ }
+ else {
+ assert(0);
+ }
+
+ if(flat_slot >= texture_info.size()) {
+ /* Allocate some slots in advance, to reduce amount
+ * of re-allocations. */
+ texture_info.resize(flat_slot + 128);
+ }
+
+ TextureInfo& info = texture_info.get_data()[flat_slot];
+ info.data = (uint64_t)mem.data_pointer;
+ info.cl_buffer = 0;
+ info.interpolation = interpolation;
+ info.extension = extension;
+ info.width = mem.data_width;
+ info.height = mem.data_height;
+ info.depth = mem.data_depth;
+
+ need_texture_info = true;
+ }
+
mem.device_pointer = mem.data_pointer;
mem.device_size = mem.memory_size();
stats.mem_alloc(mem.device_size);
@@ -352,6 +400,7 @@ public:
mem.device_pointer = 0;
stats.mem_free(mem.device_size);
mem.device_size = 0;
+ need_texture_info = true;
}
}
@@ -784,6 +833,9 @@ public:
void task_add(DeviceTask& task)
{
+ /* Load texture info. */
+ load_texture_info();
+
/* split task into smaller ones */
list<DeviceTask> tasks;