This is part of T79131
Details
Diff Detail
- Repository
- rB Blender
- Branch
- cycles_device_info_node (branched from master)
- Build Status
Buildable 10296 Build 10296: arc lint + arc unit
Event Timeline
The problem is that basically all these sockets are read-only, and that API users can't simply create a DeviceInfo by themselves. There is a list of devices provided and then a choice from that can be made.
I think probably DeviceInfo should not be what we have as nodes. Rather there could be a new class (e.g. RenderDevice or something), which has just the device type and ID. And then finding the corresponding DeviceInfo would be up to the session.
Does that make sense?
SessionParams now holds an array of RenderDevices to account for multi-device setups. This array holds pointers to RenderDevice as it has to be a socket, and we only support sockets of arrays to Node pointers.
The Session constructor takes the array of RenderDevice and constructs a DeviceInfo from it which is then used to create the actual Device.
The logic to construct the DeviceInfo is similar to that of blender_device_info, although it has to work a RenderDevice array. Hopefully the logic is similar and works for all cases, it seems to work fine for the limited set of devices that I personnaly own.
Because we allocate RenderDevice objects on the heap, we would have to use create_node instead (the Session could own those nodes), but first I want to check that this is indeed the right path.
For now, the RenderDevice Node is located in the session.h/cpp files, but could be moved elsewhere more appropriate.
Because of this refactor, DeviceInfo::has_peer_memory is not set anymore in the Blender exporter, not sure how to properly introduce it back.
Modified TileManager to have a setter for the number of devices as it is no longer possible to pass this information to its constructor while constructing a Session.
Use a RenderDevice Node to define which devices to use. SessionParams has now an array of RenderDevice nodes built using the Cycles preferences. This array is turned into a DeviceInfo in the Session constructor, which then uses it to create a Device.
The main problem I am facing with this node/patch is that the devices are in SessionParams, which is also being made into a Node (D8751, which depends on this patch). SessionParams has the devices as a socket and this forces us to have pointers to the Nodes.
To get pointers we can either allocate on the heap, or take pointers to values stored somewhere safe (where the pointer is not going to change). I am using allocating to be extra safe.
However, we decided Nodes should be allocated using some create_node and delete_node methods also defining the owners. But when creating such nodes, nothing is valid to be an owner (neither the Scene, nor the Session, is already created). We also have to make sure that pointers are stable when recreating the SessionParams to check whether or not the requested devices have changed, otherwise we can't get stuck in some infinite Session/Scene recreation loop.
Finally, the Denoiser also requires some Device which is also created from RenderDevice Nodes now, and this doesn't have a Session or a Scene, so no one can own or create those Nodes.
The solution I came up with, was to have a global cache to store those nodes and go through static methods on Session to create them, which also ensures pointer stability. Care must be taken to decide when to delete them. This is not ideal, IMO, but I am short of ideas.