From f16bca72123b279a7c1e395abb75fb4032150391 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 8 Dec 2019 18:31:01 +0100 Subject: Fix T71480: crash with Eevee image texture node and clipping --- source/blender/nodes/shader/nodes/node_shader_tex_image.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source') diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index a6dfb2636fc..c81f4f9853f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -126,6 +126,12 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, switch (tex->projection) { case SHD_PROJ_FLAT: if (do_texco_clip) { + /* This seems redundant, but is required to ensure the texco link + * is not freed by GPU_link, as it is still needed for GPU_stack_link. + * Intermediate links like this can only be used once and are then + * freed immediately, but if we make it the output link of a set_rgb + * node it will be kept and can be used multiple times. */ + GPU_link(mat, "set_rgb", *texco, texco); GPU_link(mat, "set_rgb", *texco, &input_coords); } if (do_texco_extend) { @@ -151,6 +157,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, GPU_link(mat, "point_texco_remap_square", *texco, texco); GPU_link(mat, "point_map_to_sphere", *texco, texco); if (do_texco_clip) { + /* See SHD_PROJ_FLAT for explanation. */ + GPU_link(mat, "set_rgb", *texco, texco); GPU_link(mat, "set_rgb", *texco, &input_coords); } if (do_texco_extend) { @@ -163,6 +171,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, GPU_link(mat, "point_texco_remap_square", *texco, texco); GPU_link(mat, "point_map_to_tube", *texco, texco); if (do_texco_clip) { + /* See SHD_PROJ_FLAT for explanation. */ + GPU_link(mat, "set_rgb", *texco, texco); GPU_link(mat, "set_rgb", *texco, &input_coords); } if (do_texco_extend) { -- cgit v1.2.3