diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:38 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:38 +0400 |
commit | 29f6616d609fbd92cf313b0fdec555c2fcb4ede0 (patch) | |
tree | e0c9500368c5210071cb841ea86f5674b0cf6f25 /intern/cycles/device/device_cpu.cpp | |
parent | 60ff60dcdc9f43891fb8a19e10f9bb7964a539bf (diff) |
Cycles: viewport render now takes scene color management settings into account,
except for curves, that's still missing from the OpenColorIO GLSL shader.
The pixels are stored in a half float texture, converterd from full float with
native GPU instructions and SIMD on the CPU, so it should be pretty quick.
Using a GLSL shader is useful for GPU render because it avoids a copy through
CPU memory.
Diffstat (limited to 'intern/cycles/device/device_cpu.cpp')
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index d9c08dadbb0..b1dbdec9d36 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -127,8 +127,8 @@ public: { if(task->type == DeviceTask::PATH_TRACE) thread_path_trace(*task); - else if(task->type == DeviceTask::TONEMAP) - thread_tonemap(*task); + else if(task->type == DeviceTask::FILM_CONVERT) + thread_film_convert(*task); else if(task->type == DeviceTask::SHADER) thread_shader(*task); } @@ -237,28 +237,55 @@ public: #endif } - void thread_tonemap(DeviceTask& task) + void thread_film_convert(DeviceTask& task) { + float sample_scale = 1.0f/(task.sample + 1); + + if(task.rgba_half) { #ifdef WITH_OPTIMIZED_KERNEL - if(system_cpu_support_sse3()) { - for(int y = task.y; y < task.y + task.h; y++) - for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_sse3_tonemap(&kernel_globals, (uchar4*)task.rgba, (float*)task.buffer, - task.sample, x, y, task.offset, task.stride); - } - else if(system_cpu_support_sse2()) { - for(int y = task.y; y < task.y + task.h; y++) - for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_sse2_tonemap(&kernel_globals, (uchar4*)task.rgba, (float*)task.buffer, - task.sample, x, y, task.offset, task.stride); + if(system_cpu_support_sse3()) { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_sse3_convert_to_half_float(&kernel_globals, (uchar4*)task.rgba_half, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } + else if(system_cpu_support_sse2()) { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_sse2_convert_to_half_float(&kernel_globals, (uchar4*)task.rgba_half, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } + else +#endif + { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_convert_to_half_float(&kernel_globals, (uchar4*)task.rgba_half, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } } - else + else { +#ifdef WITH_OPTIMIZED_KERNEL + if(system_cpu_support_sse3()) { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_sse3_convert_to_byte(&kernel_globals, (uchar4*)task.rgba_byte, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } + else if(system_cpu_support_sse2()) { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_sse2_convert_to_byte(&kernel_globals, (uchar4*)task.rgba_byte, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } + else #endif - { - for(int y = task.y; y < task.y + task.h; y++) - for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_tonemap(&kernel_globals, (uchar4*)task.rgba, (float*)task.buffer, - task.sample, x, y, task.offset, task.stride); + { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_convert_to_byte(&kernel_globals, (uchar4*)task.rgba_byte, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } } } |