diff options
author | Martijn Berger <martijn.berger@gmail.com> | 2014-03-08 02:16:09 +0400 |
---|---|---|
committer | Martijn Berger <martijn.berger@gmail.com> | 2014-03-08 02:16:33 +0400 |
commit | dd2dca2f7e77e7521d13b78e875ffa58a90846f2 (patch) | |
tree | 26c0d371fbca7eb25e9060aabc5ef6fe56939cf2 /intern/cycles/device | |
parent | ef51b690090967f5576b88a528a79c5defb1ddd4 (diff) |
Add support for multiple interpolation modes on cycles image textures
All textures are sampled bi-linear currently with the exception of OSL there texture sampling is fixed and set to smart bi-cubic.
This patch adds user control to this setting.
Added:
- bits to DNA / RNA in the form of an enum for supporting multiple interpolations types
- changes to the image texture node drawing code ( add enum)
- to ImageManager (this needs to know to allocate second texture when interpolation type is different)
- to node compiler (pass on interpolation type)
- to device tex_alloc this also needs to get the concept of multiple interpolation types
- implementation for doing non interpolated lookup for cuda and cpu
- implementation where we pass this along to osl ( this makes OSL also do linear untill I add smartcubic to the interface / DNA/ RNA)
Reviewers: brecht, dingto
Reviewed By: brecht
CC: dingto, venomgfx
Differential Revision: https://developer.blender.org/D317
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/device.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_cuda.cpp | 16 | ||||
-rw-r--r-- | intern/cycles/device/device_multi.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_network.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_opencl.cpp | 2 |
6 files changed, 19 insertions, 11 deletions
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index bd309e35788..f94075f9aa5 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -100,7 +100,7 @@ public: /* texture memory */ virtual void tex_alloc(const char *name, device_memory& mem, - bool interpolation = false, bool periodic = false) {}; + InterpolationType interpolation = INTERPOLATION_NONE, bool periodic = false) {}; virtual void tex_free(device_memory& mem) {}; /* pixel memory */ diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 76123fe44d2..de44feb2deb 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -103,9 +103,9 @@ public: kernel_const_copy(&kernel_globals, name, host, size); } - void tex_alloc(const char *name, device_memory& mem, bool interpolation, bool periodic) + void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic) { - kernel_tex_copy(&kernel_globals, name, mem.data_pointer, mem.data_width, mem.data_height); + kernel_tex_copy(&kernel_globals, name, mem.data_pointer, mem.data_width, mem.data_height, interpolation); mem.device_pointer = mem.data_pointer; stats.mem_alloc(mem.memory_size()); diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 932fdc303a5..5133a5c9fea 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -451,7 +451,7 @@ public: cuda_pop_context(); } - void tex_alloc(const char *name, device_memory& mem, bool interpolation, bool periodic) + void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic) { /* determine format */ CUarray_format_enum format; @@ -479,7 +479,7 @@ public: return; } - if(interpolation) { + if(interpolation != INTERPOLATION_NONE) { CUarray handle = NULL; CUDA_ARRAY_DESCRIPTOR desc; @@ -513,7 +513,15 @@ public: cuda_assert(cuTexRefSetArray(texref, handle, CU_TRSA_OVERRIDE_FORMAT)) - cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR)) + if(interpolation == INTERPOLATION_CLOSEST) { + cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT)) + } + else if (interpolation == INTERPOLATION_LINEAR){ + cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR)) + } + else {/* CUBIC and SMART are unsupported for CUDA */ + cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR)) + } cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES)) mem.device_pointer = (device_ptr)handle; @@ -570,7 +578,7 @@ public: cuda_pop_context(); } - tex_interp_map[mem.device_pointer] = interpolation; + tex_interp_map[mem.device_pointer] = (interpolation != INTERPOLATION_NONE); } void tex_free(device_memory& mem) diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 27b9de0769e..1e9367c845a 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -168,7 +168,7 @@ public: sub.device->const_copy_to(name, host, size); } - void tex_alloc(const char *name, device_memory& mem, bool interpolation, bool periodic) + void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic) { foreach(SubDevice& sub, devices) { mem.device_pointer = 0; diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp index bffd993818f..8f00324c3e1 100644 --- a/intern/cycles/device/device_network.cpp +++ b/intern/cycles/device/device_network.cpp @@ -162,7 +162,7 @@ public: snd.write_buffer(host, size); } - void tex_alloc(const char *name, device_memory& mem, bool interpolation, bool periodic) + void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic) { thread_scoped_lock lock(rpc_lock); @@ -559,7 +559,7 @@ protected: else if(rcv.name == "tex_alloc") { network_device_memory mem; string name; - bool interpolation; + InterpolationType interpolation; bool periodic; device_ptr client_pointer; diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 9117b70d749..33170e1230d 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -881,7 +881,7 @@ public: mem_copy_to(*i->second); } - void tex_alloc(const char *name, device_memory& mem, bool interpolation, bool periodic) + void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic) { mem_alloc(mem, MEM_READ_ONLY); mem_copy_to(mem); |