I have been working with Metal for a little while now and I have encountered the threadgroup address space. After reading a little about it in Apple’s MSL reference, I am aware of how thread groups are formed and how they can be split into SIMD groups; however, I have not yet seen threadgroup memory in action. Can someone give me some examples of when/how threadgroup memory is used?
Specifically, how is the [[threadgroup(n)]] attribute used in both kernel and fragment shaders? References to WWDC videos, articles, and/or other resources would be appreciated.
Hi thank you for your response. I have looked through this document already; it covers how to locate threads within SIMD groups and threadgroups and how to locate threads and threadgroupds within a grid. I am looking for Metal shader code (MSL) that uses threadgroup memory within the shader as well as the API calls so that I can start to take advantage of what is in the document. For instance, how could I use [[threadgroup_position_in_grid]]? I presume it involves indexing into buffers, but which ones and how do I set them up?
I have found some WWDC videos that pertain to the use of the [[threadgroup(n)]] attribute, viz. the video sequence of “Metal 2 on A11” where the attribute is used for tile shaders. There is also source code available but it is all written in Objective-C (sigh). I’m learning Objective-C currently so that I can read through those projects as well as legacy code. My Swift knowledge has guided me through some of them and I have made some progress, but I am still looking for other concrete examples.
If anyone has any more resources on tiled rendering, image blocks, tile memory, etc. please do share