Blender V4.3
pass_accessor_gpu.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
6
7#include "device/queue.h"
8#include "session/buffers.h"
9#include "util/log.h"
10
12
14 const PassAccessInfo &pass_access_info,
15 float exposure,
16 int num_samples)
17 : PassAccessor(pass_access_info, exposure, num_samples), queue_(queue)
18{
19}
20
21/* --------------------------------------------------------------------
22 * Kernel execution.
23 */
24
26 const RenderBuffers *render_buffers,
27 const BufferParams &buffer_params,
28 const Destination &destination) const
29{
30 KernelFilmConvert kfilm_convert;
31 init_kernel_film_convert(&kfilm_convert, buffer_params, destination);
32
33 const int work_size = buffer_params.window_width * buffer_params.window_height;
34
35 const int destination_stride = destination.stride != 0 ? destination.stride :
36 buffer_params.window_width;
37
38 const int offset = buffer_params.window_x * buffer_params.pass_stride +
39 buffer_params.window_y * buffer_params.stride * buffer_params.pass_stride;
40
42 if (destination.d_pixels) {
43 DCHECK_EQ(destination.stride, 0) << "Custom stride for float destination is not implemented.";
44
45 DeviceKernelArguments args(&kfilm_convert,
46 &destination.d_pixels,
47 &render_buffers->buffer.device_pointer,
48 &work_size,
49 &buffer_params.window_width,
50 &offset,
51 &buffer_params.stride,
52 &destination.pixel_offset,
53 &destination.offset,
54 &destination_stride);
55
56 queue_->enqueue(kernel, work_size, args);
57 }
58 if (destination.d_pixels_half_rgba) {
59 const DeviceKernel kernel_half_float = static_cast<DeviceKernel>(kernel + 1);
60
61 DeviceKernelArguments args(&kfilm_convert,
62 &destination.d_pixels_half_rgba,
63 &render_buffers->buffer.device_pointer,
64 &work_size,
65 &buffer_params.window_width,
66 &offset,
67 &buffer_params.stride,
68 &destination.offset,
69 &destination_stride);
70
71 queue_->enqueue(kernel_half_float, work_size, args);
72 }
73
75}
76
77/* --------------------------------------------------------------------
78 * Pass accessors.
79 */
80
81#define DEFINE_PASS_ACCESSOR(pass, kernel_pass) \
82 void PassAccessorGPU::get_pass_##pass(const RenderBuffers *render_buffers, \
83 const BufferParams &buffer_params, \
84 const Destination &destination) const \
85 { \
86 run_film_convert_kernels( \
87 DEVICE_KERNEL_FILM_CONVERT_##kernel_pass, render_buffers, buffer_params, destination); \
88 }
89
90/* Float (scalar) passes. */
93DEFINE_PASS_ACCESSOR(sample_count, SAMPLE_COUNT);
95
96/* Float3 passes. */
97DEFINE_PASS_ACCESSOR(light_path, LIGHT_PATH);
99
100/* Float4 passes. */
101DEFINE_PASS_ACCESSOR(motion, MOTION);
102DEFINE_PASS_ACCESSOR(cryptomatte, CRYPTOMATTE);
103DEFINE_PASS_ACCESSOR(shadow_catcher, SHADOW_CATCHER);
104DEFINE_PASS_ACCESSOR(shadow_catcher_matte_with_shadow, SHADOW_CATCHER_MATTE_WITH_SHADOW);
105DEFINE_PASS_ACCESSOR(combined, COMBINED);
107
108#undef DEFINE_PASS_ACCESSOR
109
int pass_stride
Definition buffers.h:94
int window_y
Definition buffers.h:80
int window_height
Definition buffers.h:82
int window_width
Definition buffers.h:81
int window_x
Definition buffers.h:79
virtual void init_execution()=0
virtual bool synchronize()=0
virtual bool enqueue(DeviceKernel kernel, const int work_size, DeviceKernelArguments const &args)=0
DeviceQueue * queue_
void run_film_convert_kernels(DeviceKernel kernel, const RenderBuffers *render_buffers, const BufferParams &buffer_params, const Destination &destination) const
PassAccessorGPU(DeviceQueue *queue, const PassAccessInfo &pass_access_info, float exposure, int num_samples)
virtual void init_kernel_film_convert(KernelFilmConvert *kfilm_convert, const BufferParams &buffer_params, const Destination &destination) const
device_vector< float > buffer
Definition buffers.h:160
#define CCL_NAMESPACE_END
ccl_gpu_kernel_postfix ccl_global const int ccl_global float const int work_size
DeviceKernel
#define DCHECK_EQ(a, b)
Definition log.h:59
#define DEFINE_PASS_ACCESSOR(pass, kernel_pass)
@ FLOAT4
@ FLOAT3
@ FLOAT