Geometry Nodes: support baking data block references #117043

Merged
Jacques Lucke merged 79 commits from JacquesLucke/blender:bake-data-block-map into main 2024-02-01 09:22:04 +01:00
Member

With this patch, materials are kept intact in simulation zones and bake nodes without any additional user action.

This implements the design proposed in #108410 to support referencing data-blocks (only materials for now) in the baked data. The task also describes why this is not a trivial issue. A previous attempt was implemented in #109703 but it didn't work well-enough.

The solution is to have an explicit name (+ library name) -> data-block mapping that is stored in the modifier for each bake node and simulation zone. The library name is necessary for it to be unique within a .blend file. Note that this refers to the name of the Library data-block and not a file path. The baked data only contains the names of the used data-blocks. When the baked data is loaded, the correct material data-block is looked up from the mapping.

Automatic Mapping Generation

The most tricky aspect of this approach is to make it automatic. From the user point-of-view, it should just work. Therefore, we don't want the user to have to create the mapping manually in the majority of cases. Creating the mapping automatically is difficult because the data-blocks that should become part of the mapping are only known during depsgraph evaluation. So we somehow have to gather the missing data blocks during evaluation and then write the new mappings back to the original data.

While writing back to original data is something we do in some cases already, the situation here is different, because we are actually creating new relations between data-blocks. This also means that we'll have to do user-counting. Since user counts in data-blocks are not atomic, we can't do that from multiple threads at the same time. Also, under some circumstances, it may be necessary to trigger depsgraph evaluation again after the write-back because it actually affects the result.

To solve this, a small new API is added in DEG_depsgraph_writeback_sync.hh. It allows gathering tasks which write back to original data in a synchronous way which may also require a reevaluation.

Accessing the Mapping

A new BakeDataBlockMap is passed to some nodes (bake and simulation for now) by the modifier. This map allows getting the ID pointer that should be used for a specific data-block name that is stored in baked data. It's also used to gather all the missing data mappings during evaluation.

Weak ID References

The baked/cached geometries may have references to other data-blocks (currently only materials, but in the future also e.g. instanced objects/collections). However, the pointers of these data-blocks are not stable over time. That is especially true when storing/loading the data from disk, but also just when playing back the animation. Therefore, the used data-blocks have to referenced in a different way at run-time.

