Blender V4.3
work_stealing.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
8
9/*
10 * Utility functions for work stealing
11 */
12
13/* Map global work index to tile, pixel X/Y and sample. */
15 uint global_work_index,
19{
20 uint sample_offset, pixel_offset;
21
22 if (kernel_data.integrator.scrambling_distance < 0.9f) {
23 /* Keep threads for the same sample together. */
24 uint tile_pixels = tile->w * tile->h;
25 sample_offset = global_work_index / tile_pixels;
26 pixel_offset = global_work_index - sample_offset * tile_pixels;
27 }
28 else {
29 /* Keeping threads for the same pixel together.
30 * Appears to improve performance by a few % on CUDA and OptiX. */
31 sample_offset = global_work_index % tile->num_samples;
32 pixel_offset = global_work_index / tile->num_samples;
33 }
34
35 uint y_offset = pixel_offset / tile->w;
36 uint x_offset = pixel_offset - y_offset * tile->w;
37
38 *x = tile->x + x_offset;
39 *y = tile->y + y_offset;
40 *sample = tile->start_sample + sample_offset;
41}
42
unsigned int uint
#define kernel_data
#define ccl_private
#define ccl_device_inline
#define ccl_global
#define CCL_NAMESPACE_END
ccl_global const KernelWorkTile * tile
CCL_NAMESPACE_BEGIN ccl_device_inline void get_work_pixel(ccl_global const KernelWorkTile *tile, uint global_work_index, ccl_private uint *x, ccl_private uint *y, ccl_private uint *sample)