Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/integrator/path_trace_work_gpu.cpp
| Show First 20 Lines • Show All 696 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| const int full_x = effective_buffer_params_.full_x; | const int full_x = effective_buffer_params_.full_x; | ||||
| const int full_y = effective_buffer_params_.full_y; | const int full_y = effective_buffer_params_.full_y; | ||||
| const int width = effective_buffer_params_.width; | const int width = effective_buffer_params_.width; | ||||
| const int height = effective_buffer_params_.height; | const int height = effective_buffer_params_.height; | ||||
| const int final_width = buffers_->params.width; | const int final_width = buffers_->params.width; | ||||
| const int final_height = buffers_->params.height; | const int final_height = buffers_->params.height; | ||||
| const int texture_x = full_x - effective_big_tile_params_.full_x; | const int texture_x = full_x - effective_full_params_.full_x; | ||||
| const int texture_y = full_y - effective_big_tile_params_.full_y; | const int texture_y = full_y - effective_full_params_.full_y; | ||||
| /* Re-allocate display memory if needed, and make sure the device pointer is allocated. | /* Re-allocate display memory if needed, and make sure the device pointer is allocated. | ||||
| * | * | ||||
| * NOTE: allocation happens to the final resolution so that no re-allocation happens on every | * NOTE: allocation happens to the final resolution so that no re-allocation happens on every | ||||
| * change of the resolution divider. However, if the display becomes smaller, shrink the | * change of the resolution divider. However, if the display becomes smaller, shrink the | ||||
| * allocated memory as well. */ | * allocated memory as well. */ | ||||
| if (gpu_display_rgba_half_.data_width != final_width || | if (gpu_display_rgba_half_.data_width != final_width || | ||||
| gpu_display_rgba_half_.data_height != final_height) { | gpu_display_rgba_half_.data_height != final_height) { | ||||
| gpu_display_rgba_half_.alloc(final_width, final_height); | gpu_display_rgba_half_.alloc(final_width, final_height); | ||||
| /* TODO(sergey): There should be a way to make sure device-side memory is allocated without | /* TODO(sergey): There should be a way to make sure device-side memory is allocated without | ||||
| * transfering zeroes to the device. */ | * transfering zeroes to the device. */ | ||||
| queue_->zero_to_device(gpu_display_rgba_half_); | queue_->zero_to_device(gpu_display_rgba_half_); | ||||
| } | } | ||||
| run_film_convert(gpu_display_rgba_half_.device_pointer, pass_mode, num_samples); | PassAccessor::Destination destination(film_->get_display_pass()); | ||||
| destination.d_pixels_half_rgba = gpu_display_rgba_half_.device_pointer; | |||||
| get_render_tile_film_pixels(destination, pass_mode, num_samples); | |||||
| gpu_display_rgba_half_.copy_from_device(); | gpu_display_rgba_half_.copy_from_device(); | ||||
| gpu_display->copy_pixels_to_texture( | gpu_display->copy_pixels_to_texture( | ||||
| gpu_display_rgba_half_.data(), texture_x, texture_y, width, height); | gpu_display_rgba_half_.data(), texture_x, texture_y, width, height); | ||||
| } | } | ||||
| bool PathTraceWorkGPU::copy_to_gpu_display_interop(GPUDisplay *gpu_display, | bool PathTraceWorkGPU::copy_to_gpu_display_interop(GPUDisplay *gpu_display, | ||||
| PassMode pass_mode, | PassMode pass_mode, | ||||
| int num_samples) | int num_samples) | ||||
| { | { | ||||
| if (!device_graphics_interop_) { | if (!device_graphics_interop_) { | ||||
| device_graphics_interop_ = queue_->graphics_interop_create(); | device_graphics_interop_ = queue_->graphics_interop_create(); | ||||
| } | } | ||||
| const DeviceGraphicsInteropDestination graphics_interop_dst = | const DeviceGraphicsInteropDestination graphics_interop_dst = | ||||
| gpu_display->graphics_interop_get(); | gpu_display->graphics_interop_get(); | ||||
| device_graphics_interop_->set_destination(graphics_interop_dst); | device_graphics_interop_->set_destination(graphics_interop_dst); | ||||
| const device_ptr d_rgba_half = device_graphics_interop_->map(); | const device_ptr d_rgba_half = device_graphics_interop_->map(); | ||||
| if (!d_rgba_half) { | if (!d_rgba_half) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* NOTE: No need to take device slice into account since the interop is only used during single | PassAccessor::Destination destination = get_gpu_display_destination_template(gpu_display); | ||||
| * device rendering. */ | destination.d_pixels_half_rgba = d_rgba_half; | ||||
| run_film_convert(d_rgba_half, pass_mode, num_samples); | get_render_tile_film_pixels(destination, pass_mode, num_samples); | ||||
| device_graphics_interop_->unmap(); | device_graphics_interop_->unmap(); | ||||
| return true; | return true; | ||||
| } | } | ||||
| void PathTraceWorkGPU::run_film_convert(device_ptr d_rgba_half, | void PathTraceWorkGPU::get_render_tile_film_pixels(const PassAccessor::Destination &destination, | ||||
| PassMode pass_mode, | PassMode pass_mode, | ||||
| int num_samples) | int num_samples) | ||||
| { | { | ||||
| const KernelFilm &kfilm = device_scene_->data.film; | const KernelFilm &kfilm = device_scene_->data.film; | ||||
| const PassAccessor::PassAccessInfo pass_access_info = get_display_pass_access_info(pass_mode); | const PassAccessor::PassAccessInfo pass_access_info = get_display_pass_access_info(pass_mode); | ||||
| const PassAccessorGPU pass_accessor(queue_.get(), pass_access_info, kfilm.exposure, num_samples); | const PassAccessorGPU pass_accessor(queue_.get(), pass_access_info, kfilm.exposure, num_samples); | ||||
| PassAccessor::Destination destination(pass_access_info.type); | |||||
| destination.d_pixels_half_rgba = d_rgba_half; | |||||
| pass_accessor.get_render_tile_pixels(buffers_.get(), effective_buffer_params_, destination); | pass_accessor.get_render_tile_pixels(buffers_.get(), effective_buffer_params_, destination); | ||||
| } | } | ||||
| int PathTraceWorkGPU::adaptive_sampling_converge_filter_count_active(float threshold, bool reset) | int PathTraceWorkGPU::adaptive_sampling_converge_filter_count_active(float threshold, bool reset) | ||||
| { | { | ||||
| const int num_active_pixels = adaptive_sampling_convergence_check_count_active(threshold, reset); | const int num_active_pixels = adaptive_sampling_convergence_check_count_active(threshold, reset); | ||||
| if (num_active_pixels) { | if (num_active_pixels) { | ||||
| ▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines | |||||