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.
@2084megabot Thanks very much for your question!
The best that I could come with unfortunately is the Apple documentation here.
I do apologize if it is something you are already familiar with, or not relevant to your question.
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?
@syedfa Do you think I should post this in
Metal by Tutorials instead? While it doesn’t directly pertain to the book it may be more relevant in that section.
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
This topic was automatically closed after 166 days. New replies are no longer allowed.