Please help me understand how tiles work in Cycles

I would appreceiate some help in understanding how tiles work in Cycles.

What I know so far:
I figured out that they are managed by the class “TileManager” in /render/tile.h and that the session in /render/session.h owns the TileManager.

I also understand that tiles are generated in the method “gen_tiles” in /render/tile.cpp and how that logic works.

What I cant seem to wrap my head around is how the render logic interacts with the tiles. When I step through the code in debug mode, the render logic and tile generation seem to be in different, indipendent call stacks. How does the rendering logic access the generated tiles? Does every thread get one tile that it then renders? If so, where in the code does that happen?

What I want to do is manipulate the logic in a way so that I can determine only certain tiles to be rendered.
I managed to achieve that by changing the code in the “gen_tiles” method, but I lack the information I need to determine which tiles I want to render there. So I need to understand how the render logic accesses the tiles.

I would greatly appreciate some pointers in the right direction. Classes, Lines in the code or something similar.

The devices and their threads call Session::acquire_tile to get a tile to render, which calls tile_manager.next_tile.


Ok thank you, i will have a look at that.