diff options
author | Jacques Lucke <jacques@blender.org> | 2021-12-31 16:23:14 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-12-31 16:24:11 +0300 |
commit | d09b1d2759861aa012ab2e7e4ce2ffa2b56bd9d3 (patch) | |
tree | 7cdbb28a6ba1ae13ff61acaaf3473544932827d3 /source/blender/blenkernel/intern | |
parent | 56344fb30fe41bb18a2fce246a30a9e14a8d4e25 (diff) |
Fix T94464: video texture is not refreshing
In the past that worked because the `GPUMaterial` referenced the
`ImageUser` from the image node. However, that design was incompatible
with the recent node tree update refactor (rB7e712b2d6a0d257d272e).
Also, in general it is a bad idea to have references between data that is
owned by two different data blocks.
This incompatibility was resolved by copying the image user from the node
to the `GPUMaterial` (rB28df0107d4a8). Unfortunately, eevee depended
on this reference, because the image user on the node was update when the
frame changed. Because the image user was copied, the image user in the
`GPUMaterial` did not receive the frame update anymore.
This frame update is added back by this commit. The main change is that
the image user iterator now also iterates over image users in `GPUMaterial`s
on material and world data blocks. An issue is that these materials don't
exist on the original data blocks and that caused the check in
`build_animation_images` in the depsgraph to give the wrong answer.
Therefore the check is extended.
Right now the check is not optimal, because it results in more depsgraph
nodes than are necessary. This can be improved when it becomes cheaper
to check if a node tree contains any references to a video texture.
The node tree update refactor mentioned before makes it much easier
to construct this kind of run-time data from the bottom up, instead of
scanning the entire node tree recursively every time some information
is needed.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index edd5073da79..3fec5db422d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -98,6 +98,7 @@ #include "SEQ_utils.h" /* SEQ_get_topmost_sequence() */ +#include "GPU_material.h" #include "GPU_texture.h" #include "BLI_sys_types.h" /* for intptr_t support */ @@ -3364,6 +3365,23 @@ static void image_walk_ntree_all_users( } } +static void image_walk_gpu_materials( + ID *id, + ListBase *gpu_materials, + void *customdata, + void callback(Image *ima, ID *iuser_id, ImageUser *iuser, void *customdata)) +{ + LISTBASE_FOREACH (LinkData *, link, gpu_materials) { + GPUMaterial *gpu_material = (GPUMaterial *)link->data; + ListBase textures = GPU_material_textures(gpu_material); + LISTBASE_FOREACH (GPUMaterialTexture *, gpu_material_texture, &textures) { + if (gpu_material_texture->iuser_available) { + callback(gpu_material_texture->ima, id, &gpu_material_texture->iuser, customdata); + } + } + } +} + static void image_walk_id_all_users( ID *id, bool skip_nested_nodes, @@ -3383,6 +3401,7 @@ static void image_walk_id_all_users( if (ma->nodetree && ma->use_nodes && !skip_nested_nodes) { image_walk_ntree_all_users(ma->nodetree, &ma->id, customdata, callback); } + image_walk_gpu_materials(id, &ma->gpumaterial, customdata, callback); break; } case ID_LA: { @@ -3397,6 +3416,7 @@ static void image_walk_id_all_users( if (world->nodetree && world->use_nodes && !skip_nested_nodes) { image_walk_ntree_all_users(world->nodetree, &world->id, customdata, callback); } + image_walk_gpu_materials(id, &world->gpumaterial, customdata, callback); break; } case ID_TE: { |