Blender V5.3
scene/image.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "device/device.h"
6#include "device/queue.h"
7
8#include "scene/devicescene.h"
9#include "scene/image.h"
10#include "scene/image_loader.h"
11#include "scene/image_oiio.h"
12#include "scene/image_vdb.h"
13#include "scene/scene.h"
14#include "scene/stats.h"
15
16#include "util/colorspace.h"
17#include "util/debug.h"
18#include "util/log.h"
19#include "util/progress.h"
20#include "util/task.h"
21#include "util/types_image.h"
22
24
25/* Image Handle */
26
27ImageHandle::ImageHandle() = default;
28
36
39{
40 if (image_texture) {
42 }
43}
44
46 : image_texture(other.image_texture), manager(other.manager)
47{
48 other.image_texture = nullptr;
49 other.manager = nullptr;
50}
51
53{
54 clear();
56 manager = other.manager;
57
58 if (image_texture) {
60 }
61
62 return *this;
63}
64
66{
67 if (this != &other) {
68 clear();
69 image_texture = other.image_texture;
70 manager = other.manager;
71 other.image_texture = nullptr;
72 other.manager = nullptr;
73 }
74 return *this;
75}
76
81
83{
84 /* Don't remove immediately, rather do it all together later on. one of
85 * the reasons for this is that on shader changes we add and remove nodes
86 * that use them, but we do not want to reload the image all the time. */
87 if (image_texture) {
90 if (image_texture->users == 0) {
92 }
93 image_texture = nullptr;
94 }
95
96 manager = nullptr;
97}
98
100{
101 return image_texture == nullptr;
102}
103
105{
107 ImageUDIM *udim = static_cast<ImageUDIM *>(image_texture);
108 return udim->tiles.size();
109 }
110
111 return 0;
112}
113
115{
116 if (image_texture) {
118 ImageSingle *img = static_cast<ImageSingle *>(image_texture);
119 manager->load_image_metadata(img, progress);
120 return img->metadata;
121 }
123 ImageUDIM *udim = static_cast<ImageUDIM *>(image_texture);
124 return udim->tiles[0].second.metadata(progress);
125 }
126 }
127
128 return ImageMetaData();
129}
130
132{
134 ImageUDIM *udim = static_cast<ImageUDIM *>(image_texture);
135 for (auto &tile : udim->tiles) {
136 if (!tile.second.metadata(progress).has_tiles_and_mipmaps) {
137 return false;
138 }
139 }
140 return true;
141 }
142 return metadata(progress).has_tiles_and_mipmaps;
143}
144
146{
147 if (!image_texture) {
148 return KERNEL_IMAGE_NONE;
149 }
151 return static_cast<const ImageSingle *>(image_texture)->image_texture_id;
152 }
153 return static_cast<const ImageUDIM *>(image_texture)->id;
154}
155
157{
159 return nullptr;
160 }
161
162 ImageSingle *img = static_cast<ImageSingle *>(image_texture);
163 return img->vdb_memory;
164}
165
167{
169 return nullptr;
170 }
171
172 ImageSingle *img = static_cast<ImageSingle *>(image_texture);
173 ImageLoader *loader = img->loader.get();
174 if (loader == nullptr) {
175 return nullptr;
176 }
177
178 if (loader->is_vdb_loader()) {
179 return dynamic_cast<VDBImageLoader *>(loader);
180 }
181
182 return nullptr;
183}
184
186{
187 return manager;
188}
189
190bool ImageHandle::operator==(const ImageHandle &other) const
191{
192 return image_texture == other.image_texture && manager == other.manager;
193}
194
195void ImageHandle::add_to_set(set<const ImageSingle *> &images) const
196{
197 if (empty()) {
198 return;
199 }
200
202 images.insert(static_cast<const ImageSingle *>(image_texture));
203 }
204 else {
205 for (const auto &tile : static_cast<const ImageUDIM *>(image_texture)->tiles) {
206 images.insert(static_cast<const ImageSingle *>(tile.second.image_texture));
207 }
208 }
209}
210
211/* Image Single */
212
213ImageSingle::~ImageSingle() = default;
214
215/* Image Manager */
216
217ImageManager::ImageManager(const DeviceInfo & /*info*/, const SceneParams &params)
218{
219 use_texture_cache = params.use_texture_cache;
220 auto_texture_cache = params.auto_texture_cache;
221 texture_cache_path = params.texture_cache_path;
222}
223
225{
226 for (ImageSingle *img : images) {
227 assert(!img);
228 (void)img;
229 }
230}
231
233{
234 if (frame != animation_frame) {
235 const thread_scoped_lock device_lock(images_mutex);
236 animation_frame = frame;
237
238 for (ImageSingle *img : images) {
239 if (img && img->params.animated) {
240 return true;
241 }
242 }
243 }
244
245 return false;
246}
247
248void ImageManager::load_image_metadata(ImageSingle *img, Progress &progress)
249{
250 if (!img->need_metadata) {
251 return;
252 }
253
254 const thread_scoped_lock image_lock(img->mutex);
255 if (!img->need_metadata) {
256 return;
257 }
258
259 /* Isolate threading since we are holding a mutex lock and metadata loading
260 * may involve multi-threading from e.g. the texture cache generation or host
261 * application processing. */
262 isolate_task([&]() {
263 /* Change image to use tx file if supported. */
264 const ImageLoaderParams params = {.use_texture_cache = use_texture_cache,
265 .auto_texture_cache = auto_texture_cache,
266 .texture_cache_path = texture_cache_path,
267 .colorspace = img->params.colorspace,
268 .alpha_type = img->params.alpha_type,
269 .load_failure_num = load_failure_num,
270 .tx_failure_num = tx_failure_num};
271
272 ImageMetaData &metadata = img->metadata;
273 metadata = ImageMetaData();
274 metadata.colorspace = img->params.colorspace;
275
276 if (img->loader->load_metadata(metadata, params, progress)) {
277 assert(metadata.type != IMAGE_DATA_NUM_TYPES);
278 }
279 else {
280 metadata.type = IMAGE_DATA_TYPE_BYTE4;
281 }
282
283 metadata.finalize(img->params.alpha_type);
284
285 img->need_metadata = false;
286 });
287}
288
289ImageHandle ImageManager::add_image(const string &filename, const ImageParams &params)
290{
291 ImageSingle *image = add_image_texture(make_unique<OIIOImageLoader>(filename), params, false);
292 return ImageHandle(image, this);
293}
294
296 const ImageParams &params,
297 const array<int> &tiles)
298{
299 if (tiles.empty()) {
300 return add_image(filename, params);
301 }
302
304 for (const int tile : tiles) {
305 string tile_filename = filename;
306
307 /* Since we don't have information about the exact tile format used in this code location,
308 * just attempt all replacement patterns that Blender supports. */
309 string_replace(tile_filename, "<UDIM>", string_printf("%04d", tile));
310
311 const int u = ((tile - 1001) % 10);
312 const int v = ((tile - 1001) / 10);
313 string_replace(tile_filename, "<UVTILE>", string_printf("u%d_v%d", u + 1, v + 1));
314
315 ImageSingle *image = add_image_texture(
316 make_unique<OIIOImageLoader>(tile_filename), params, false);
317 udim_tiles.emplace_back(tile, ImageHandle(image, this));
318 }
319
320 ImageUDIM *udim = add_image_texture(std::move(udim_tiles));
321 return ImageHandle(udim, this);
322}
323
325 const ImageParams &params,
326 const bool builtin)
327{
328 ImageSingle *image = add_image_texture(std::move(loader), params, builtin);
329 return ImageHandle(image, this);
330}
331
333 const ImageParams &params)
334{
336
337 for (unique_ptr<ImageLoader> &loader : loaders) {
338 unique_ptr<ImageLoader> local_loader;
339 std::swap(loader, local_loader);
340 ImageSingle *image = add_image_texture(std::move(local_loader), params, true);
341 udim_tiles.emplace_back(image->loader->get_tile_number(), ImageHandle(image, this));
342 }
343
344 ImageUDIM *udim = add_image_texture(std::move(udim_tiles));
345 return ImageHandle(udim, this);
346}
347
348/* ImageManager */
349
350ImageSingle *ImageManager::add_image_texture(unique_ptr<ImageLoader> &&loader,
351 const ImageParams &params,
352 const bool builtin)
353{
354 const thread_scoped_lock device_lock(images_mutex);
355
356 /* Find existing image. */
357 size_t image_texture_id;
358 for (image_texture_id = 0; image_texture_id < images.size(); image_texture_id++) {
359 ImageSingle *img = images[image_texture_id];
360 if (img && ImageLoader::equals(img->loader.get(), loader.get()) && img->params == params) {
361 return img;
362 }
363 }
364
365 /* Find free image_texture_id. */
366 for (image_texture_id = 0; image_texture_id < images.size(); image_texture_id++) {
367 if (!images[image_texture_id]) {
368 break;
369 }
370 }
371
372 if (image_texture_id == images.size()) {
373 images.resize(images.size() + 1);
374 }
375
376 /* Add new image. */
377 unique_ptr<ImageSingle> img = make_unique<ImageSingle>();
378 img->type = ImageTexture::SINGLE;
379 img->image_texture_id = image_texture_id;
380 img->params = params;
381 img->loader = std::move(loader);
382 img->builtin = builtin;
383
384 images.replace(image_texture_id, std::move(img));
385
386 tag_update();
387
388 return images[image_texture_id];
389}
390
391ImageUDIM *ImageManager::add_image_texture(vector<std::pair<int, ImageHandle>> &&tiles)
392{
393 const thread_scoped_lock device_lock(images_mutex);
394
395 /* Find existing UDIM. */
396 size_t image_texture_id;
397 for (image_texture_id = 0; image_texture_id < image_udims.size(); image_texture_id++) {
398 ImageUDIM *udim = image_udims[image_texture_id];
399 if (udim && udim->tiles == tiles) {
400 return udim;
401 }
402 }
403
404 /* Find free image_texture_id. */
405 for (image_texture_id = 0; image_texture_id < image_udims.size(); image_texture_id++) {
406 if (!image_udims[image_texture_id]) {
407 break;
408 }
409 }
410
411 if (image_texture_id == image_udims.size()) {
412 image_udims.resize(image_udims.size() + 1);
413 }
414
415 /* Add new image. */
416 unique_ptr<ImageUDIM> img = make_unique<ImageUDIM>();
417 img->type = ImageTexture::UDIM;
418 img->id = -num_udim_tiles - 1;
419 img->tiles = std::move(tiles);
420
421 num_udim_tiles += img->tiles.size() + 1;
422
423 image_udims.replace(image_texture_id, std::move(img));
424
425 tag_update();
426
427 return image_udims[image_texture_id];
428}
429
430void ImageManager::device_resize_image_textures(Scene *scene)
431{
432 const thread_scoped_lock device_lock(device_mutex);
433 DeviceScene &dscene = scene->dscene;
434
435 if (dscene.image_textures.size() < images.size()) {
436 dscene.image_textures.resize(images.size());
437 }
438}
439
440void ImageManager::device_copy_image_textures(Device *device, Scene *scene)
441{
442 image_cache.copy_to_device(scene->dscene);
443
444 const thread_scoped_lock device_lock(device_mutex);
445 DeviceScene &dscene = scene->dscene;
446
449
452
453 device->set_image_cache_func(
454 [this, device, scene](size_t image_texture_id,
455 int miplevel,
456 int x,
457 int y,
458 KernelTileDescriptor &tile_descriptor) {
459 this->device_cpu_load_requested(
460 device, scene, image_texture_id, miplevel, x, y, tile_descriptor);
461 },
462 [this, device, scene](DeviceQueue &queue) {
463 this->device_gpu_load_requested(device, queue, scene);
464 });
465}
466
467void ImageManager::device_load_image(Device *device,
468 Scene *scene,
469 const size_t image_texture_id,
470 Progress &progress)
471{
472 if (progress.get_cancel()) {
473 return;
474 }
475
476 ImageSingle *img = images[image_texture_id];
477
478 progress.set_status("Updating Images", "Loading " + img->loader->name());
479
480 load_image_metadata(img, progress);
481
482 KernelImageTexture tex;
483 tex.width = img->metadata.width;
484 tex.height = img->metadata.height;
486 tex.extension = img->params.extension;
490
491 int max_dim = std::max(img->metadata.width, img->metadata.height);
492
493 if (use_texture_cache && img->metadata.has_tiles_and_mipmaps && img->metadata.tile_size) {
494 /* Apply texture size limit by skipping the highest mip levels. */
495 const int texture_limit = scene->params.texture_limit;
496 img->miplevel_offset = 0;
497 while (texture_limit > 0 && max_dim > texture_limit) {
498 img->miplevel_offset++;
499 tex.width = std::max(1, tex.width / 2);
500 tex.height = std::max(1, tex.height / 2);
501 max_dim /= 2;
502 }
503 image_cache.load_image_tiled(img->metadata, tex);
504 }
505 else {
506 /* Compute texture resolution scale factor from texture size limit. */
507 float texture_resolution = scene->params.texture_resolution;
508 const int texture_limit = scene->params.texture_limit;
509 if (texture_limit > 0 && max_dim > texture_limit) {
510 texture_resolution = std::min(texture_resolution, float(texture_limit) / float(max_dim));
511 }
512 img->vdb_memory = image_cache.load_image_full(
513 *device, *img->loader, img->metadata, texture_resolution, tex);
514 }
515
516 /* Update image texture device data. */
517 scene->dscene.image_textures[image_texture_id] = tex;
519
520 /* Cleanup memory in image loader. */
521 img->loader->cleanup();
522 img->need_load = false;
523}
524
525void ImageManager::device_load_tiled_descriptors(Scene *scene)
526{
527 DeviceScene &dscene = scene->dscene;
528 image_cache.load_image_tiled_descriptors(
529 dscene, {dscene.image_textures.data(), dscene.image_textures.size()});
530}
531
532void ImageManager::device_free_image(Scene *scene, size_t image_texture_id)
533{
534 ImageSingle *img = images[image_texture_id];
535 if (img == nullptr) {
536 return;
537 }
538
539 if (!img->need_load) {
540 const KernelImageTexture &tex = scene->dscene.image_textures[image_texture_id];
541 image_cache.free_image(scene->dscene, tex);
542 }
543
544 images.steal(image_texture_id);
545}
546
547void ImageManager::device_cpu_load_requested(Device *device,
548 Scene *scene,
549 size_t image_texture_id,
550 int miplevel,
551 int x,
552 int y,
553 KernelTileDescriptor &tile_descriptor)
554{
555 /* Load the tile. */
556 const ImageSingle *img = images[image_texture_id];
557 const KernelImageTexture &tex = scene->dscene.image_textures[image_texture_id];
558 image_cache.load_requested_tile(*device,
559 scene->dscene,
560 tex,
561 tile_descriptor,
562 miplevel,
563 x,
564 y,
565 *img->loader,
566 img->metadata,
567 img->miplevel_offset);
568}
569
570void ImageManager::device_gpu_load_requested(Device *device, DeviceQueue &queue, Scene *scene)
571{
572 DeviceScene &dscene = scene->dscene;
573
574 /* Copy tile access state from the device, using either the storage or just a pointer to
575 * existing allocation for unified memory. */
576 vector<uint8_t> local_storage;
577 const uint8_t *access_state = reinterpret_cast<const uint8_t *>(
579
580 /* Load tiles requested by this device in parallel. */
581 parallel_for(blocked_range<size_t>(0, images.size(), 1), [&](const blocked_range<size_t> &r) {
582 for (size_t i = r.begin(); i != r.end(); i++) {
583 if (images[i] && dscene.image_textures[i].tile_descriptor_offset != KERNEL_TILE_LOAD_NONE) {
584 ImageSingle *img = images[i];
585 image_cache.load_requested_tiles(*device,
586 dscene,
587 dscene.image_textures[i],
588 *img->loader,
589 img->metadata,
590 img->miplevel_offset,
591 access_state);
592 }
593 }
594 });
595
596 /* Copy data to just this GPU device, using the queue so it happens before kernel execution
597 * without the need for another synchronize call. */
598 image_cache.copy_to_device(dscene, queue);
599}
600
601void ImageManager::device_update_udims(Device * /*device*/, Scene *scene)
602{
603 const thread_scoped_lock device_lock(device_mutex);
604 device_vector<KernelImageUDIM> &device_udims = scene->dscene.image_texture_udims;
605 if (device_udims.size() == num_udim_tiles) {
606 return;
607 }
608
609 device_udims.resize(num_udim_tiles);
610
611 for (auto [udim_id, udim] : image_udims.enumerate()) {
612 if (udim == nullptr) {
613 continue;
614 }
615
616 if (udim->users == 0) {
617 image_udims.replace(udim_id, nullptr);
618 }
619 else if (udim->need_load) {
620 const uint udim_offset = -udim->id - 1;
621 KernelImageUDIM *udim_data = device_udims.data() + udim_offset;
622
623 udim_data[0] = KernelImageUDIM{.tile = int(udim->tiles.size()), .image_texture_id = 0};
624 for (int i = 0; i < udim->tiles.size(); i++) {
625 const auto &tile = udim->tiles[i];
626 udim_data[i + 1] = KernelImageUDIM{.tile = tile.first,
627 .image_texture_id = tile.second.kernel_id()};
628 }
629 udim->need_load = false;
630 }
631 }
632}
633
634void ImageManager::device_update(Device *device, Scene *scene, Progress &progress)
635{
636 if (!need_update()) {
637 return;
638 }
639
640 const scoped_callback_timer timer([scene](double time) {
641 if (scene->update_stats) {
642 scene->update_stats->image.times.add_entry({"device_update", time});
643 }
644 });
645
646 /* Set mip bias for tiled images based on texture resolution. */
647 KernelImage *kimage = &scene->dscene.data.image;
648 kimage->mip_bias = (scene->params.texture_resolution < 1.0f) ?
649 -log2f(scene->params.texture_resolution) :
650 0.0f;
651
652 /* Update UDIM ids. */
653 device_update_udims(device, scene);
654
655 /* Resize devices arrays to match. */
656 device_resize_image_textures(scene);
657
658 /* Free and load images. */
659 TaskPool pool;
660 for (auto [image_texture_id, img] : images.enumerate()) {
661 if (img && img->users == 0) {
662 device_free_image(scene, image_texture_id);
663 }
664 else if (img && img->need_load) {
665 pool.push([this, device, scene, image_texture_id, &progress] {
666 device_load_image(device, scene, image_texture_id, progress);
667 });
668 }
669 }
670
671 pool.wait_work();
672 device_load_tiled_descriptors(scene);
673 report_failures();
674
675 /* Copy device arrays. */
676 device_copy_image_textures(device, scene);
677
678 need_update_ = false;
679}
680
682 Scene *scene,
683 Progress &progress,
684 const set<const ImageSingle *> &images)
685{
686 /* Set mip bias for tiled images based on texture resolution. */
687 KernelImage *kimage = &scene->dscene.data.image;
688 kimage->mip_bias = (scene->params.texture_resolution < 1.0f) ?
689 -log2f(scene->params.texture_resolution) :
690 0.0f;
691
692 /* Update UDIM ids. */
693 device_update_udims(device, scene);
694
695 /* Resize devices arrays to match number of images. */
696 device_resize_image_textures(scene);
697
698 /* Load handles. */
699 TaskPool pool;
700 for (const ImageSingle *img : images) {
701 pool.push([this, device, scene, img, &progress] {
702 assert(img != nullptr);
703 if (img->users == 0) {
704 device_free_image(scene, img->image_texture_id);
705 }
706 else if (img->need_load) {
707 device_load_image(device, scene, img->image_texture_id, progress);
708 }
709 });
710 }
711 pool.wait_work();
712 device_load_tiled_descriptors(scene);
713 report_failures();
714
715 /* Copy device arrays. */
716 device_copy_image_textures(device, scene);
717}
718
720{
721 /* Load only builtin images, Blender needs this to load evaluated
722 * scene data from depsgraph before it is freed. */
723 if (!need_update()) {
724 return;
725 }
726
727 device_resize_image_textures(scene);
728
729 TaskPool pool;
730 for (auto [image_texture_id, img] : images.enumerate()) {
731 if (img && img->need_load && img->builtin) {
732 pool.push([this, device, scene, image_texture_id, &progress] {
733 device_load_image(device, scene, image_texture_id, progress);
734 });
735 }
736 }
737
738 pool.wait_work();
739 device_load_tiled_descriptors(scene);
740 report_failures();
741}
742
744{
745 image_udims.clear();
746 for (auto [image_texture_id, img] : images.enumerate()) {
747 if (img && img->builtin) {
748 device_free_image(scene, image_texture_id);
749 }
750 }
751}
752
754{
755 image_udims.clear();
756 for (auto [image_texture_id, img] : images.enumerate()) {
757 device_free_image(scene, image_texture_id);
758 }
759 images.clear();
760 image_cache.device_free(scene->dscene);
761 scene->dscene.image_textures.free();
763}
764
766{
767 if (!DebugFlags().texture_cache.use_eviction) {
768 return;
769 }
770
771 DeviceScene &dscene = scene->dscene;
773
774 if (tile_access.size() == 0) {
775 return;
776 }
777
778 /* Read back tile access state from all devices and OR together. */
779 device->mem_or_from_device(tile_access);
780
781 image_cache.evict_unused(*device,
782 dscene,
783 {dscene.image_textures.data(), dscene.image_textures.size()},
784 tile_access.data());
785
786 /* Reset access state on both host and device, so no more tiles are marked as used.
787 * Any tile not marked as used before the next eviction cycle will be evicted. */
788 memset(tile_access.data(), KERNEL_TILE_ACCESS_NONE, tile_access.size() * sizeof(uint8_t));
789 tile_access.zero_to_device();
790 tile_access.clear_modified();
791 device_copy_image_textures(device, scene);
792}
793
795{
796 DeviceScene &dscene = scene->dscene;
797
798 for (auto [image_texture_id, image] : images.enumerate()) {
799 if (!image) {
800 continue;
801 }
802
803 const KernelImageTexture &tex = dscene.image_textures[image_texture_id];
804
806 /* Tiled image. */
807 ImageTileStats tile_stats;
808 tile_stats.name = image->loader->name();
809 tile_stats.size = 0;
810
811 image_cache.collect_statistics(dscene, tex, image->metadata, tile_stats);
812
813 stats->image.tiled_images.push_back(tile_stats);
814 stats->image.tiled_images_size += tile_stats.size;
815 }
816 else {
817 /* Non-tiled image. */
819 NamedSizeEntry(image->loader->name(), image->metadata.memory_size()));
820 }
821 }
822
823 /* Add global overhead from device vectors. */
826 image_cache.memory_size(dscene);
827
828 /* Map image cache stats to eviction statistics. */
829 const ImageCacheStats &cache_stats = image_cache.get_stats();
830 stats->image.eviction.tiles_loaded = cache_stats.total_loaded;
831 stats->image.eviction.tiles_evicted = cache_stats.total_evicted;
832 stats->image.eviction.tiles_reloaded = cache_stats.total_reloaded;
833 stats->image.eviction.peak_loaded = cache_stats.peak_loaded;
834 stats->image.tiled_images_peak_size = size_t(cache_stats.peak_tiled_bytes);
835}
836
838{
839 need_update_ = true;
840}
841
843{
844 return need_update_;
845}
846
848{
849 return use_texture_cache;
850}
851
853{
854 return auto_texture_cache;
855}
856
857void ImageManager::report_failures()
858{
859 /* Report failure once after the full update. If we report an error immediately then
860 * exit-on-error will abort the process without waiting for other threads to cleanly finish
861 * generating their tx files. */
862 const int load_num = load_failure_num.exchange(0);
863 if (load_num > 0) {
864 LOG_ERROR << "Failed to load " << load_num << " image files";
865 }
866
867 const int tx_num = tx_failure_num.exchange(0);
868 if (tx_num > 0) {
869 LOG_ERROR << "Failed to generate " << tx_num << " tx files";
870 }
871}
872
virtual void * copy_from_device_synchronized(device_memory &mem, vector< uint8_t > &storage)=0
device_vector< uint8_t > image_texture_tile_access_state
device_vector< KernelImageUDIM > image_texture_udims
device_vector< KernelImageTexture > image_textures
Definition devicescene.h:98
KernelData data
virtual void mem_or_from_device(device_memory &mem)
virtual void set_image_cache_func(KernelImageLoadRequestedCPU, KernelImageLoadRequestedGPU image_load_requested_gpu)
int num_tiles() const
device_image * vdb_image_memory() const
ImageMetaData metadata(Progress &progress)
ImageManager * get_manager() const
bool operator==(const ImageHandle &other) const
friend class ImageManager
bool empty() const
int kernel_id() const
ImageManager * manager
ImageHandle & operator=(const ImageHandle &other)
VDBImageLoader * vdb_loader() const
bool all_udim_tiled(Progress &progress)
void add_to_set(set< const ImageSingle * > &images) const
ImageTexture * image_texture
virtual bool equals(const ImageLoader &other) const =0
virtual bool is_vdb_loader() const
void evict_unused(Device *device, Scene *scene)
void collect_statistics(RenderStats *stats, Scene *scene)
void device_update(Device *device, Scene *scene, Progress &progress)
bool need_update() const
void device_load_images(Device *device, Scene *scene, Progress &progress, const set< const ImageSingle * > &images)
void device_free(Scene *scene)
void device_free_builtin(Scene *scene)
void device_load_builtin(Device *device, Scene *scene, Progress &progress)
bool set_animation_frame_update(const int frame)
ImageManager(const DeviceInfo &info, const SceneParams &params)
ImageHandle add_image(const string &filename, const ImageParams &params)
bool get_use_texture_cache() const
friend class ImageHandle
bool get_auto_texture_cache() const
ImageDataType type
void finalize(const ImageAlphaType alpha_type=IMAGE_ALPHA_AUTO)
bool has_tiles_and_mipmaps
Transform transform_3d
uint32_t tile_size
ImageAlphaType alpha_type
InterpolationType interpolation
ExtensionType extension
device_image * vdb_memory
unique_ptr< ImageLoader > loader
ImageParams params
ImageMetaData metadata
thread_mutex mutex
vector< ImageTileStats > tiled_images
size_t tiled_images_peak_size
ImageEvictionStats eviction
size_t tiled_images_size
NamedSizeStats full_images
size_t overhead_size
enum ImageTexture::@125057243052132335305237234015050125102306363074 type
std::atomic< int > users
vector< std::pair< int, ImageHandle > > tiles
void add_entry(const NamedSizeEntry &entry)
Definition stats.cpp:58
bool get_cancel() const
Definition progress.h:77
void set_status(const string &status_, const string &substatus_="")
Definition progress.h:248
ImageStats image
std::string texture_cache_path
Definition scene.h:89
int texture_limit
Definition scene.h:82
float texture_resolution
Definition scene.h:81
bool auto_texture_cache
Definition scene.h:87
bool use_texture_cache
Definition scene.h:85
Definition scene.h:133
SceneParams params
Definition scene.h:190
unique_ptr< SceneUpdateStats > update_stats
Definition scene.h:197
DeviceScene dscene
Definition scene.h:187
void push(TaskRunFunction &&task)
Definition task.cpp:21
void wait_work(Summary *stats=nullptr)
Definition task.cpp:27
size_t size() const
T * resize(const size_t width, const size_t height=0)
size_t size() const
#define CCL_NAMESPACE_END
#define assert(assertion)
#define image(slot, qualifiers, format)
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
const ccl_global KernelWorkTile * tile
#define LOG_ERROR
Definition log.h:101
#define KERNEL_TILE_LOAD_NONE
#define KERNEL_IMAGE_NONE
#define KERNEL_TILE_ACCESS_NONE
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
auto isolate_task(const Function &function)
Definition BLI_task.hh:224
unsigned int uint
Definition BKE_text.h:55
unsigned char uint8_t
Definition BKE_text.h:79
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
Definition string.cpp:25
void string_replace(string &haystack, const string &needle, const string &other)
Definition string.cpp:147
int64_t peak_tiled_bytes
Definition image_cache.h:42
int64_t total_evicted
Definition image_cache.h:38
int64_t total_reloaded
Definition image_cache.h:39
int64_t total_loaded
Definition image_cache.h:37
int64_t peak_loaded
Definition image_cache.h:41
Transform transform_3d
std::unique_lock< std::mutex > thread_scoped_lock
Definition thread.h:28
uint KernelTileDescriptor
@ IMAGE_DATA_NUM_TYPES
Definition types_image.h:51
@ IMAGE_DATA_TYPE_BYTE4
Definition types_image.h:37