On Macs with discrete graphics cards, Managed buffers should be used instead of Shared Buffers, however there are additional requirements to maintain synchronisation using [MTLBuffer:didModifyRange:].
However on Apple Silicon, if I force the use of Managed buffers by pretending [MTLDevice hasUnifiedMemory] returns NO
, and removing calls to didModifyRange:
, then the rendering is working just fine.
What’s the best way to test Managed buffers on Apple Silicon where the GPU memory is unified so that I can be sure my code will work on older Macs?
2
Answers
The best practice for testing hardware compatibility is on the actual hardware in which you are testing compatibility. If you plan on supporting discrete GPUs, which are substantially different from Apple Silicon, it would be best to have access to one for testing.
You might approximate behavior, but remember that it is only a emulation, and there is no way to ensure that the actual hardware will work the same.
It would be akin to developing with the Simulator only, which is not at all a good practice.
UPDATE: There are numerous services that rent access to bare metal Macs. The MacInCloud service allows you to configure a machine with an external GPU (such as a AMD RX 580). It is only $0.99 for the first 24 hours.
There are many similar services out there, but that is the first service I was able to verify that discrete GPUs are an option.
In my experience, there is no best practice to test code when it comes to rendering api’s, since there are many different factors here:
GPU and CPU vendors (Apple, AMD, Intel), operating systems, drivers.
I agree with Jeshua:
There are many useful ways that can make development and testing easier:
You can detect vendors id:
With following method you can find your gpu type:
Note:
Determine TBDR GPU architecture:
Understand the Managed Mode:
Behaves like
MTLStorageModeShared
, has only one copy of content.Note:
You can also check some implementations by other developers:
PixarAnimationStudios/USD:
KhronosGroup/MoltenVK