From 8e0763827e3165eea26b52f62694e7360c1d05c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 4 Feb 2022 13:49:37 +0100 Subject: [PATCH 1/3] Fix T95284 Workbench: "World" Cavity Type Doesn't Render Anything This was caused by a faulty UBO bind (not updated after renaming). --- source/blender/draw/engines/workbench/workbench_effect_cavity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.c b/source/blender/draw/engines/workbench/workbench_effect_cavity.c index 6ab74d179f6..04ff2077443 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_cavity.c +++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.c @@ -164,7 +164,7 @@ void workbench_cavity_cache_init(WORKBENCH_Data *data) grp = DRW_shgroup_create(sh, psl->cavity_ps); DRW_shgroup_uniform_texture(grp, "normalBuffer", wpd->normal_buffer_tx); - DRW_shgroup_uniform_block(grp, "samples_block", wpd->vldata->cavity_sample_ubo); + DRW_shgroup_uniform_block(grp, "samples_coords", wpd->vldata->cavity_sample_ubo); DRW_shgroup_uniform_block(grp, "world_data", wpd->world_ubo); if (SSAO_ENABLED(wpd)) { From 080dd18cdf8768ff61955d9cb5e5d02de5eb28d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 4 Feb 2022 14:02:43 +0100 Subject: [PATCH 2/3] Fix T95427: Crash during dragging a link in a node editor This was caused by macros interpreted as recursive. Workaround by not using macros at all and just define local variables which hopefully will be optimized. --- .../shaders/gpu_shader_2D_nodelink_vert.glsl | 97 +++++-------------- 1 file changed, 24 insertions(+), 73 deletions(-) diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl index b83ea59a692..779bcc59487 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl @@ -4,57 +4,18 @@ #define MID_VERTEX 65 -#ifndef USE_GPU_SHADER_CREATE_INFO +/** + * `uv.x` is position along the curve, defining the tangent space. + * `uv.y` is "signed" distance (compressed to [0..1] range) from the pos in expand direction + * `pos` is the verts position in the curve tangent space + */ -/* u is position along the curve, defining the tangent space. - * v is "signed" distance (compressed to [0..1] range) from the pos in expand direction */ -in vec2 uv; -in vec2 pos; /* verts position in the curve tangent space */ -in vec2 expand; - -# ifdef USE_INSTANCE -/* Instance attrs. */ -in vec2 P0; -in vec2 P1; -in vec2 P2; -in vec2 P3; -in ivec4 colid_doarrow; -in vec4 start_color; -in vec4 end_color; -in ivec2 domuted; -in float dim_factor; -in float thickness; -in float dash_factor; -in float dash_alpha; - -uniform vec4 colors[6]; - -# else -/* Single curve drawcall, use uniform. */ -uniform vec2 bezierPts[4]; - -uniform vec4 colors[3]; -uniform bool doArrow; -uniform bool doMuted; -uniform float dim_factor; -uniform float thickness; -uniform float dash_factor; -uniform float dash_alpha; - -# endif - -uniform float expandSize; -uniform float arrowSize; -uniform mat4 ModelViewProjectionMatrix; - -out float colorGradient; -out vec4 finalColor; -out float lineU; -flat out float lineLength; -flat out float dashFactor; -flat out float dashAlpha; -flat out int isMainLine; -#endif +void main(void) +{ + /* Define where along the noodle the gradient will starts and ends. + * Use 0.25 instead of 0.35-0.65, because of a visual shift issue. */ + const float start_gradient_threshold = 0.25; + const float end_gradient_threshold = 0.55; #ifdef USE_INSTANCE # define colStart (colid_doarrow[0] < 3 ? start_color : node_link_data.colors[colid_doarrow[0]]) @@ -62,33 +23,23 @@ flat out int isMainLine; # define colShadow node_link_data.colors[colid_doarrow[2]] # define doArrow (colid_doarrow[3] != 0) # define doMuted (domuted[0] != 0) - #else -# define P0 node_link_data.bezierPts[0].xy -# define P1 node_link_data.bezierPts[1].xy -# define P2 node_link_data.bezierPts[2].xy -# define P3 node_link_data.bezierPts[3].xy -# define cols node_link_data.colors -# define doArrow node_link_data.doArrow -# define doMuted node_link_data.doMuted -# define dim_factor node_link_data.dim_factor -# define thickness node_link_data.thickness -# define dash_factor node_link_data.dash_factor -# define dash_alpha node_link_data.dash_alpha - -# define colShadow node_link_data.colors[0] -# define colStart node_link_data.colors[1] -# define colEnd node_link_data.colors[2] + vec2 P0 = node_link_data.bezierPts[0].xy; + vec2 P1 = node_link_data.bezierPts[1].xy; + vec2 P2 = node_link_data.bezierPts[2].xy; + vec2 P3 = node_link_data.bezierPts[3].xy; + bool doArrow = node_link_data.doArrow; + bool doMuted = node_link_data.doMuted; + float dim_factor = node_link_data.dim_factor; + float thickness = node_link_data.thickness; + float dash_factor = node_link_data.dash_factor; + float dash_alpha = node_link_data.dash_alpha; + vec4 colShadow = node_link_data.colors[0]; + vec4 colStart = node_link_data.colors[1]; + vec4 colEnd = node_link_data.colors[2]; #endif -/* Define where along the noodle the gradient will starts and ends. - * Use 0.25 instead of 0.35-0.65, because of a visual shift issue. */ -const float start_gradient_threshold = 0.25; -const float end_gradient_threshold = 0.55; - -void main(void) -{ /* Parameters for the dashed line. */ isMainLine = expand.y != 1.0 ? 0 : 1; dashFactor = dash_factor; From 2e766ff7624349b65a5d908dc3895ad10b240050 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 4 Feb 2022 15:28:48 +0100 Subject: [PATCH 3/3] Image Editor: Fix slowdown with 8b colormanaged images. Byte images are converted to float. Due to an issue how VSE cache is freeing its images we cannot store these float buffers what leads to recalculating it for each change in the image editor. This fix will reduce the slowdown to areas that have the root cause of the memory leak, so the buffers can be reused between refreshes. NOTE: The root cause should still be fixed. Thanks for reporting Sybren! --- .../blender/draw/engines/image/image_drawing_mode.hh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh b/source/blender/draw/engines/image/image_drawing_mode.hh index 16d3ff30890..b56f3062901 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.hh +++ b/source/blender/draw/engines/image/image_drawing_mode.hh @@ -231,7 +231,7 @@ template class ScreenSpaceDrawingMode : public AbstractD if (iterator.tile_data.tile_buffer == nullptr) { continue; } - const bool float_buffer_created = ensure_float_buffer(*iterator.tile_data.tile_buffer); + ensure_float_buffer(*iterator.tile_data.tile_buffer); const float tile_width = static_cast(iterator.tile_data.tile_buffer->x); const float tile_height = static_cast(iterator.tile_data.tile_buffer->y); @@ -338,10 +338,6 @@ template class ScreenSpaceDrawingMode : public AbstractD 0); imb_freerectImbuf_all(&extracted_buffer); } - /* TODO(jbakker): Find leak when rendering VSE and remove this call. */ - if (float_buffer_created) { - imb_freerectfloatImBuf(iterator.tile_data.tile_buffer); - } } } @@ -419,6 +415,9 @@ template class ScreenSpaceDrawingMode : public AbstractD const int texture_width = texture_buffer.x; const int texture_height = texture_buffer.y; const bool float_buffer_created = ensure_float_buffer(tile_buffer); + /* TODO(jbakker): Find leak when rendering VSE and don't free here. */ + const bool do_free_float_buffer = float_buffer_created && + instance_data.image->type == IMA_TYPE_R_RESULT; /* IMB_transform works in a non-consistent space. This should be documented or fixed!. * Construct a variant of the info_uv_to_texture that adds the texel space @@ -456,8 +455,7 @@ template class ScreenSpaceDrawingMode : public AbstractD uv_to_texel, crop_rect_ptr); - /* TODO(jbakker): Find leak when rendering VSE and remove this call. */ - if (float_buffer_created) { + if (do_free_float_buffer) { imb_freerectfloatImBuf(&tile_buffer); } }