Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/external_engine.c
| Show All 23 Lines | |||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BLI_utildefines.h" | |||||
| #include "BLI_ghash.h" | |||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_rect.h" | |||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_utildefines.h" | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| ▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | #endif | ||||
| MEM_freeN(engine); | MEM_freeN(engine); | ||||
| } | } | ||||
| /* Render Results */ | /* Render Results */ | ||||
| static RenderPart *get_part_from_result(Render *re, RenderResult *result) | static RenderPart *get_part_from_result(Render *re, RenderResult *result) | ||||
| { | { | ||||
| RenderPart *pa; | rcti key = result->tilerect; | ||||
| BLI_rcti_translate(&key, re->disprect.xmin, re->disprect.ymin); | |||||
| for (pa = re->parts.first; pa; pa = pa->next) { | |||||
| if (result->tilerect.xmin == pa->disprect.xmin - re->disprect.xmin && | |||||
| result->tilerect.ymin == pa->disprect.ymin - re->disprect.ymin && | |||||
| result->tilerect.xmax == pa->disprect.xmax - re->disprect.xmin && | |||||
| result->tilerect.ymax == pa->disprect.ymax - re->disprect.ymin) { | |||||
| return pa; | |||||
| } | |||||
| } | |||||
| return NULL; | return BLI_ghash_lookup(re->parts, &key); | ||||
| } | } | ||||
| RenderResult *RE_engine_begin_result( | RenderResult *RE_engine_begin_result( | ||||
| RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname) | RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname) | ||||
| { | { | ||||
| Render *re = engine->re; | Render *re = engine->re; | ||||
| RenderResult *result; | RenderResult *result; | ||||
| rcti disprect; | rcti disprect; | ||||
| ▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | bool RE_engine_get_spherical_stereo(RenderEngine *engine, Object *camera) | ||||
| Render *re = engine->re; | Render *re = engine->re; | ||||
| return BKE_camera_multiview_spherical_stereo(re ? &re->r : NULL, camera) ? 1 : 0; | return BKE_camera_multiview_spherical_stereo(re ? &re->r : NULL, camera) ? 1 : 0; | ||||
| } | } | ||||
| rcti *RE_engine_get_current_tiles(Render *re, int *r_total_tiles, bool *r_needs_free) | rcti *RE_engine_get_current_tiles(Render *re, int *r_total_tiles, bool *r_needs_free) | ||||
| { | { | ||||
| static rcti tiles_static[BLENDER_MAX_THREADS]; | static rcti tiles_static[BLENDER_MAX_THREADS]; | ||||
| const int allocation_step = BLENDER_MAX_THREADS; | const int allocation_step = BLENDER_MAX_THREADS; | ||||
| RenderPart *pa; | |||||
| int total_tiles = 0; | int total_tiles = 0; | ||||
| rcti *tiles = tiles_static; | rcti *tiles = tiles_static; | ||||
| int allocation_size = BLENDER_MAX_THREADS; | int allocation_size = BLENDER_MAX_THREADS; | ||||
| BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_READ); | BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_READ); | ||||
| *r_needs_free = false; | *r_needs_free = false; | ||||
| if (re->engine && (re->engine->flag & RE_ENGINE_HIGHLIGHT_TILES) == 0) { | if (!re->parts || (re->engine && (re->engine->flag & RE_ENGINE_HIGHLIGHT_TILES) == 0)) { | ||||
| *r_total_tiles = 0; | *r_total_tiles = 0; | ||||
| BLI_rw_mutex_unlock(&re->partsmutex); | BLI_rw_mutex_unlock(&re->partsmutex); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| for (pa = re->parts.first; pa; pa = pa->next) { | GHashIterator pa_iter; | ||||
| GHASH_ITER (pa_iter, re->parts) { | |||||
| RenderPart *pa = BLI_ghashIterator_getValue(&pa_iter); | |||||
| if (pa->status == PART_STATUS_IN_PROGRESS) { | if (pa->status == PART_STATUS_IN_PROGRESS) { | ||||
| if (total_tiles >= allocation_size) { | if (total_tiles >= allocation_size) { | ||||
| /* Just in case we're using crazy network rendering with more | /* Just in case we're using crazy network rendering with more | ||||
| * workers than BLENDER_MAX_THREADS. | * workers than BLENDER_MAX_THREADS. | ||||
| */ | */ | ||||
| allocation_size += allocation_step; | allocation_size += allocation_step; | ||||
| if (tiles == tiles_static) { | if (tiles == tiles_static) { | ||||
| /* Can not realloc yet, tiles are pointing to a | /* Can not realloc yet, tiles are pointing to a | ||||
| ▲ Show 20 Lines • Show All 399 Lines • Show Last 20 Lines | |||||