How is a theme template file picked up? Does any one know how Drupal 8 picks up theme template file? I mean in source code.

I have module which use a custom template file for a custom block , but the custom template file was not been picked up.

I have tried many different ways, but none working, so I have decided to looking Drupal 8 source code to find out , but I am unable to find out exact source code that picks up the theme template file.
I had a similar problem and tried:

{% include 'my-template.html.twig' %}
{% include directory ~ '/templates/my-template.html.twig' %}


but ThemeRegistryLoader wouldn't recognize 'my-template'. This syntax worked:

{% include 'modules/custom/my_module/templates/my-template.html.twig' %}