diff options
author | Jacques Lucke <jacques@blender.org> | 2021-12-25 13:14:02 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-12-25 13:14:02 +0300 |
commit | 28df0107d4a83dd7ce62781bef821092db1e0835 (patch) | |
tree | 53c755f72f58bf52ecbff39f60f83d74b36767b5 /source/blender/draw/intern/draw_manager_data.c | |
parent | f1e04116f08d80a7523d1b18bbba3c16b0d8943d (diff) |
Fix T94362: GPUMaterialTexture references freed ImageUser
The issue was caused by rB7e712b2d6a0d257d272ed35622b41d06274af8df
and the fact that `GPUMaterialTexture` contains an `ImageUser *` which
references the `ImageUser` on e.g. `NodeTexImage`.
Since the node tree update refactor, it is possible that the node tree changes
without changing the actual material. Therefore, either the renderer should
check if the node tree has changed or it should not store pointers to data in
node storage. The latter approach is implemented in this patch.
Differential Revision: https://developer.blender.org/D13663
Diffstat (limited to 'source/blender/draw/intern/draw_manager_data.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index e71a1298812..f1c13bc039a 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -1364,14 +1364,15 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial if (tex->ima) { /* Image */ GPUTexture *gputex; + ImageUser *iuser = tex->iuser_available ? &tex->iuser : NULL; if (tex->tiled_mapping_name[0]) { - gputex = BKE_image_get_gpu_tiles(tex->ima, tex->iuser, NULL); + gputex = BKE_image_get_gpu_tiles(tex->ima, iuser, NULL); drw_shgroup_material_texture(grp, gputex, tex->sampler_name, tex->sampler_state); - gputex = BKE_image_get_gpu_tilemap(tex->ima, tex->iuser, NULL); + gputex = BKE_image_get_gpu_tilemap(tex->ima, iuser, NULL); drw_shgroup_material_texture(grp, gputex, tex->tiled_mapping_name, tex->sampler_state); } else { - gputex = BKE_image_get_gpu_texture(tex->ima, tex->iuser, NULL); + gputex = BKE_image_get_gpu_texture(tex->ima, iuser, NULL); drw_shgroup_material_texture(grp, gputex, tex->sampler_name, tex->sampler_state); } } |