Blender V5.3
eevee_film.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14
15#include "BLI_hash_c.hh"
16#include "BLI_rect.hh"
17#include "BLI_set.hh"
18
19#include "BKE_compositor.hh"
20#include "BKE_scene.hh"
21
22#include "GPU_framebuffer.hh"
23#include "GPU_texture.hh"
24
25#include "DRW_render.hh"
26#include "RE_pipeline.h"
27
28#include "draw_view_data.hh"
29
30#include "eevee_film.hh"
31#include "eevee_instance.hh"
32
33namespace blender::eevee {
34
35/* -------------------------------------------------------------------- */
38
39void Film::init_aovs(const Set<std::string> &passes_used_by_viewport_compositor)
40{
41 Vector<ViewLayerAOV *> aovs;
42
43 aovs_info.display_id = -1;
44 aovs_info.display_is_value = false;
45 aovs_info.value_len = aovs_info.color_len = 0;
46
47 if (inst_.is_viewport()) {
48 /* Viewport case. */
49 if (inst_.v3d->shading.render_pass == EEVEE_RENDER_PASS_AOV) {
50 /* AOV display, request only a single AOV. */
51 ViewLayerAOV *aov = static_cast<ViewLayerAOV *>(BLI_findstring(
52 &inst_.view_layer->aovs, inst_.v3d->shading.aov_name, offsetof(ViewLayerAOV, name)));
53
54 /* AOV found in view layer. */
55 if (aov) {
56 aovs.append(aov);
57 aovs_info.display_id = 0;
58 aovs_info.display_is_value = (aov->type == AOV_TYPE_VALUE);
59 }
60 }
61
62 if (inst_.is_viewport_compositor_used) {
63 for (ViewLayerAOV &aov : inst_.view_layer->aovs) {
64 /* Already added as a display pass. No need to add again. */
65 if (!aovs.is_empty() && aovs.last() == &aov) {
66 continue;
67 }
68
69 if (passes_used_by_viewport_compositor.contains(aov.name)) {
70 aovs.append(&aov);
71 }
72 }
73 }
74 }
75 else {
76 /* Render case. */
77 for (ViewLayerAOV &aov : inst_.view_layer->aovs) {
78 aovs.append(&aov);
79 }
80 }
81
82 if (aovs.size() > AOV_MAX) {
83 inst_.info_append_i18n("Error: Too many AOVs");
84 return;
85 }
86
87 /* Pack color AOV hashes first, then value AOV hashes. Value hashes are placed after
88 * color hashes using the final color count as base, so the two must be packed in
89 * separate passes to avoid collisions when a value AOV precedes a color AOV. */
90 for (ViewLayerAOV *aov : aovs) {
91 if (aov->type == AOV_TYPE_VALUE) {
92 continue;
93 }
94 int &index = aovs_info.color_len;
95 aovs_info.hash[index / 4][index % 4] = BLI_hash_string(aov->name);
96 index++;
97 }
98 for (ViewLayerAOV *aov : aovs) {
99 if (aov->type == AOV_TYPE_COLOR) {
100 continue;
101 }
102 int &index = aovs_info.value_len;
103 int combined_index = aovs_info.color_len + index;
104 aovs_info.hash[combined_index / 4][combined_index % 4] = BLI_hash_string(aov->name);
105 index++;
106 }
107
108 if (!aovs.is_empty()) {
109 enabled_categories_ |= PASS_CATEGORY_AOV;
110 }
111}
112
114{
115 gpu::Texture *pass_tx = this->get_aov_texture(aov);
116
117 if (pass_tx == nullptr) {
118 return nullptr;
119 }
120
122
123 return static_cast<float *>(GPU_texture_read(pass_tx, GPU_DATA_FLOAT, 0));
124}
125
127{
128 bool is_value = (aov->type == AOV_TYPE_VALUE);
129 Texture &accum_tx = is_value ? value_accum_tx_ : color_accum_tx_;
130
131 /* Find AOV index next, by searching for the matching hash. */
133 int aov_index = -1;
134
135 /* Hashes are packed in tuples of 4, and value hashes are placed after color hashes,
136 * so we iterate only the relevant range. */
137 IndexRange color_range(0, aovs_info.color_len);
138 IndexRange value_range(aovs_info.color_len, aovs_info.value_len);
139 for (int i : (is_value ? value_range : color_range)) {
140 uint candidate_hash = aovs_info.hash[i / 4][i % 4];
141 if (candidate_hash == hash) {
142 aov_index = i - (is_value ? aovs_info.color_len : 0);
143 break;
144 }
145 }
146
147 if (aov_index == -1) {
148 return nullptr;
149 }
150
151 accum_tx.ensure_layer_views();
152
153 int index = aov_index + (is_value ? data_.aov_value_id : data_.aov_color_id);
154 return accum_tx.layer_view(index);
155}
156
158
159/* -------------------------------------------------------------------- */
162
163void Film::sync_mist()
164{
165 const CameraData &cam = inst_.camera.data_get();
166 const blender::World *world = inst_.scene->world;
167 float mist_start = world ? world->miststa : cam.clip_near;
168 float mist_distance = world ? world->mistdist : fabsf(cam.clip_far - cam.clip_near);
169 int mist_type = world ? world->mistype : int(WO_MIST_LINEAR);
170
171 switch (mist_type) {
173 data_.mist_exponent = 2.0f;
174 break;
175 case WO_MIST_LINEAR:
176 data_.mist_exponent = 1.0f;
177 break;
179 data_.mist_exponent = 0.5f;
180 break;
181 }
182
183 data_.mist_scale = 1.0 / mist_distance;
184 data_.mist_bias = -mist_start / mist_distance;
185}
186
188
189/* -------------------------------------------------------------------- */
192
193inline bool operator==(const FilmData &a, const FilmData &b)
194{
195 return (a.extent == b.extent) && (a.offset == b.offset) &&
196 (a.render_extent == b.render_extent) && (a.overscan == b.overscan) &&
197 (a.filter_radius == b.filter_radius) && (a.scaling_factor == b.scaling_factor) &&
198 (a.background_opacity == b.background_opacity);
199}
200
201inline bool operator!=(const FilmData &a, const FilmData &b)
202{
203 return !(a == b);
204}
205
207
208/* -------------------------------------------------------------------- */
211
213{
215
216 /* We enforce the use of combined pass to be compliant with Cycles and EEVEE-Legacy (#122188). */
218
219#define ENABLE_FROM_LEGACY(name_legacy, name_eevee) \
220 SET_FLAG_FROM_TEST(result, \
221 (view_layer->passflag & SCE_PASS_##name_legacy) != 0, \
222 EEVEE_RENDER_PASS_##name_eevee);
223
224 ENABLE_FROM_LEGACY(DEPTH, DEPTH)
225 ENABLE_FROM_LEGACY(MIST, MIST)
227 ENABLE_FROM_LEGACY(POSITION, POSITION)
228 ENABLE_FROM_LEGACY(SHADOW, SHADOW)
230 ENABLE_FROM_LEGACY(EMIT, EMIT)
231 ENABLE_FROM_LEGACY(ENVIRONMENT, ENVIRONMENT)
232 ENABLE_FROM_LEGACY(DIFFUSE_COLOR, DIFFUSE_COLOR)
233 ENABLE_FROM_LEGACY(GLOSSY_COLOR, SPECULAR_COLOR)
234 ENABLE_FROM_LEGACY(DIFFUSE_DIRECT, DIFFUSE_LIGHT)
235 ENABLE_FROM_LEGACY(GLOSSY_DIRECT, SPECULAR_LIGHT)
236 ENABLE_FROM_LEGACY(ENVIRONMENT, ENVIRONMENT)
238
239#undef ENABLE_FROM_LEGACY
240
250
257
258 return result;
259}
260
261/* Get all pass types used by the viewport compositor from the set of all needed passes. */
263 const Set<std::string> &viewport_compositor_needed_passes, const ViewLayer *view_layer)
264{
265 const eViewLayerEEVEEPassType scene_enabled_passes = enabled_passes(view_layer);
266
267 /* Go over all possible pass types, check if their possible pass names exist in the viewport
268 * compositor needed passes, and if true, mark them as needed. */
269 eViewLayerEEVEEPassType viewport_compositor_enabled_passes = eViewLayerEEVEEPassType(0);
270 for (const int i : IndexRange(EEVEE_RENDER_PASS_MAX_BIT + 1)) {
271 /* Mask by the scene enabled passes, because some pass types like EEVEE_RENDER_PASS_UNUSED_8
272 * have no corresponding pass names, so they will assert later. */
273 eViewLayerEEVEEPassType pass_type = eViewLayerEEVEEPassType(scene_enabled_passes & (1 << i));
274 if (pass_type == 0) {
275 continue;
276 }
277
278 for (const std::string &pass_name : Film::pass_to_render_pass_names(pass_type, view_layer)) {
279 if (viewport_compositor_needed_passes.contains(pass_name)) {
280 viewport_compositor_enabled_passes |= pass_type;
281 }
282 }
283 }
284
285 return viewport_compositor_enabled_passes;
286}
287
288/* Light passes are stored pre-divided by their matching Color pass, so Color must be enabled
289 * whenever Light is (#161352). */
300
301void Film::init(const int2 &extent, const rcti *output_rect)
302{
303 using namespace math;
304
305 Sampling &sampling = inst_.sampling;
306 Scene &scene = *inst_.scene;
307
308 if (inst_.is_viewport()) {
309 /* Update detection of viewport setting. */
310 const View3DShading &shading = inst_.v3d->shading;
311 int update = 0;
312 update += assign_if_different(ui_render_pass_, eViewLayerEEVEEPassType(shading.render_pass));
313 update += assign_if_different(ui_aov_name_, std::string(shading.aov_name));
314 if (update) {
315 inst_.sampling.reset();
316 }
317 }
318
320
321 /* Compute the passes needed by the viewport compositor. */
322 Set<std::string> passes_used_by_viewport_compositor;
323 if (inst_.is_viewport_compositor_used) {
324 passes_used_by_viewport_compositor = bke::compositor::get_used_passes(
325 scene, inst_.view_layer, bke::compositor::ExecutionMode::Preview);
326 viewport_compositor_enabled_passes_ = get_viewport_compositor_enabled_passes(
327 passes_used_by_viewport_compositor, inst_.view_layer);
328 }
329 else {
330 viewport_compositor_enabled_passes_ = eViewLayerEEVEEPassType(0);
331 }
332
333 enabled_categories_ = PassCategory(0);
334 init_aovs(passes_used_by_viewport_compositor);
335
336 {
337 /* Enable passes that need to be rendered. */
338 if (inst_.is_viewport()) {
339 /* Viewport Case. */
341 inst_.v3d->shading.render_pass) |
342 viewport_compositor_enabled_passes_;
343
344 if (inst_.overlays_enabled() || inst_.gpencil_engine_enabled()) {
345 /* Overlays and Grease Pencil needs the depth for correct compositing.
346 * Using the render pass ensure we store the center depth. */
348 }
349
351
352 if (assign_if_different(enabled_passes_, enabled_passes)) {
353 inst_.sampling.reset();
354 }
355 }
356 else {
357 /* Render Case. */
358 enabled_passes_ = enabled_passes(inst_.view_layer);
359 }
360
361 enabled_passes_ = with_light_pass_color_dependencies(enabled_passes_);
362
363 /* Filter obsolete passes. */
365
366 if (scene.r.mode & R_MBLUR) {
367 /* Disable motion vector pass if motion blur is enabled. */
368 enabled_passes_ &= ~EEVEE_RENDER_PASS_VECTOR;
369 }
370 }
371 {
372 data_.scaling_factor = 1;
373 if (inst_.is_viewport()) {
374 data_.scaling_factor = BKE_render_preview_pixel_size(&inst_.scene->r);
375 }
376 /* Sharpen the LODs (1.5x) to avoid TAA filtering causing over-blur (see #122941). */
377 data_.texture_lod_bias = 1.0f / (data_.scaling_factor * 1.5f);
378 }
379 {
380 rcti fallback_rect;
381 if (BLI_rcti_is_empty(output_rect)) {
382 BLI_rcti_init(&fallback_rect, 0, extent[0], 0, extent[1]);
383 output_rect = &fallback_rect;
384 }
385
386 display_extent = extent;
387
388 data_.extent = int2(BLI_rcti_size_x(output_rect), BLI_rcti_size_y(output_rect));
389 data_.offset = int2(output_rect->xmin, output_rect->ymin);
390 data_.extent_inv = 1.0f / float2(data_.extent);
391 data_.render_extent = divide_ceil(data_.extent, int2(data_.scaling_factor));
392 data_.overscan = overscan_pixels_get(inst_.camera.overscan(), data_.render_extent);
393 data_.render_extent += data_.overscan * 2;
394
395 is_valid_render_extent_ = data_.render_extent.x <= GPU_max_texture_size() &&
396 data_.render_extent.y <= GPU_max_texture_size();
397 if (!is_valid_render_extent_) {
398 inst_.info_append_i18n(
399 "Required render size ({}px) is larger than reported texture size limit ({}px).",
400 max_ii(data_.render_extent.x, data_.render_extent.y),
402
403 data_.extent = int2(4, 4);
404 data_.render_extent = int2(4, 4);
405 data_.extent_inv = 1.0f / float2(data_.extent);
406 data_.offset = int2(0, 0);
407 data_.overscan = 0;
408 }
409
410 if (inst_.camera.is_panoramic()) {
411 /* Reshape into a square so each face's pixel density stays close to the final film.
412 * TODO: Remove once per projection face clipping is implemented. */
413 int64_t render_pixel_count = data_.render_extent.x * int64_t(data_.render_extent.y);
414 render_extent_shading_view_ = int2(ceilf(sqrtf(float(render_pixel_count))));
415 }
416 else {
417 render_extent_shading_view_ = data_.render_extent;
418 }
419
420 data_.filter_radius = clamp_f(scene.r.gauss, 0.0f, 100.0f);
421 if (sampling.sample_count() == 1) {
422 /* Disable filtering if sample count is 1. */
423 data_.filter_radius = 0.0f;
424 }
425 if (data_.scaling_factor > 1) {
426 /* Fixes issue when using scaling factor and no filtering.
427 * Without this, the filter becomes a dirac and samples gets only the fallback weight.
428 * This results in a box blur instead of no filtering. */
429 data_.filter_radius = math::max(data_.filter_radius, 0.0001f);
430 }
431 if (inst_.camera.is_panoramic()) {
432 /* Avoid div by zero in the panoramic filter weights. */
433 data_.filter_radius = math::max(data_.filter_radius, 0.0001f);
434 }
435
436 data_.cryptomatte_samples_len = inst_.view_layer->cryptomatte_levels;
437
438 data_.background_opacity = (scene.r.alphamode == R_ALPHAPREMUL) ? 0.0f : 1.0f;
439 if (inst_.is_viewport() && false /* TODO(fclem): StudioLight */) {
440 data_.background_opacity = inst_.v3d->shading.studiolight_background;
441 }
442
465
466 data_.exposure_scale = pow2f(scene.view_settings.exposure);
467 if (enabled_passes_ & data_passes) {
468 enabled_categories_ |= PASS_CATEGORY_DATA;
469 }
470 if (enabled_passes_ & color_passes_1) {
471 enabled_categories_ |= PASS_CATEGORY_COLOR_1;
472 }
473 if (enabled_passes_ & color_passes_2) {
474 enabled_categories_ |= PASS_CATEGORY_COLOR_2;
475 }
476 if (enabled_passes_ & color_passes_3) {
477 enabled_categories_ |= PASS_CATEGORY_COLOR_3;
478 }
479 if (enabled_passes_ & cryptomatte_passes) {
480 enabled_categories_ |= PASS_CATEGORY_CRYPTOMATTE;
481 }
482 if (enabled_passes_ & denoising_passes) {
483 enabled_categories_ |= PASS_CATEGORY_DENOISE;
484 }
485 }
486 {
487 /* Set pass offsets. */
488
489 data_.display_id = aovs_info.display_id;
490 data_.display_storage_type = aovs_info.display_is_value ? PASS_STORAGE_VALUE :
492
493 /* Combined is in a separate buffer. */
494 data_.combined_id = (enabled_passes_ & EEVEE_RENDER_PASS_COMBINED) ? 0 : -1;
495 /* Depth is in a separate buffer. */
496 data_.depth_id = (enabled_passes_ & EEVEE_RENDER_PASS_DEPTH) ? 0 : -1;
497
498 data_.color_len = 0;
499 data_.value_len = 0;
500
501 int cryptomatte_id = 0;
502 auto pass_index_get = [&](eViewLayerEEVEEPassType pass_type) {
503 ePassStorageType storage_type = pass_storage_type(pass_type);
504 int index = -1;
505 if (enabled_passes_ & pass_type) {
506 if (storage_type == PASS_STORAGE_COLOR) {
507 index = data_.color_len++;
508 }
509 else if (storage_type == PASS_STORAGE_VALUE) {
510 index = data_.value_len++;
511 }
512 else if (storage_type == PASS_STORAGE_CRYPTOMATTE) {
513 index = cryptomatte_id;
514 cryptomatte_id += divide_ceil_u(data_.cryptomatte_samples_len, 2u);
515 }
516 else if (storage_type == PASS_STORAGE_DENOISING_DEPTH) {
517 index = 0;
518 }
519
520 if (inst_.is_viewport() && inst_.v3d->shading.render_pass == pass_type) {
521 data_.display_id = index;
522 data_.display_storage_type = storage_type;
523 }
524 }
525 return index;
526 };
527
528 data_.mist_id = pass_index_get(EEVEE_RENDER_PASS_MIST);
529 data_.normal_id = pass_index_get(EEVEE_RENDER_PASS_NORMAL);
530 data_.position_id = pass_index_get(EEVEE_RENDER_PASS_POSITION);
531 data_.vector_id = pass_index_get(EEVEE_RENDER_PASS_VECTOR);
532 data_.diffuse_light_id = pass_index_get(EEVEE_RENDER_PASS_DIFFUSE_LIGHT);
533 data_.diffuse_color_id = pass_index_get(EEVEE_RENDER_PASS_DIFFUSE_COLOR);
534 data_.specular_light_id = pass_index_get(EEVEE_RENDER_PASS_SPECULAR_LIGHT);
535 data_.specular_color_id = pass_index_get(EEVEE_RENDER_PASS_SPECULAR_COLOR);
536 data_.volume_light_id = pass_index_get(EEVEE_RENDER_PASS_VOLUME_LIGHT);
537 data_.emission_id = pass_index_get(EEVEE_RENDER_PASS_EMIT);
538 data_.environment_id = pass_index_get(EEVEE_RENDER_PASS_ENVIRONMENT);
539 data_.shadow_id = pass_index_get(EEVEE_RENDER_PASS_SHADOW);
540 data_.ambient_occlusion_id = pass_index_get(EEVEE_RENDER_PASS_AO);
541 data_.transparent_id = pass_index_get(EEVEE_RENDER_PASS_TRANSPARENT);
542
543 data_.denoising_depth_id = pass_index_get(EEVEE_RENDER_PASS_DENOISING_DEPTH);
544 data_.denoising_normal_id = pass_index_get(EEVEE_RENDER_PASS_DENOISING_NORMAL);
545 data_.denoising_roughness_id = pass_index_get(EEVEE_RENDER_PASS_DENOISING_ROUGHNESS);
546 data_.denoising_diffuse_albedo_id = pass_index_get(EEVEE_RENDER_PASS_DENOISING_DIFFUSE_ALBEDO);
547 data_.denoising_specular_albedo_id = pass_index_get(
549
550 data_.aov_color_id = data_.color_len;
551 data_.aov_value_id = data_.value_len;
552
553 data_.aov_color_len = aovs_info.color_len;
554 data_.aov_value_len = aovs_info.value_len;
555
556 data_.color_len += data_.aov_color_len;
557 data_.value_len += data_.aov_value_len;
558
559 data_.cryptomatte_object_id = pass_index_get(EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT);
560 data_.cryptomatte_asset_id = pass_index_get(EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET);
561 data_.cryptomatte_material_id = pass_index_get(EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL);
562 }
563 {
564 int2 weight_extent = (inst_.camera.is_panoramic() || (data_.scaling_factor > 1)) ?
565 data_.extent :
566 int2(1);
567
568 gpu::TextureFormat color_format = gpu::TextureFormat::SFLOAT_16_16_16_16;
569 gpu::TextureFormat float_format = gpu::TextureFormat::SFLOAT_16;
570 gpu::TextureFormat weight_format = gpu::TextureFormat::SFLOAT_32;
571 gpu::TextureFormat depth_format = gpu::TextureFormat::SFLOAT_32;
572 gpu::TextureFormat cryptomatte_format = gpu::TextureFormat::SFLOAT_32_32_32_32;
573
574 int reset = 0;
575 reset += depth_tx_.ensure_2d(depth_format, data_.extent);
576 reset += combined_tx_.current().ensure_2d(color_format, data_.extent);
577 reset += combined_tx_.next().ensure_2d(color_format, data_.extent);
578 /* Two layers, one for nearest sample weight and one for weight accumulation. */
579 reset += weight_tx_.current().ensure_2d_array(weight_format, weight_extent, 2);
580 reset += weight_tx_.next().ensure_2d_array(weight_format, weight_extent, 2);
581 reset += color_accum_tx_.ensure_2d_array(color_format,
582 (data_.color_len > 0) ? data_.extent : int2(1),
583 (data_.color_len > 0) ? data_.color_len : 1);
584 reset += value_accum_tx_.ensure_2d_array(float_format,
585 (data_.value_len > 0) ? data_.extent : int2(1),
586 (data_.value_len > 0) ? data_.value_len : 1);
587 /* Divided by two as two cryptomatte samples fit in pixel (RG, BA). */
588 int cryptomatte_array_len = cryptomatte_layer_len_get() *
589 divide_ceil_u(data_.cryptomatte_samples_len, 2u);
590 reset += cryptomatte_tx_.ensure_2d_array(cryptomatte_format,
591 (cryptomatte_array_len > 0) ? data_.extent : int2(1),
592 (cryptomatte_array_len > 0) ? cryptomatte_array_len :
593 1);
594 reset += denoising_depth_tx_.ensure_2d(
595 depth_format,
596 (enabled_passes_ & EEVEE_RENDER_PASS_DENOISING_DEPTH) ? data_.extent : int2(1));
597
598 if (reset > 0) {
599 data_.use_history = 0;
600 use_reprojection_ = false;
601
602 /* Avoid NaN in uninitialized texture memory making history blending dangerous. */
603 color_accum_tx_.clear(float4(0.0f));
604 value_accum_tx_.clear(float4(0.0f));
605 combined_tx_.current().clear(float4(0.0f));
606 weight_tx_.current().clear(float4(0.0f));
607 depth_tx_.clear(float4(0.0f));
608 cryptomatte_tx_.clear(float4(0.0f));
609 denoising_depth_tx_.clear(float4(0.0f));
610 }
611 }
612}
613
615{
616 /* We use a fragment shader for viewport because we need to output the depth.
617 *
618 * Compute shader is also used to work around Metal/Intel iGPU issues concerning
619 * read write support for array textures. In this case the copy_ps_ is used to
620 * copy the right color/value to the framebuffer.
621 *
622 * It is also disabled for Windows on ARM as certain GPU/Driver combinations will cause a driver
623 * compiler crash. There is no way to detect up front when this is the case.
624 *
625 * See #153463
626 */
627 /* The fragment shader path below is only safe to call once per frame, so force the
628 * compute path for panoramic to avoid a race between accumulate calls. */
629 use_compute_ = !inst_.is_viewport() || inst_.camera.is_panoramic() ||
633
634 eShaderType shader = inst_.camera.is_panoramic() ? FILM_COMP_PANORAMIC :
635 (use_compute_ ? FILM_COMP : FILM_FRAG);
636
637 /* TODO(fclem): Shader variation for scaled resolution. */
638
639 gpu::Shader *sh = inst_.shaders.static_shader_get(shader);
640 accumulate_ps_.init();
641 init_pass(accumulate_ps_, sh);
642 /* Sync with rendering passes. */
644 if (use_compute_) {
645 accumulate_ps_.dispatch(int3(math::divide_ceil(data_.extent, int2(FILM_GROUP_SIZE)), 1));
646 }
647 else {
648 accumulate_ps_.push_constant("display_only", &display_only_);
649 accumulate_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3);
650 }
651
652 copy_ps_.init();
653 if (use_compute_ && inst_.is_viewport()) {
654 init_pass(copy_ps_, inst_.shaders.static_shader_get(FILM_COPY));
656 copy_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3);
657 }
658
659 const int cryptomatte_layer_count = cryptomatte_layer_len_get();
660 const bool is_cryptomatte_pass_enabled = cryptomatte_layer_count > 0;
661 const bool do_cryptomatte_sorting = !inst_.is_viewport() || inst_.is_viewport_compositor_used;
662 cryptomatte_post_ps_.init();
663 if (is_cryptomatte_pass_enabled && do_cryptomatte_sorting) {
664 cryptomatte_post_ps_.state_set(DRW_STATE_NO_DRAW);
665 cryptomatte_post_ps_.shader_set(inst_.shaders.static_shader_get(FILM_CRYPTOMATTE_POST));
666 cryptomatte_post_ps_.bind_image("cryptomatte_img", &cryptomatte_tx_);
667 cryptomatte_post_ps_.bind_resources(inst_.uniform_data);
668 cryptomatte_post_ps_.push_constant("cryptomatte_layer_len", cryptomatte_layer_count);
669 cryptomatte_post_ps_.push_constant("cryptomatte_samples_per_layer",
670 inst_.view_layer->cryptomatte_levels);
671 int2 dispatch_size = math::divide_ceil(int2(cryptomatte_tx_.size()), int2(FILM_GROUP_SIZE));
672 cryptomatte_post_ps_.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS);
673 cryptomatte_post_ps_.dispatch(int3(UNPACK2(dispatch_size), 1));
674 }
675}
676
677void Film::init_pass(PassSimple &pass, gpu::Shader *sh)
678{
680 RenderBuffers &rbuffers = inst_.render_buffers;
681 VelocityModule &velocity = inst_.velocity;
682
683 pass.specialize_constant(sh, "enabled_categories", uint(enabled_categories_));
684 pass.specialize_constant(sh, "samples_len", &data_.samples_len);
685 pass.specialize_constant(sh, "use_reprojection", &use_reprojection_);
686 pass.specialize_constant(sh, "scaling_factor", data_.scaling_factor);
687 pass.specialize_constant(sh, "combined_id", &data_.combined_id);
688 pass.specialize_constant(sh, "display_id", &data_.display_id);
689 pass.specialize_constant(sh, "normal_id", &data_.normal_id);
691 pass.shader_set(sh);
692 /* For viewport, only previous motion is supported.
693 * Still bind previous step to avoid undefined behavior. */
694 eVelocityStep step_next = inst_.is_viewport() ? STEP_PREVIOUS : STEP_NEXT;
695
696 pass.bind_resources(inst_.uniform_data);
697 pass.bind_ubo("camera_prev", &(*velocity.camera_steps[STEP_PREVIOUS]));
698 pass.bind_ubo("camera_curr", &(*velocity.camera_steps[STEP_CURRENT]));
699 pass.bind_ubo("camera_next", &(*velocity.camera_steps[step_next]));
700 pass.bind_texture("depth_tx", &rbuffers.depth_tx);
701 pass.bind_texture("combined_tx", &combined_final_tx_, filter);
702 pass.bind_texture("vector_tx", &rbuffers.vector_tx);
703 pass.bind_texture("rp_color_tx", &rbuffers.rp_color_tx);
704 pass.bind_texture("rp_value_tx", &rbuffers.rp_value_tx);
705 pass.bind_texture("cryptomatte_tx", &rbuffers.cryptomatte_tx);
706 /* NOTE(@fclem): 16 is the max number of sampled texture in many implementations.
707 * If we need more, we need to pack more of the similar passes in the same textures as arrays or
708 * use image binding instead. */
709 pass.bind_image("in_weight_img", &weight_tx_.current());
710 pass.bind_image("out_weight_img", &weight_tx_.next());
711 pass.bind_texture("in_combined_tx", &combined_tx_.current(), filter);
712 pass.bind_image("out_combined_img", &combined_tx_.next());
713 pass.bind_image("depth_img", &depth_tx_);
714 pass.bind_image("color_accum_img", &color_accum_tx_);
715 pass.bind_image("value_accum_img", &value_accum_tx_);
716 pass.bind_image("cryptomatte_img", &cryptomatte_tx_);
717 pass.bind_image("denoising_depth_img", &denoising_depth_tx_);
718 pass.bind_resources(inst_.uniform_data);
719 pass.bind_resources(inst_.sampling);
720}
721
723{
724 use_reprojection_ = inst_.sampling.interactive_mode() && !inst_.camera.is_panoramic();
725
726 /* Just bypass the reprojection and reset the accumulation. */
727 if (inst_.is_viewport() && !use_reprojection_ && inst_.sampling.is_reset()) {
728 use_reprojection_ = false;
729 data_.use_history = false;
730 }
731
732 aovs_info.push_update();
733
734 sync_mist();
735
736 /* Update sample table length for specialization warm up.
737 * Otherwise, we will warm a specialization that is not actually used.
738 * We still need to update it once per sample afterward. */
740
741 inst_.manager->warm_shader_specialization(accumulate_ps_);
742 inst_.manager->warm_shader_specialization(copy_ps_);
743 inst_.manager->warm_shader_specialization(cryptomatte_post_ps_);
744}
745
747{
748 float2 jitter = inst_.sampling.rng_2d_get(SAMPLING_FILTER_U);
749
750 if (!use_box_filter && data_.filter_radius < M_SQRT1_2 && !inst_.camera.is_panoramic() &&
751 !inst_.sampling.use_custom_pixel_jitter_sample())
752 {
753 /* For filter size less than a pixel, change sampling strategy and use a uniform disk
754 * distribution covering the filter shape. This avoids putting samples in areas without any
755 * weights. */
756 /* TODO(fclem): Importance sampling could be a better option here. */
757 /* NOTE: We bias the disk to encompass most of the energy of the filter to avoid energy issues
758 * with motion blur at low sample. */
759 const float bias = 0.5f;
760 jitter = Sampling::sample_disk(jitter) * bias * data_.filter_radius;
761 }
762 else {
763 /* Jitter the size of a whole pixel. [-0.5..0.5] */
764 jitter -= 0.5f;
765 }
766
767 if (data_.scaling_factor > 1) {
768 /* In this case, the jitter sequence is the same for the number of film pixel a render pixel
769 * covers. This allows to add a manual offset to the different film pixels to ensure they get
770 * appropriate coverage instead of waiting that random sampling covers all the area. This
771 * ensures a much faster convergence. */
772 const int scale = data_.scaling_factor;
773 const int render_pixel_per_final_pixel = square_i(scale);
774 /* TODO(fclem): Random in Z-order curve. */
775 /* Works great for the scaling factor we have. */
776 int prime = (render_pixel_per_final_pixel / 2) - 1;
777 /* For now just randomize in scan-lines using a prime number. */
778 uint64_t index = (inst_.sampling.sample_index() * prime) % render_pixel_per_final_pixel;
779 int2 pixel_co = int2(index % scale, index / scale);
780 /* The jitter is applied on render target pixels. Make it proportional to film pixel. */
781 jitter /= float(scale);
782 /* Offset from the render pixel center to the center of film pixel. */
783 jitter += ((float2(pixel_co) + 0.5f) / scale) - 0.5f;
784 }
785 return jitter;
786}
787
789{
790 if (inst_.is_viewport() && use_reprojection_) {
791 /* Enable motion vector rendering but not the accumulation buffer. */
792 return enabled_passes_ | EEVEE_RENDER_PASS_VECTOR;
793 }
794 return enabled_passes_;
795}
796
798{
799 int result = 0;
800 result += data_.cryptomatte_object_id == -1 ? 0 : 1;
801 result += data_.cryptomatte_asset_id == -1 ? 0 : 1;
802 result += data_.cryptomatte_material_id == -1 ? 0 : 1;
803 return result;
804}
805
807{
808 /* Offset in render target pixels. */
809 data_.subpixel_offset = pixel_jitter_get();
810
811 int filter_radius_ceil = ceilf(data_.filter_radius);
812 float filter_radius_sqr = square_f(data_.filter_radius);
813
814 /* Reset */
815 for (FilmSample &sample : data_.samples) {
816 sample.texel = int2(0, 0);
817 sample.weight = 0.0f;
818 }
819
820 data_.samples_len = 0;
821 if (inst_.camera.is_panoramic()) {
822 /* Samples are jittered and weighted on the GPU (see `panoramic_sample_get`). */
823 data_.samples_len = FILM_PANORAMIC_SAMPLE_LEN;
824 }
825 else if (data_.scaling_factor > 1) {
826 /* For this case there might be no valid samples for some pixels.
827 * Still visit all four neighbors to have the best weight available.
828 * Note that weight is computed on the GPU as it is different for each sample. */
829 /* TODO(fclem): Make it work for filters larger than then scaling_factor. */
830 for (int y = 0; y <= 1; y++) {
831 for (int x = 0; x <= 1; x++) {
832 FilmSample &sample = data_.samples[data_.samples_len];
833 sample.texel = int2(x, y);
834 sample.weight = -1.0f; /* Computed on GPU. */
835 data_.samples_len++;
836 }
837 }
838 data_.samples_weight_total = -1.0f; /* Computed on GPU. */
839 }
840 else if (use_box_filter || data_.filter_radius < 0.01f) {
841 /* Disable gather filtering. */
842 data_.samples[0].texel = int2(0, 0);
843 data_.samples[0].weight = 1.0f;
844 data_.samples_weight_total = 1.0f;
845 data_.samples_len = 1;
846 }
847 /* NOTE: Threshold determined by hand until we don't hit the assert below. */
848 else if (data_.filter_radius < 2.20f) {
849 /* Small filter Size. */
850 int closest_index = 0;
851 float closest_distance = FLT_MAX;
852 data_.samples_weight_total = 0.0f;
853 /* TODO(fclem): For optimization, could try Z-tile ordering. */
854 for (int y = -filter_radius_ceil; y <= filter_radius_ceil; y++) {
855 for (int x = -filter_radius_ceil; x <= filter_radius_ceil; x++) {
856 float2 pixel_offset = float2(x, y) - data_.subpixel_offset;
857 float distance_sqr = math::length_squared(pixel_offset);
858 if (distance_sqr < filter_radius_sqr) {
859 if (data_.samples_len >= FILM_PRECOMP_SAMPLE_MAX) {
860 BLI_assert_msg(0, "Precomputed sample table is too small.");
861 break;
862 }
863 FilmSample &sample = data_.samples[data_.samples_len];
864 sample.texel = int2(x, y);
865 sample.weight = film_filter_weight(data_.filter_radius, distance_sqr);
866 data_.samples_weight_total += sample.weight;
867
868 if (distance_sqr < closest_distance) {
869 closest_distance = distance_sqr;
870 closest_index = data_.samples_len;
871 }
872 data_.samples_len++;
873 }
874 }
875 }
876 /* Put the closest one in first position. */
877 if (closest_index != 0) {
878 std::swap(data_.samples[closest_index], data_.samples[0]);
879 }
880 /* Avoid querying a different shader specialization for this case.
881 * This can happen with the default settings. */
882 if (data_.samples_len <= 9) {
883 data_.samples_len = 9;
884 }
885 }
886 else {
887 /* Large Filter Size. */
888 MutableSpan<FilmSample> sample_table(data_.samples, FILM_PRECOMP_SAMPLE_MAX);
889 /* To avoid hitting driver TDR and slowing rendering too much we use random sampling. */
890 /* TODO(fclem): This case needs more work. We could distribute the samples better to avoid
891 * loading the same pixel twice. */
892 data_.samples_len = sample_table.size();
893 data_.samples_weight_total = 0.0f;
894
895 int i = 0;
896 for (FilmSample &sample : sample_table) {
897 /* TODO(fclem): Own RNG. */
898 float2 random_2d = inst_.sampling.rng_2d_get(SAMPLING_SSS_U);
899 /* This randomization makes sure we converge to the right result but also makes nearest
900 * neighbor filtering not converging rapidly. */
901 random_2d.x = (random_2d.x + i) / float(FILM_PRECOMP_SAMPLE_MAX);
902
903 float2 pixel_offset = math::floor(Sampling::sample_spiral(random_2d) * data_.filter_radius);
904 sample.texel = int2(pixel_offset);
905
906 float distance_sqr = math::length_squared(pixel_offset - data_.subpixel_offset);
907 sample.weight = film_filter_weight(data_.filter_radius, distance_sqr);
908 data_.samples_weight_total += sample.weight;
909 i++;
910 }
911 }
912
913 /* Round to specific amount of sample to avoid variation in sample count to cause stutter on
914 * startup because of shader specialization. */
915 if (data_.samples_len == 1) {
916 data_.samples_len = 1;
917 }
918 else if (data_.samples_len <= 4) {
919 data_.samples_len = 4;
920 }
921 else if (data_.samples_len <= 9) {
922 data_.samples_len = 9;
923 }
924 else if (data_.samples_len <= 16) {
925 data_.samples_len = 16;
926 }
927 else {
929 }
930}
931
932void Film::accumulate(View &view, gpu::Texture *combined_final_tx)
933{
934 if (inst_.is_viewport()) {
935 DefaultFramebufferList *dfbl = inst_.draw_ctx->viewport_framebuffer_list_get();
936 DefaultTextureList *dtxl = inst_.draw_ctx->viewport_texture_list_get();
938 /* Clear when using render borders. */
939 if (data_.extent != int2(GPU_texture_width(dtxl->color), GPU_texture_height(dtxl->color))) {
941 }
942 GPU_framebuffer_viewport_set(dfbl->default_fb, UNPACK2(data_.offset), UNPACK2(data_.extent));
943 }
944
945 combined_final_tx_ = combined_final_tx;
946
947 display_only_ = false;
948 inst_.manager->submit(accumulate_ps_, view);
949
950 combined_tx_.swap();
951 weight_tx_.swap();
952
953 /* copy_ps_ reads in_combined_tx so it must run after the swap. */
954 inst_.manager->submit(copy_ps_, view);
955
956 /* Use history after first sample. */
957 if (data_.use_history == 0) {
958 data_.use_history = 1;
959 }
960}
961
963{
964 BLI_assert(inst_.is_viewport());
965
966 /* Acquire dummy render buffers for correct binding. They will not be used. */
967 inst_.render_buffers.acquire(int2(1));
968
969 DefaultFramebufferList *dfbl = inst_.draw_ctx->viewport_framebuffer_list_get();
971 GPU_framebuffer_viewport_set(dfbl->default_fb, UNPACK2(data_.offset), UNPACK2(data_.extent));
972
973 combined_final_tx_ = inst_.render_buffers.combined_tx;
974
976
977 display_only_ = true;
978 DRW_manager_get()->submit(use_compute_ ? copy_ps_ : accumulate_ps_, drw_view);
979
980 inst_.render_buffers.release();
981
982 /* IMPORTANT: Do not swap! No accumulation has happened. */
983}
984
986{
987 DRW_manager_get()->submit(cryptomatte_post_ps_);
988}
989
990float *Film::read_pass(eViewLayerEEVEEPassType pass_type, int layer_offset)
991{
992 gpu::Texture *pass_tx = this->get_pass_texture(pass_type, layer_offset);
993
995
996 float *result = static_cast<float *>(GPU_texture_read(pass_tx, GPU_DATA_FLOAT, 0));
997
998 if (pass_is_float3(pass_type)) {
999 /* Convert result in place as we cannot do this conversion on GPU. */
1000 for (const int px : IndexRange(GPU_texture_width(pass_tx) * GPU_texture_height(pass_tx))) {
1001 float3 tmp = *(reinterpret_cast<float3 *>(result + px * 4));
1002 *(reinterpret_cast<float3 *>(result) + px) = tmp;
1003 }
1004 }
1005
1006 return result;
1007}
1008
1010{
1011 ePassStorageType storage_type = pass_storage_type(pass_type);
1012 const bool is_value = storage_type == PASS_STORAGE_VALUE;
1013 const bool is_cryptomatte = storage_type == PASS_STORAGE_CRYPTOMATTE;
1014
1015 Texture &accum_tx = (pass_type == EEVEE_RENDER_PASS_COMBINED) ?
1016 combined_tx_.current() :
1017 (pass_type == EEVEE_RENDER_PASS_DEPTH) ?
1018 depth_tx_ :
1019 (pass_type == EEVEE_RENDER_PASS_DENOISING_DEPTH) ?
1020 denoising_depth_tx_ :
1021 (is_cryptomatte ? cryptomatte_tx_ :
1022 (is_value ? value_accum_tx_ : color_accum_tx_));
1023
1024 int index = pass_id_get(pass_type);
1025 if (index == -1) {
1026 return nullptr;
1027 }
1028
1029 accum_tx.ensure_layer_views();
1030 return accum_tx.layer_view(index + layer_offset);
1031}
1032
1033/* Gets the appropriate shader to write the given pass type. This is because passes of different
1034 * types are stored in different textures types and formats. */
1036{
1037 switch (pass_type) {
1042 default:
1043 break;
1044 }
1045
1046 switch (Film::pass_storage_type(pass_type)) {
1047 case PASS_STORAGE_VALUE:
1050 case PASS_STORAGE_COLOR:
1054 }
1055
1057}
1058
1059/* Gets the appropriate shader to write the given AOV pass. */
1061{
1062 switch (aov->type) {
1063 case AOV_TYPE_VALUE:
1065 case AOV_TYPE_COLOR:
1067 }
1068
1070}
1071
1073{
1074 this->cryptomatte_sort();
1075
1076 /* Write standard passes. */
1077 for (const int i : IndexRange(EEVEE_RENDER_PASS_MAX_BIT + 1)) {
1079 viewport_compositor_enabled_passes_ & (1 << i));
1080 if (pass_type == 0) {
1081 continue;
1082 }
1083
1084 Vector<std::string> pass_names = Film::pass_to_render_pass_names(pass_type, inst_.view_layer);
1085 for (const int64_t pass_offset : IndexRange(pass_names.size())) {
1086 gpu::Texture *pass_texture = this->get_pass_texture(pass_type, pass_offset);
1087 if (!pass_texture) {
1088 continue;
1089 }
1090
1091 /* Allocate passes that spans the entire display extent, even when border rendering, then
1092 * copy the border region while zeroing the rest. That's because the compositor doesn't have
1093 * a distinction between display and data windows at the moment, so it expects passes to have
1094 * the extent of the viewport. Furthermore, we still do not support passes from Cycles and
1095 * external engines, so the viewport size assumption holds at the compositor side to support
1096 * all cases for now. */
1097 const char *pass_name = pass_names[pass_offset].c_str();
1098 draw::TextureFromPool &output_pass_texture = DRW_viewport_pass_texture_get(pass_name);
1099 output_pass_texture.acquire_2d(this->display_extent, GPU_texture_format(pass_texture));
1100
1101 PassSimple write_pass_ps = {"Film.WriteViewportCompositorPass"};
1102 const eShaderType write_shader_type = get_write_pass_shader_type(pass_type);
1103 write_pass_ps.shader_set(inst_.shaders.static_shader_get(write_shader_type));
1104 write_pass_ps.push_constant("offset", data_.offset);
1105 write_pass_ps.bind_texture("input_tx", pass_texture);
1106 write_pass_ps.bind_image("output_img", output_pass_texture);
1107 write_pass_ps.barrier(GPU_BARRIER_TEXTURE_FETCH);
1108 write_pass_ps.dispatch(math::divide_ceil(this->display_extent, int2(FILM_GROUP_SIZE)));
1109 inst_.manager->submit(write_pass_ps);
1110 }
1111 }
1112
1113 /* Write AOV passes. */
1114 for (ViewLayerAOV &aov : inst_.view_layer->aovs) {
1115 if ((aov.flag & AOV_CONFLICT) != 0) {
1116 continue;
1117 }
1118 gpu::Texture *pass_texture = this->get_aov_texture(&aov);
1119 if (!pass_texture) {
1120 continue;
1121 }
1122
1123 /* See above comment regarding the allocation extent. */
1124 draw::TextureFromPool &output_pass_texture = DRW_viewport_pass_texture_get(aov.name);
1125 output_pass_texture.acquire_2d(this->display_extent, GPU_texture_format(pass_texture));
1126
1127 PassSimple write_pass_ps = {"Film.WriteViewportCompositorPass"};
1128 const eShaderType write_shader_type = get_aov_write_pass_shader_type(&aov);
1129 write_pass_ps.shader_set(inst_.shaders.static_shader_get(write_shader_type));
1130 write_pass_ps.push_constant("offset", data_.offset);
1131 write_pass_ps.bind_texture("input_tx", pass_texture);
1132 write_pass_ps.bind_image("output_img", output_pass_texture);
1133 write_pass_ps.barrier(GPU_BARRIER_TEXTURE_FETCH);
1134 write_pass_ps.dispatch(math::divide_ceil(this->display_extent, int2(FILM_GROUP_SIZE)));
1135 inst_.manager->submit(write_pass_ps);
1136 }
1137}
1138
1140
1141} // namespace blender::eevee
#define M_SQRT1_2
#define EEVEE_RENDER_PASS_MAX_BIT
#define UNPACK2(a)
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
#define BLI_assert_msg(a, msg)
void reset()
constexpr IndexRange()=default
constexpr int64_t size() const
Definition BLI_span.hh:499
bool contains(const Key &key) const
Definition BLI_set.hh:310
int64_t size() const
void submit(PassSimple &pass, View &view)
bool acquire_2d(int2 extent, gpu::TextureFormat format, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, int mip_len=1)
bool ensure_layer_views(bool cube_as_array=false)
gpu::Texture * layer_view(int layer)
static View & default_get()
Definition draw_view.cc:317
void bind_resources(U &resources)
Definition draw_pass.hh:459
void shader_set(gpu::Shader *shader)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
void specialize_constant(gpu::Shader *shader, const char *name, const float &data)
void bind_image(const char *name, gpu::Texture *image)
void dispatch(int group_len)
void state_set(DRWState state, int clip_plane_count=0)
void barrier(GPUBarrier type)
void bind_ubo(const char *name, gpu::UniformBuf *buffer)
void push_constant(const char *name, const float &data)
const CameraData & data_get() const
float2 pixel_jitter_get() const
int pass_id_get(eViewLayerEEVEEPassType pass_type) const
static bool pass_is_float3(eViewLayerEEVEEPassType pass_type)
gpu::Texture * get_pass_texture(eViewLayerEEVEEPassType pass_type, int layer_offset)
struct blender::eevee::Film::DepthState depth
static const Vector< std::string > pass_to_render_pass_names(eViewLayerEEVEEPassType pass_type, const ViewLayer *view_layer)
int cryptomatte_layer_len_get() const
static ePassStorageType pass_storage_type(eViewLayerEEVEEPassType pass_type)
float * read_pass(eViewLayerEEVEEPassType pass_type, int layer_offset)
void write_viewport_compositor_passes()
static int overscan_pixels_get(float overscan, int2 extent)
void accumulate(View &view, gpu::Texture *combined_final_tx)
void init(const int2 &full_extent, const rcti *output_rect)
float * read_aov(ViewLayerAOV *aov)
StorageBuffer< AOVsInfoData > aovs_info
Definition eevee_film.hh:59
eViewLayerEEVEEPassType enabled_passes_get() const
static constexpr bool use_box_filter
Definition eevee_film.hh:61
gpu::Texture * get_aov_texture(ViewLayerAOV *aov)
UniformDataModule uniform_data
static float2 sample_disk(const float2 &rand)
uint64_t sample_count() const
static float2 sample_spiral(const float2 &rand)
virtual void init(const shader::ShaderCreateInfo &info, bool is_codegen_only)=0
#define offsetof(t, d)
#define FILM_GROUP_SIZE
#define ENABLE_FROM_LEGACY(name_legacy, name_eevee)
#define FLT_MAX
#define index(i)
int divide_ceil(int a, int b)
float3x3 scale(float3x3 mat, float2 scale)
Set< std::string > get_used_passes(const Scene &scene, const ViewLayer *view_layer, ExecutionMode mode)
detail::Pass< command::DrawCommandBuf > PassSimple
@ FILM_PASS_CONVERT_CRYPTOMATTE
static eShaderType get_write_pass_shader_type(eViewLayerEEVEEPassType pass_type)
bool operator!=(const CameraData &a, const CameraData &b)
static eViewLayerEEVEEPassType with_light_pass_color_dependencies(eViewLayerEEVEEPassType passes)
static eShaderType get_aov_write_pass_shader_type(const ViewLayerAOV *aov)
static eViewLayerEEVEEPassType enabled_passes(const ViewLayer *view_layer)
bool operator==(const CameraData &a, const CameraData &b)
static eViewLayerEEVEEPassType get_viewport_compositor_enabled_passes(const Set< std::string > &viewport_compositor_needed_passes, const ViewLayer *view_layer)
T length_squared(const VecBase< T, Size > &a)
T floor(const T &a)
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T max(const T &a, const T &b)
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int BKE_render_preview_pixel_size(const RenderData *r)
Definition scene.cc:3183
unsigned __int64 uint64_t
Definition BKE_text.h:91
__int64 int64_t
Definition BKE_text.h:90
bool GPU_type_matches_ex(GPUDeviceType device, GPUOSType os, GPUDriverType driver, GPUBackendType backend)
gpu::TextureFormat GPU_texture_format(const gpu::Texture *texture)
draw::TextureFromPool & DRW_viewport_pass_texture_get(const char *pass_name)
unsigned int uint
Definition BKE_text.h:55
bool assign_if_different(T &old_value, T &&new_value)
void GPU_framebuffer_viewport_set(gpu::FrameBuffer *fb, int x, int y, int width, int height)
MINLINE int square_i(int a)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
void GPU_framebuffer_clear_color(gpu::FrameBuffer *fb, const double4 clear_col)
@ GPU_SAMPLER_FILTERING_LINEAR
MINLINE int max_ii(int a, int b)
int GPU_max_texture_size()
MINLINE float pow2f(float x)
VecBase< float, 4 > float4
bool GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
@ WO_MIST_INVERSE_QUADRATIC
void GPU_memory_barrier(GPUBarrier barrier)
Definition gpu_state.cc:305
int GPU_texture_width(const gpu::Texture *texture)
@ GPU_BARRIER_TEXTURE_FETCH
Definition GPU_state.hh:40
@ GPU_BARRIER_TEXTURE_UPDATE
Definition GPU_state.hh:42
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
Definition GPU_state.hh:38
@ DRW_STATE_NO_DRAW
Definition draw_state.hh:29
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:32
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:31
@ DRW_STATE_DEPTH_ALWAYS
Definition draw_state.hh:38
@ DRW_STATE_DEPTH_GREATER_EQUAL
Definition draw_state.hh:43
bool BLI_rcti_is_empty(const struct rcti *rect)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:428
BLI_INLINE unsigned int BLI_hash_string(const char *str)
Definition BLI_hash_c.hh:69
@ EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET
@ EEVEE_RENDER_PASS_MIST
@ EEVEE_RENDER_PASS_SPECULAR_LIGHT
@ EEVEE_RENDER_PASS_DIFFUSE_COLOR
@ EEVEE_RENDER_PASS_DENOISING_NORMAL
@ EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL
@ EEVEE_RENDER_PASS_ENVIRONMENT
@ EEVEE_RENDER_PASS_VECTOR
@ EEVEE_RENDER_PASS_EMIT
@ EEVEE_RENDER_PASS_AOV
@ EEVEE_RENDER_PASS_AO
@ EEVEE_RENDER_PASS_DENOISING_ROUGHNESS
@ EEVEE_RENDER_PASS_DENOISING_DIFFUSE_ALBEDO
@ EEVEE_RENDER_PASS_DEPTH
@ EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT
@ EEVEE_RENDER_PASS_COMBINED
@ EEVEE_RENDER_PASS_VOLUME_LIGHT
@ EEVEE_RENDER_PASS_DENOISING_SPECULAR_ALBEDO
@ EEVEE_RENDER_PASS_TRANSPARENT
@ EEVEE_RENDER_PASS_NORMAL
@ EEVEE_RENDER_PASS_UNUSED_8
@ EEVEE_RENDER_PASS_POSITION
@ EEVEE_RENDER_PASS_DIFFUSE_LIGHT
@ EEVEE_RENDER_PASS_SPECULAR_COLOR
@ EEVEE_RENDER_PASS_SHADOW
@ EEVEE_RENDER_PASS_UNUSED_14
@ EEVEE_RENDER_PASS_DENOISING_DEPTH
int GPU_texture_height(const gpu::Texture *texture)
@ VIEW_LAYER_CRYPTOMATTE_ASSET
@ VIEW_LAYER_CRYPTOMATTE_MATERIAL
@ VIEW_LAYER_CRYPTOMATTE_OBJECT
MINLINE uint divide_ceil_u(uint a, uint b)
draw::Manager * DRW_manager_get()
MINLINE float square_f(float a)
@ EEVEE_DENOISING_PASS_STORE
void * GPU_texture_read(gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
VecBase< float, 3 > float3
@ GPU_DEVICE_QUALCOMM
@ GPU_DEVICE_INTEL
VecBase< double, 4 > double4
MINLINE float clamp_f(float value, float min, float max)
#define hash
Definition noise_c.cc:156
#define fabsf
#define sqrtf
#define ceilf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct World * world
ColorManagedViewSettings view_settings
struct RenderData r
eViewLayerAOVFlag flag
eViewLayerAOVType type
eViewLayerEEVEEPassType render_passes
struct ViewLayerEEVEE eevee
eViewLayerCryptomatteFlags cryptomatte_flag