Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device_cpu.cpp
| Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | #endif | ||||
| bool use_split_kernel; | bool use_split_kernel; | ||||
| DeviceRequestedFeatures requested_features; | DeviceRequestedFeatures requested_features; | ||||
| KernelFunctions<void(*)(KernelGlobals *, float *, int, int, int, int, int)> path_trace_kernel; | KernelFunctions<void(*)(KernelGlobals *, float *, int, int, int, int, int)> path_trace_kernel; | ||||
| KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_half_float_kernel; | KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_half_float_kernel; | ||||
| KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_byte_kernel; | KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_byte_kernel; | ||||
| KernelFunctions<void(*)(KernelGlobals *, uint4 *, float4 *, int, int, int, int, int)> shader_kernel; | KernelFunctions<void(*)(KernelGlobals *, uint4 *, float4 *, int, int, int, int, int)> shader_kernel; | ||||
| KernelFunctions<void(*)(KernelGlobals *, float *, int, int, int, int, int)> bake_kernel; | |||||
| KernelFunctions<void(*)(int, TilesInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_divide_shadow_kernel; | KernelFunctions<void(*)(int, TilesInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_divide_shadow_kernel; | ||||
| KernelFunctions<void(*)(int, TilesInfo*, int, int, int, int, float*, float*, int*, int, int)> filter_get_feature_kernel; | KernelFunctions<void(*)(int, TilesInfo*, int, int, int, int, float*, float*, int*, int, int)> filter_get_feature_kernel; | ||||
| KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel; | KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel; | ||||
| KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel; | KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel; | ||||
| KernelFunctions<void(*)(int, int, float*, float*, float*, int*, int, int, float, float)> filter_nlm_calc_difference_kernel; | KernelFunctions<void(*)(int, int, float*, float*, float*, int*, int, int, float, float)> filter_nlm_calc_difference_kernel; | ||||
| KernelFunctions<void(*)(float*, float*, int*, int, int)> filter_nlm_blur_kernel; | KernelFunctions<void(*)(float*, float*, int*, int, int)> filter_nlm_blur_kernel; | ||||
| Show All 21 Lines | #define KERNEL_FUNCTIONS(name) \ | ||||
| CPUDevice(DeviceInfo& info_, Stats &stats_, bool background_) | CPUDevice(DeviceInfo& info_, Stats &stats_, bool background_) | ||||
| : Device(info_, stats_, background_), | : Device(info_, stats_, background_), | ||||
| texture_info(this, "__texture_info", MEM_TEXTURE), | texture_info(this, "__texture_info", MEM_TEXTURE), | ||||
| #define REGISTER_KERNEL(name) name ## _kernel(KERNEL_FUNCTIONS(name)) | #define REGISTER_KERNEL(name) name ## _kernel(KERNEL_FUNCTIONS(name)) | ||||
| REGISTER_KERNEL(path_trace), | REGISTER_KERNEL(path_trace), | ||||
| REGISTER_KERNEL(convert_to_half_float), | REGISTER_KERNEL(convert_to_half_float), | ||||
| REGISTER_KERNEL(convert_to_byte), | REGISTER_KERNEL(convert_to_byte), | ||||
| REGISTER_KERNEL(shader), | REGISTER_KERNEL(shader), | ||||
| REGISTER_KERNEL(bake), | |||||
| REGISTER_KERNEL(filter_divide_shadow), | REGISTER_KERNEL(filter_divide_shadow), | ||||
| REGISTER_KERNEL(filter_get_feature), | REGISTER_KERNEL(filter_get_feature), | ||||
| REGISTER_KERNEL(filter_detect_outliers), | REGISTER_KERNEL(filter_detect_outliers), | ||||
| REGISTER_KERNEL(filter_combine_halves), | REGISTER_KERNEL(filter_combine_halves), | ||||
| REGISTER_KERNEL(filter_nlm_calc_difference), | REGISTER_KERNEL(filter_nlm_calc_difference), | ||||
| REGISTER_KERNEL(filter_nlm_blur), | REGISTER_KERNEL(filter_nlm_blur), | ||||
| REGISTER_KERNEL(filter_nlm_calc_weight), | REGISTER_KERNEL(filter_nlm_calc_weight), | ||||
| REGISTER_KERNEL(filter_nlm_update_output), | REGISTER_KERNEL(filter_nlm_update_output), | ||||
| ▲ Show 20 Lines • Show All 453 Lines • ▼ Show 20 Lines | for(int y = task->rect.y; y < task->rect.w; y++) { | ||||
| (float*) output_ptr, | (float*) output_ptr, | ||||
| &task->rect.x, | &task->rect.x, | ||||
| task->buffer.pass_stride); | task->buffer.pass_stride); | ||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| void path_trace(DeviceTask &task, RenderTile &tile, KernelGlobals *kg) | void render(DeviceTask &task, RenderTile &tile, KernelGlobals *kg) | ||||
| { | { | ||||
| scoped_timer timer(&tile.buffers->render_time); | scoped_timer timer(&tile.buffers->render_time); | ||||
| float *render_buffer = (float*)tile.buffer; | float *render_buffer = (float*)tile.buffer; | ||||
| int start_sample = tile.start_sample; | int start_sample = tile.start_sample; | ||||
| int end_sample = tile.start_sample + tile.num_samples; | int end_sample = tile.start_sample + tile.num_samples; | ||||
| for(int sample = start_sample; sample < end_sample; sample++) { | for(int sample = start_sample; sample < end_sample; sample++) { | ||||
| if(task.get_cancel() || task_pool.canceled()) { | if(task.get_cancel() || task_pool.canceled()) { | ||||
| if(task.need_finish_queue == false) | if(task.need_finish_queue == false) | ||||
| break; | break; | ||||
| } | } | ||||
| if(tile.task == RenderTile::PATH_TRACE) { | |||||
| for(int y = tile.y; y < tile.y + tile.h; y++) { | for(int y = tile.y; y < tile.y + tile.h; y++) { | ||||
| for(int x = tile.x; x < tile.x + tile.w; x++) { | for(int x = tile.x; x < tile.x + tile.w; x++) { | ||||
| path_trace_kernel()(kg, render_buffer, | path_trace_kernel()(kg, render_buffer, | ||||
| sample, x, y, tile.offset, tile.stride); | sample, x, y, tile.offset, tile.stride); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| else { | |||||
| for(int y = tile.y; y < tile.y + tile.h; y++) { | |||||
| for(int x = tile.x; x < tile.x + tile.w; x++) { | |||||
| bake_kernel()(kg, render_buffer, | |||||
| sample, x, y, tile.offset, tile.stride); | |||||
| } | |||||
| } | |||||
| } | |||||
| tile.sample = sample + 1; | tile.sample = sample + 1; | ||||
| task.update_progress(&tile, tile.w*tile.h); | task.update_progress(&tile, tile.w*tile.h); | ||||
| } | } | ||||
| } | } | ||||
| void denoise(DeviceTask &task, DenoisingTask& denoising, RenderTile &tile) | void denoise(DeviceTask &task, DenoisingTask& denoising, RenderTile &tile) | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | void thread_render(DeviceTask& task) | ||||
| while(task.acquire_tile(this, tile)) { | while(task.acquire_tile(this, tile)) { | ||||
| if(tile.task == RenderTile::PATH_TRACE) { | if(tile.task == RenderTile::PATH_TRACE) { | ||||
| if(use_split_kernel) { | if(use_split_kernel) { | ||||
| device_only_memory<uchar> void_buffer(this, "void_buffer"); | device_only_memory<uchar> void_buffer(this, "void_buffer"); | ||||
| split_kernel->path_trace(&task, tile, kgbuffer, void_buffer); | split_kernel->path_trace(&task, tile, kgbuffer, void_buffer); | ||||
| } | } | ||||
| else { | else { | ||||
| path_trace(task, tile, kg); | render(task, tile, kg); | ||||
| } | |||||
| } | } | ||||
| else if(tile.task == RenderTile::BAKE) { | |||||
| render(task, tile, kg); | |||||
| } | } | ||||
| else if(tile.task == RenderTile::DENOISE) { | else if(tile.task == RenderTile::DENOISE) { | ||||
| denoise(task, denoising, tile); | denoise(task, denoising, tile); | ||||
| } | } | ||||
| task.release_tile(tile); | task.release_tile(tile); | ||||
| if(task_pool.canceled()) { | if(task_pool.canceled()) { | ||||
| ▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines | |||||