From 7db42b8f2a8cdec5067f2fe73082bd5d806a5e42 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 13 Nov 2020 22:09:37 +0100 Subject: Fix T82460: Color Management Curves do not update when Image/UV Editor is present Caused by rB4212b6528afb. 'updateGLSLCurveMapping()' compares cacheIDs and in certain scenarios, these are the same when they should not. - whenever we had multiple viewports that are colormanaged with curvemappings this worked right (cacheIDs were different) - for example, this also worked right when the ImageEditor displays a Render Result or a Compositor Viewer - but it worked wrong when the Image Editor displays any other Image (or no Image at all) - it also worked right if there were multiple Image Editors [and one of them displays a Render Result e.g] Now why is this so? For comparison, the curve mapping's pointer/address is used. - update_glsl_display_processor frees the curve_mapping, see BKE_curvemapping_free(global_glsl_state.curve_mapping) - similar, update_glsl_display_processor creates a new curvemapping, see BKE_curvemapping_copy(view_settings->curve_mapping) - now for the situation that a viewport with curvemapping and a viewport without curvemapping is present and you make changes to the curvemapping the following happens: -- curve_mapping_settings->cache_id is set once [to the memory address of curvemapping before change] -- change happens -- viewport 1 frees curvemapping -- viewport 2 duplicates using BKE_curvemapping_copy, but this one gets the same address like before the change -- this means we have different data on the same address with the same cacheID... Solution: to really make the cache ID unique we can combine the pointer with its 'changed_timestamp' [which increases on every change]. Reviewers: jbakker Maniphest Tasks: T82460 Differential Revision: https://developer.blender.org/D9559 --- source/blender/imbuf/intern/colormanagement.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 8005049eab2..7847ae83c19 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -4044,7 +4044,7 @@ static void curve_mapping_to_ocio_settings(CurveMapping *curve_mapping, copy_v3_v3(curve_mapping_settings->black, curve_mapping->black); copy_v3_v3(curve_mapping_settings->bwmul, curve_mapping->bwmul); - curve_mapping_settings->cache_id = (size_t)curve_mapping; + curve_mapping_settings->cache_id = (size_t)curve_mapping + curve_mapping->changed_timestamp; } static void update_glsl_display_processor(const ColorManagedViewSettings *view_settings, -- cgit v1.2.3