Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device_cpu.cpp
| Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | #endif | ||||
| void thread_path_trace(DeviceTask& task) | void thread_path_trace(DeviceTask& task) | ||||
| { | { | ||||
| if(task_pool.canceled()) { | if(task_pool.canceled()) { | ||||
| if(task.need_finish_queue == false) | if(task.need_finish_queue == false) | ||||
| return; | return; | ||||
| } | } | ||||
| KernelGlobals kg = kernel_globals; | KernelGlobals kg = thread_kernel_globals_init(); | ||||
| #ifdef WITH_OSL | |||||
| OSLShader::thread_init(&kg, &kernel_globals, &osl_globals); | |||||
| #endif | |||||
| RenderTile tile; | RenderTile tile; | ||||
| void(*path_trace_kernel)(KernelGlobals*, float*, unsigned int*, int, int, int, int, int); | void(*path_trace_kernel)(KernelGlobals*, float*, unsigned int*, int, int, int, int, int); | ||||
| #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 | #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 | ||||
| if(system_cpu_support_avx2()) { | if(system_cpu_support_avx2()) { | ||||
| path_trace_kernel = kernel_cpu_avx2_path_trace; | path_trace_kernel = kernel_cpu_avx2_path_trace; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | while(task.acquire_tile(this, tile)) { | ||||
| task.release_tile(tile); | task.release_tile(tile); | ||||
| if(task_pool.canceled()) { | if(task_pool.canceled()) { | ||||
| if(task.need_finish_queue == false) | if(task.need_finish_queue == false) | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| #ifdef WITH_OSL | thread_kernel_globals_free(&kg); | ||||
| OSLShader::thread_free(&kg); | |||||
| #endif | |||||
| } | } | ||||
| void thread_film_convert(DeviceTask& task) | void thread_film_convert(DeviceTask& task) | ||||
| { | { | ||||
| float sample_scale = 1.0f/(task.sample + 1); | float sample_scale = 1.0f/(task.sample + 1); | ||||
| if(task.rgba_half) { | if(task.rgba_half) { | ||||
| void(*convert_to_half_float_kernel)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int); | void(*convert_to_half_float_kernel)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int); | ||||
| ▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | #endif | ||||
| { | { | ||||
| task_pool.wait_work(); | task_pool.wait_work(); | ||||
| } | } | ||||
| void task_cancel() | void task_cancel() | ||||
| { | { | ||||
| task_pool.cancel(); | task_pool.cancel(); | ||||
| } | } | ||||
| protected: | |||||
| inline KernelGlobals thread_kernel_globals_init() | |||||
| { | |||||
| KernelGlobals kg = kernel_globals; | |||||
| kg.transparent_shadow_intersections = NULL; | |||||
| const int decoupled_count = sizeof(kg.decoupled_volume_steps) / | |||||
| sizeof(*kg.decoupled_volume_steps); | |||||
| for(int i = 0; i < decoupled_count; ++i) { | |||||
| kg.decoupled_volume_steps[i] = NULL; | |||||
| } | |||||
| kg.decoupled_volume_steps_index = 0; | |||||
| #ifdef WITH_OSL | |||||
| OSLShader::thread_init(&kg, &kernel_globals, &osl_globals); | |||||
| #endif | |||||
| return kg; | |||||
| } | |||||
| inline void thread_kernel_globals_free(KernelGlobals *kg) | |||||
| { | |||||
| if(kg->transparent_shadow_intersections != NULL) { | |||||
| free(kg->transparent_shadow_intersections); | |||||
| } | |||||
| const int decoupled_count = sizeof(kg->decoupled_volume_steps) / | |||||
| sizeof(*kg->decoupled_volume_steps); | |||||
| for(int i = 0; i < decoupled_count; ++i) { | |||||
| if(kg->decoupled_volume_steps[i] != NULL) { | |||||
| free(kg->decoupled_volume_steps[i]); | |||||
| } | |||||
| } | |||||
| #ifdef WITH_OSL | |||||
| OSLShader::thread_free(kg); | |||||
| #endif | |||||
| } | |||||
| }; | }; | ||||
| Device *device_cpu_create(DeviceInfo& info, Stats &stats, bool background) | Device *device_cpu_create(DeviceInfo& info, Stats &stats, bool background) | ||||
| { | { | ||||
| return new CPUDevice(info, stats, background); | return new CPUDevice(info, stats, background); | ||||
| } | } | ||||
| void device_cpu_info(vector<DeviceInfo>& devices) | void device_cpu_info(vector<DeviceInfo>& devices) | ||||
| Show All 27 Lines | |||||