This is solved by adding std::unique_ptr<bake::BakeMaterialsList> to the run-time data of various geometry data-blocks. If the data-block is cached over a longer period of time (such that material pointers can't be used directly), it stores the material name (+ library name) used by each material slot. When the geometry is used again, the material pointers are restored using these weak name references and the BakeDataBlockMap.

Manual Mapping Management

There is a new Data-Blocks panel in the bake settings in the node editor sidebar that allows inspecting and modifying the data-blocks that are used when baking. The user can change what data-block a specific name is mapped to.

image

With this patch, materials are kept intact in simulation zones and bake nodes without any additional user action. This implements the design proposed in #108410 to support referencing data-blocks (only materials for now) in the baked data. The task also describes why this is not a trivial issue. A previous attempt was implemented in #109703 but it didn't work well-enough. The solution is to have an explicit `name (+ library name) -> data-block` mapping that is stored in the modifier for each bake node and simulation zone. The `library name` is necessary for it to be unique within a .blend file. Note that this refers to the name of the `Library` data-block and not a file path. The baked data only contains the names of the used data-blocks. When the baked data is loaded, the correct material data-block is looked up from the mapping. ### Automatic Mapping Generation The most tricky aspect of this approach is to make it automatic. From the user point-of-view, it should just work. Therefore, we don't want the user to have to create the mapping manually in the majority of cases. Creating the mapping automatically is difficult because the data-blocks that should become part of the mapping are only known during depsgraph evaluation. So we somehow have to gather the missing data blocks during evaluation and then write the new mappings back to the original data. While writing back to original data is something we do in some cases already, the situation here is different, because we are actually creating new relations between data-blocks. This also means that we'll have to do user-counting. Since user counts in data-blocks are *not* atomic, we can't do that from multiple threads at the same time. Also, under some circumstances, it may be necessary to trigger depsgraph evaluation again after the write-back because it actually affects the result. To solve this, a small new API is added in `DEG_depsgraph_writeback_sync.hh`. It allows gathering tasks which write back to original data in a synchronous way which may also require a reevaluation. ### Accessing the Mapping A new `BakeDataBlockMap` is passed to some nodes (bake and simulation for now) by the modifier. This map allows getting the `ID` pointer that should be used for a specific data-block name that is stored in baked data. It's also used to gather all the missing data mappings during evaluation. ### Weak ID References The baked/cached geometries may have references to other data-blocks (currently only materials, but in the future also e.g. instanced objects/collections). However, the pointers of these data-blocks are not stable over time. That is especially true when storing/loading the data from disk, but also just when playing back the animation. Therefore, the used data-blocks have to referenced in a different way at run-time. This is solved by adding `std::unique_ptr<bake::BakeMaterialsList>` to the run-time data of various geometry data-blocks. If the data-block is cached over a longer period of time (such that material pointers can't be used directly), it stores the material name (+ library name) used by each material slot. When the geometry is used again, the material pointers are restored using these weak name references and the `BakeDataBlockMap`. ### Manual Mapping Management There is a new `Data-Blocks` panel in the bake settings in the node editor sidebar that allows inspecting and modifying the data-blocks that are used when baking. The user can change what data-block a specific name is mapped to. ![image](/attachments/099cd77f-0363-408f-984b-874b29543c7a)
Jacques Lucke added 13 commits 2024-01-11 20:24:52 +01:00
Jacques Lucke added 1 commit 2024-01-12 15:19:09 +01:00
Jacques Lucke added 2 commits 2024-01-14 14:03:23 +01:00
Jacques Lucke added 1 commit 2024-01-16 13:45:48 +01:00
Jacques Lucke added 4 commits 2024-01-16 17:32:17 +01:00
Jacques Lucke added 1 commit 2024-01-16 18:09:40 +01:00
Jacques Lucke added 4 commits 2024-01-16 19:29:37 +01:00
Jacques Lucke added 1 commit 2024-01-16 19:32:36 +01:00
Jacques Lucke added 1 commit 2024-01-18 10:41:17 +01:00
Jacques Lucke added 6 commits 2024-01-18 13:02:49 +01:00
Hans Goudey added 7 commits 2024-01-19 19:16:31 +01:00
Jacques Lucke added 1 commit 2024-01-22 16:54:43 +01:00
Jacques Lucke added 1 commit 2024-01-22 17:51:28 +01:00
Jacques Lucke added 4 commits 2024-01-23 10:45:38 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
0420547c21
improve description
Jacques Lucke changed title from WIP: Geometry Nodes: support baking data block references to Geometry Nodes: support baking data block references 2024-01-23 11:21:52 +01:00
Jacques Lucke requested review from Simon Thommes 2024-01-23 11:23:44 +01:00
Jacques Lucke requested review from Hans Goudey 2024-01-23 11:23:44 +01:00
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke requested review from Brecht Van Lommel 2024-01-24 11:58:51 +01:00
Jacques Lucke requested review from Sergey Sharybin 2024-01-24 11:58:51 +01:00

For the UI:

  • With panel titles "Bake" > "Data-Blocks" it sounds a bit like those datablocks are being baked. Maybe "References" or "Referenced Data" as the panel title would be better?
  • I would try to put all the information in the list itself rather than as buttons below. I think you could split the row layout 50/50, and then have a text label with datablock and library name on the left, and button to select datablock on the right.
For the UI: * With panel titles "Bake" > "Data-Blocks" it sounds a bit like those datablocks are being baked. Maybe "References" or "Referenced Data" as the panel title would be better? * I would try to put all the information in the list itself rather than as buttons below. I think you could split the row layout 50/50, and then have a text label with datablock and library name on the left, and button to select datablock on the right.
Jacques Lucke added 2 commits 2024-01-26 10:57:57 +01:00
Author
Member

@brecht sounds good, changed it and updated the screenshot.

@brecht sounds good, changed it and updated the screenshot.
Brecht Van Lommel requested changes 2024-01-26 15:48:14 +01:00
@ -2614,1 +2619,4 @@
DEG_ids_clear_recalc(depsgraph, backup);
if (blender::bke::scene::sync_writeback::run(*depsgraph)) {
scene_graph_update_tagged(depsgraph, bmain, only_if_tagged);

This recursive function call looks too risky to me. I can't locally reason about this not going into infinite recursion, it depends on what the write back functions do exactly.

It also means callbacks for add-ons get run twice, which I think would add unnecessary overhead, and break expectations about how many times these are run.

I would rather expect this writeback to happen after each pass. What I don't understand well is if there is a need for this to cause a third pass to be run.

This recursive function call looks too risky to me. I can't locally reason about this not going into infinite recursion, it depends on what the write back functions do exactly. It also means callbacks for add-ons get run twice, which I think would add unnecessary overhead, and break expectations about how many times these are run. I would rather expect this writeback to happen after each pass. What I don't understand well is if there is a need for this to cause a third pass to be run.
Author
Member

In theory it's possible that an arbitrary amount of reevaluations is necessary (will outline the case below). In almost all cases, no extra evaluation is necessary, even if a missing data block mapping is created, because all dependencies existed in the depsgraph already. An extra evaluation is only necessary if the baked data on disk references a data block that is currently not a dependency of the object and is not yet in the data block mapping. This is rather unlikely to happen in practice currently but can happen when manually editing the data block references, or the baked data, when baking without saving the .blend file afterwards or when trying to load baked data in a different file.

Multiple reevaluations can happen in theory if all of the following are true at the same time:

  • There are multiple baked bake nodes which all reference different data blocks.
  • The referenced data blocks are not in the data block mapping yet.
  • Each bake node is only loaded conditionally, if the previous bake nodes data block references are mapped correctly. Can be done with a switch node somehow.

This can lead to the situation where in the first evaluation, the first bake node is loaded which is missing data block references which are then automatically created. Then a reevaluation is necessary because the result changed. In the second reevaluation the second bake node is now used, which has missing data blocks again, and so on.

I'm not aware of a practical use case where more than one reevaluation after loading a bake is necessary.

Running the write-back after each pass should work too.

In theory it's possible that an arbitrary amount of reevaluations is necessary (will outline the case below). In almost all cases, no extra evaluation is necessary, even if a missing data block mapping is created, because all dependencies existed in the depsgraph already. An extra evaluation is only necessary if the baked data on disk references a data block that is currently not a dependency of the object and is not yet in the data block mapping. This is rather unlikely to happen in practice currently but can happen when manually editing the data block references, or the baked data, when baking without saving the .blend file afterwards or when trying to load baked data in a different file. Multiple reevaluations can happen in theory if all of the following are true at the same time: * There are multiple baked bake nodes which all reference different data blocks. * The referenced data blocks are not in the data block mapping yet. * Each bake node is only loaded conditionally, if the previous bake nodes data block references are mapped correctly. Can be done with a switch node somehow. This can lead to the situation where in the first evaluation, the first bake node is loaded which is missing data block references which are then automatically created. Then a reevaluation is necessary because the result changed. In the second reevaluation the second bake node is now used, which has missing data blocks again, and so on. I'm not aware of a practical use case where more than one reevaluation after loading a bake is necessary. Running the write-back after each pass should work too.
Author
Member

I updated the code so that the write-back happens directly after each pass. There are still at most two passes for now. As said, in theory there are cases where more passes are necessary, but I'm not sure if anyone will ever run into that case. In the worst case, there are some missing data block relations when loading baked data which are automatically solved after the next reevaluation.

I updated the code so that the write-back happens directly after each pass. There are still at most two passes for now. As said, in theory there are cases where more passes are necessary, but I'm not sure if anyone will ever run into that case. In the worst case, there are some missing data block relations when loading baked data which are automatically solved after the next reevaluation.
JacquesLucke marked this conversation as resolved
@ -2694,1 +2705,4 @@
}
if (blender::bke::scene::sync_writeback::run(*depsgraph)) {
BKE_scene_graph_update_for_newframe_ex(depsgraph, clear_recalc);

Same comment here.

Same comment here.
JacquesLucke marked this conversation as resolved
@ -0,0 +14,4 @@
struct WritebacksMap {
std::mutex mutex;
Map<const Depsgraph *, Vector<std::function<void()>>> map;

It's not clear to me why this map is used instead of storing these writebacks on the depsgraph itself. Seems like globals and any mutex locking can be eliminated then?

It's not clear to me why this map is used instead of storing these writebacks on the depsgraph itself. Seems like globals and any mutex locking can be eliminated then?
Author
Member

My main reason for not putting it on the Depsgraph itself was that this is not necessary the business of the depsgraph but of the code that is using the depsgraph. I'm fine with moving it directly to the depsgraph though.

My main reason for not putting it on the `Depsgraph` itself was that this is not necessary the business of the depsgraph but of the code that is using the depsgraph. I'm fine with moving it directly to the depsgraph though.
Author
Member

I changed it so that the functions are stored on the depsgraph directly. A (non-global) mutex is still necessary, because multiple threads may want to add a writeback tasks at the same time during depsgraph evaluation.

I changed it so that the functions are stored on the depsgraph directly. A (non-global) mutex is still necessary, because multiple threads may want to add a writeback tasks at the same time during depsgraph evaluation.
JacquesLucke marked this conversation as resolved
Jacques Lucke added 5 commits 2024-01-29 10:20:34 +01:00
Jacques Lucke requested review from Brecht Van Lommel 2024-01-29 10:25:37 +01:00
Brecht Van Lommel requested changes 2024-01-29 11:09:05 +01:00
@ -2571,0 +2575,4 @@
/* Write information gathered during evaluation back to original data. This may also create
* new depsgraph relations. */
blender::deg::sync_writeback::run(*depsgraph);
}

I think this code should probably be in DEG_evaluate_on_refresh and DEG_evaluate_on_framechange, or some lower level function. This is not the only place these functions are called.

In general we should ensure that writebacks are either always either cleared or flushed after evaluation. The pointers in those callbacks will become valid once further edits to the scene are made.

I think this code should probably be in `DEG_evaluate_on_refresh` and `DEG_evaluate_on_framechange`, or some lower level function. This is not the only place these functions are called. In general we should ensure that writebacks are either always either cleared or flushed after evaluation. The pointers in those callbacks will become valid once further edits to the scene are made.
Author
Member

I think this code should probably be in DEG_evaluate_on_refresh and DEG_evaluate_on_framechange, or some lower level function. This is not the only place these functions are called.

I'm not entirely sure about that. It feels weird that e.g. DEG_evaluate_on_refresh should calls something that causes the depsgraph to be tagged again. After calling DEG_evaluate_on_refresh, I'd expect DEG_is_fully_evaluated to return true.
It seems blender::deg::sync_writeback::run(*depsgraph); should be in the same function that contains the loop that evaluates the depsgraph again if necessary.

> I think this code should probably be in DEG_evaluate_on_refresh and DEG_evaluate_on_framechange, or some lower level function. This is not the only place these functions are called. I'm not entirely sure about that. It feels weird that e.g. `DEG_evaluate_on_refresh` should calls something that causes the depsgraph to be tagged again. After calling `DEG_evaluate_on_refresh`, I'd expect `DEG_is_fully_evaluated` to return true. It seems `blender::deg::sync_writeback::run(*depsgraph);` should be in the same function that contains the loop that evaluates the depsgraph again if necessary.
Author
Member

This is not the only place these functions are called.

I know, I was trying to be more explicit and on the conservative side, instead of introducing writebacks to original data in places that don't expect it and don't handle evaluating the depsgraph another time.

> This is not the only place these functions are called. I know, I was trying to be more explicit and on the conservative side, instead of introducing writebacks to original data in places that don't expect it and don't handle evaluating the depsgraph another time.

Maybe these functions can get a function argument to say if writebacks are wanted, that defaults to false. Then they don't accumulate for cases where we don't want them.

Maybe these functions can get a function argument to say if writebacks are wanted, that defaults to false. Then they don't accumulate for cases where we don't want them.
JacquesLucke marked this conversation as resolved
Jacques Lucke added 1 commit 2024-01-29 13:21:07 +01:00
Brecht Van Lommel requested changes 2024-01-29 13:46:52 +01:00
@ -0,0 +15,4 @@
void add(::Depsgraph &depsgraph, std::function<void()> fn)
{
deg::Depsgraph &deg_graph = reinterpret_cast<deg::Depsgraph &>(depsgraph);

This should only get called when the depsgraph is active. Either add an if here, or add it outside and use an assert.

This should only get called when the depsgraph is active. Either add an `if` here, or add it outside and use an assert.
JacquesLucke marked this conversation as resolved
Simon Thommes requested changes 2024-01-29 14:40:58 +01:00
Simon Thommes left a comment
Member

I had some back and forth with Jacques via chat, so here a brief summary:

I'm having some concerns with the way that is currently very easy to accumulate unnecessary pointers without them being automatically cleared when not needed anymore.

For the vast majority of use-cases where the user just bakes something locally in an isolated file, or maybe links the result to another file I would ideally expect to not have to care about this mapping at all. The problem is that since, another frame of the evaluation could depend on a datablock, you never truly know which ones are not needed anymore.

To alleviate this problem I proposed two things:

  • tie the content of the list much closer to what is actually used by the cache/bake by only adding items on evaluations that actually write to the cache/bake (simulation playback caching + bake button) and automatically clearing/rebuilding the list whenever the cache is cleared/bake is deleted
  • to avoid issues resulting from that by clearing data that might be use by another cache in the same modifier split the one list into lists that are tracked per bake

I also talked to @brecht about this who agreed that this should be as automatic as possible and was fine with the idea of splitting the list into one per bake. He did propose to keep it in one list, but rather track the bake ids referencing the datablock instead of splitting it up.

I had some back and forth with Jacques via chat, so here a brief summary: I'm having some concerns with the way that is currently very easy to accumulate unnecessary pointers without them being automatically cleared when not needed anymore. <video src="/attachments/3ec7f567-92fb-4c3c-ba8a-bf9eedd55285" title="geonodes_baking_datablocks-2024-01-29_12.53.14.mp4" controls></video> For the vast majority of use-cases where the user just bakes something locally in an isolated file, or maybe links the result to another file I would ideally expect to not have to care about this mapping at all. The problem is that since, another frame of the evaluation could depend on a datablock, you never truly know which ones are not needed anymore. To alleviate this problem I proposed two things: - tie the content of the list much closer to what is actually used by the cache/bake by only adding items on evaluations that actually write to the cache/bake (simulation playback caching + bake button) and automatically clearing/rebuilding the list whenever the cache is cleared/bake is deleted - to avoid issues resulting from that by clearing data that might be use by another cache in the same modifier split the one list into lists that are tracked per bake I also talked to @brecht about this who agreed that this should be as automatic as possible and was fine with the idea of splitting the list into one per bake. He did propose to keep it in one list, but rather track the bake ids referencing the datablock instead of splitting it up.
Jacques Lucke added 1 commit 2024-01-29 14:55:55 +01:00
Author
Member

He did propose to keep it in one list, but rather track the bake ids referencing the datablock instead of splitting it up.

It seems likely that eventually we need the ability to control this mapping on a per simulation-zone/bake-node/import-node, even if we generally want to be able to see things at a higher level. Therefore, it seems reasonable to have separate lists already, instead of referencing multiple bake ids per data block in the modifier.

> He did propose to keep it in one list, but rather track the bake ids referencing the datablock instead of splitting it up. It seems likely that eventually we need the ability to control this mapping on a per simulation-zone/bake-node/import-node, even if we generally want to be able to see things at a higher level. Therefore, it seems reasonable to have separate lists already, instead of referencing multiple bake ids per data block in the modifier.

Was checking some of those boring low-level parts of the PR, like the IO and depsgraph. Some immediate impression about the DEG part, which would be nice to dig a bit deeper.

With the current implementation it seems that the DEG is just a storage of callbacks which are registered during evaluation of the graph and are cleared at the end of evaluation, unless I am missing something. Other than the ease of access of depsgraph from the place where the callback is registered, what makes the DEG the proper place for such callbacks? Without deeper integration with the graph itself, it almost like better approach would be to pass some dedicated callback storage, via evaluation context, for example.

If the DEG is the proper place for storing such callbacks, I am not sure why DEG cares what exactly they do. Can't it be just "run this callback at a moment when ID is known to be fully evaluated", rather than be so specifically related on sync write-back from the API perspective?

Was checking some of those boring low-level parts of the PR, like the IO and depsgraph. Some immediate impression about the DEG part, which would be nice to dig a bit deeper. With the current implementation it seems that the DEG is just a storage of callbacks which are registered during evaluation of the graph and are cleared at the end of evaluation, unless I am missing something. Other than the ease of access of depsgraph from the place where the callback is registered, what makes the DEG the proper place for such callbacks? Without deeper integration with the graph itself, it almost like better approach would be to pass some dedicated callback storage, via evaluation context, for example. If the DEG is the proper place for storing such callbacks, I am not sure why DEG cares what exactly they do. Can't it be just "run this callback at a moment when ID is known to be fully evaluated", rather than be so specifically related on sync write-back from the API perspective?
Author
Member

With the current implementation it seems that the DEG is just a storage of callbacks which are registered during evaluation of the graph and are cleared at the end of evaluation, unless I am missing something.

That's right.

Other than the ease of access of depsgraph from the place where the callback is registered, what makes the DEG the proper place for such callbacks?

Originally, I used a separate Map<Depsgraph *, Vector<std::function<void()>> to store the callbacks per depsgraph and didn't integrate it with the depsgraph at all. Brecht suggested to put it on the depsgraph directly instead. It turned out to be more convenient, but obviously there are different options. Not sure how much it really matters in the end.

Without deeper integration with the graph itself, it almost like better approach would be to pass some dedicated callback storage, via evaluation context, for example.

Hm, we could, but not sure if that would actually improve things right now. Would mean that we have to pass more stuff to modifiers which in the end is just a list per depsgraph that you could also retrieve from the depsgraph without passing it separately.

If the DEG is the proper place for storing such callbacks, I am not sure why DEG cares what exactly they do.

The DEG doesn't really care what's happens in the callbacks. It's just some functions which modify original in a way that couldn't be done safely during depsgraph evaluation.

Can't it be just "run this callback at a moment when ID is known to be fully evaluated", rather than be so specifically related on sync write-back from the API perspective?

It's not enough to know that a specific ID is fully evaluated. It's not safe to run these callbacks in parallel, they might change arbitrary data-block user-counts, which are not atomic. So the "synchronous" aspect is quite important for thread-safety.

> With the current implementation it seems that the DEG is just a storage of callbacks which are registered during evaluation of the graph and are cleared at the end of evaluation, unless I am missing something. That's right. > Other than the ease of access of depsgraph from the place where the callback is registered, what makes the DEG the proper place for such callbacks? Originally, I used a separate `Map<Depsgraph *, Vector<std::function<void()>>` to store the callbacks per depsgraph and didn't integrate it with the depsgraph at all. Brecht suggested to put it on the depsgraph directly instead. It turned out to be more convenient, but obviously there are different options. Not sure how much it really matters in the end. > Without deeper integration with the graph itself, it almost like better approach would be to pass some dedicated callback storage, via evaluation context, for example. Hm, we could, but not sure if that would actually improve things right now. Would mean that we have to pass more stuff to modifiers which in the end is just a list per depsgraph that you could also retrieve from the depsgraph without passing it separately. > If the DEG is the proper place for storing such callbacks, I am not sure why DEG cares what exactly they do. The DEG doesn't really care what's happens in the callbacks. It's just some functions which modify original in a way that couldn't be done safely during depsgraph evaluation. > Can't it be just "run this callback at a moment when ID is known to be fully evaluated", rather than be so specifically related on sync write-back from the API perspective? It's not enough to know that a specific ID is fully evaluated. It's not safe to run these callbacks in parallel, they might change arbitrary data-block user-counts, which are not atomic. So the "synchronous" aspect is quite important for thread-safety.
Brecht Van Lommel approved these changes 2024-01-30 15:50:05 +01:00
Brecht Van Lommel left a comment
Owner

My comments were addressed, so LGTM from my side.

My comments were addressed, so LGTM from my side.

Ah, "sync" as in a short to "synchronous", not "synchronize".

But do you have strong opinions about that "writeback" part? Can we make it a "generic" callback which is run after DEG evaluation, in a synchronous manner, and leave the check for active DEG to the outside of the DEG code (kinda make it a mechanism similar to the Python's deg_update_post handlers) ?

Ah, "sync" as in a short to "synchronous", not "synchronize". But do you have strong opinions about that "writeback" part? Can we make it a "generic" callback which is run after DEG evaluation, in a synchronous manner, and leave the check for active DEG to the outside of the DEG code (kinda make it a mechanism similar to the Python's deg_update_post handlers) ?
Author
Member

Ah, "sync" as in a short to "synchronous", not "synchronize".

Right, should have made that more clear...

But do you have strong opinions about that "writeback" part? Can we make it a "generic" callback which is run after DEG evaluation, in a synchronous manner, and leave the check for active DEG to the outside of the DEG code (kinda make it a mechanism similar to the Python's deg_update_post handlers) ?

We could, but it feels like that would kind of revert the changes that Brecht suggested, so maybe you can briefly discuss this with him. Either way works for me tbh.

> Ah, "sync" as in a short to "synchronous", not "synchronize". Right, should have made that more clear... > But do you have strong opinions about that "writeback" part? Can we make it a "generic" callback which is run after DEG evaluation, in a synchronous manner, and leave the check for active DEG to the outside of the DEG code (kinda make it a mechanism similar to the Python's deg_update_post handlers) ? We could, but it feels like that would kind of revert the changes that Brecht suggested, so maybe you can briefly discuss this with him. Either way works for me tbh.
Jacques Lucke added 10 commits 2024-01-30 16:01:51 +01:00
Jacques Lucke added 10 commits 2024-01-30 18:28:52 +01:00

We could, but it feels like that would kind of revert the changes that Brecht suggested, so maybe you can briefly discuss this with him. Either way works for me tbh.

That is interesting.
We had a quick discussion about it, and it is one of those "i'd do it differently" but ultimately, since the code is already done lets just roll with it, and adjust when/if we need to. Will make it more practical moving forward with this project.

> We could, but it feels like that would kind of revert the changes that Brecht suggested, so maybe you can briefly discuss this with him. Either way works for me tbh. That is interesting. We had a quick discussion about it, and it is one of those "i'd do it differently" but ultimately, since the code is already done lets just roll with it, and adjust when/if we need to. Will make it more practical moving forward with this project.
Jacques Lucke added 1 commit 2024-01-31 12:38:39 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
aa4b938a10
Merge branch 'main' into bake-data-block-map
Author
Member

@blender-bot build

@blender-bot build
Simon Thommes approved these changes 2024-01-31 12:47:43 +01:00
Simon Thommes left a comment
Member

From user side this is good to go for me!

Tested everything as rigorously as I could think of and this seems to hold up well against trying to break it without the user actually needing to actively use the panel.

From user side this is good to go for me! Tested everything as rigorously as I could think of and this seems to hold up well against trying to break it without the user actually needing to actively use the panel.
Hans Goudey approved these changes 2024-01-31 15:40:24 +01:00
@ -0,0 +20,4 @@
namespace blender::bke::bake {
/**
* Maps #BakeDataBlockID to the corresponding data-block. This is used during depsgraph evaluation
Member

data-block -> data-blocks

`data-block` -> `data-blocks`
JacquesLucke marked this conversation as resolved
@ -1492,0 +1495,4 @@
{
ID *id;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (!STREQ(id->name + 2, name)) {
Member

Seems a bit clearer to use ListBase *lb = which_libbase(bmain, type);

Seems a bit clearer to use ` ListBase *lb = which_libbase(bmain, type);`
Author
Member

Looks like you added that comment before the most recent changes.

Looks like you added that comment before the most recent changes.
JacquesLucke marked this conversation as resolved
@ -616,0 +660,4 @@
void draw_data_blocks(const bContext *C, uiLayout *layout, PointerRNA &bake_rna)
{
static uiListType *data_block_list = []() {
Member

const uiListType *

`const uiListType *`
JacquesLucke marked this conversation as resolved
Hans Goudey approved these changes 2024-01-31 15:48:41 +01:00
Jacques Lucke added 2 commits 2024-02-01 09:16:07 +01:00
Jacques Lucke merged commit 2d2b087fcf into main 2024-02-01 09:22:04 +01:00
Jacques Lucke deleted branch bake-data-block-map 2024-02-01 09:22:08 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117043
No description provided.