Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/render/intern/engine.c')
-rw-r--r--source/blender/render/intern/engine.c83
1 files changed, 58 insertions, 25 deletions
diff --git a/source/blender/render/intern/engine.c b/source/blender/render/intern/engine.c
index 1510587502b..481a6662cc0 100644
--- a/source/blender/render/intern/engine.c
+++ b/source/blender/render/intern/engine.c
@@ -291,6 +291,15 @@ static RenderPart *get_part_from_result(Render *re, RenderResult *result)
return BLI_ghash_lookup(re->parts, &key);
}
+static HighlightedTile highlighted_tile_from_result_get(Render *re, RenderResult *result)
+{
+ HighlightedTile tile;
+ tile.rect = result->tilerect;
+ BLI_rcti_translate(&tile.rect, re->disprect.xmin, re->disprect.ymin);
+
+ return tile;
+}
+
RenderResult *RE_engine_begin_result(
RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname)
{
@@ -426,6 +435,30 @@ void RE_engine_end_result(
}
}
+ if (re->engine && (re->engine->flag & RE_ENGINE_HIGHLIGHT_TILES)) {
+ BLI_mutex_lock(&re->highlighted_tiles_mutex);
+
+ if (re->highlighted_tiles == NULL) {
+ re->highlighted_tiles = BLI_gset_new(
+ BLI_ghashutil_inthash_v4_p, BLI_ghashutil_inthash_v4_cmp, "highlighted tiles");
+ }
+
+ HighlightedTile tile = highlighted_tile_from_result_get(re, result);
+ if (highlight) {
+ void **tile_in_set;
+ if (!BLI_gset_ensure_p_ex(re->highlighted_tiles, &tile, &tile_in_set)) {
+ *tile_in_set = MEM_mallocN(sizeof(HighlightedTile), __func__);
+ memcpy(*tile_in_set, &tile, sizeof(tile));
+ }
+ BLI_gset_add(re->highlighted_tiles, &tile);
+ }
+ else {
+ BLI_gset_remove(re->highlighted_tiles, &tile, MEM_freeN);
+ }
+
+ BLI_mutex_unlock(&re->highlighted_tiles_mutex);
+ }
+
if (!cancel || merge_results) {
if (re->result->do_exr_tile) {
if (!cancel && merge_results) {
@@ -597,43 +630,43 @@ rcti *RE_engine_get_current_tiles(Render *re, int *r_total_tiles, bool *r_needs_
rcti *tiles = tiles_static;
int allocation_size = BLENDER_MAX_THREADS;
- BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_READ);
+ BLI_mutex_lock(&re->highlighted_tiles_mutex);
*r_needs_free = false;
- if (!re->parts || (re->engine && (re->engine->flag & RE_ENGINE_HIGHLIGHT_TILES) == 0)) {
+ if (re->highlighted_tiles == NULL) {
*r_total_tiles = 0;
- BLI_rw_mutex_unlock(&re->partsmutex);
+ BLI_mutex_unlock(&re->highlighted_tiles_mutex);
return NULL;
}
- GHashIterator pa_iter;
- GHASH_ITER (pa_iter, re->parts) {
- RenderPart *pa = BLI_ghashIterator_getValue(&pa_iter);
- if (pa->status == PART_STATUS_IN_PROGRESS) {
- if (total_tiles >= allocation_size) {
- /* Just in case we're using crazy network rendering with more
- * workers than BLENDER_MAX_THREADS.
+ GSET_FOREACH_BEGIN (HighlightedTile *, tile, re->highlighted_tiles) {
+ if (total_tiles >= allocation_size) {
+ /* Just in case we're using crazy network rendering with more
+ * workers than BLENDER_MAX_THREADS.
+ */
+ allocation_size += allocation_step;
+ if (tiles == tiles_static) {
+ /* Can not realloc yet, tiles are pointing to a
+ * stack memory.
*/
- allocation_size += allocation_step;
- if (tiles == tiles_static) {
- /* Can not realloc yet, tiles are pointing to a
- * stack memory.
- */
- tiles = MEM_mallocN(allocation_size * sizeof(rcti), "current engine tiles");
- }
- else {
- tiles = MEM_reallocN(tiles, allocation_size * sizeof(rcti));
- }
- *r_needs_free = true;
+ tiles = MEM_mallocN(allocation_size * sizeof(rcti), "current engine tiles");
}
- tiles[total_tiles] = pa->disprect;
-
- total_tiles++;
+ else {
+ tiles = MEM_reallocN(tiles, allocation_size * sizeof(rcti));
+ }
+ *r_needs_free = true;
}
+ tiles[total_tiles] = tile->rect;
+
+ total_tiles++;
}
- BLI_rw_mutex_unlock(&re->partsmutex);
+ GSET_FOREACH_END();
+
+ BLI_mutex_unlock(&re->highlighted_tiles_mutex);
+
*r_total_tiles = total_tiles;
+
return tiles;
}