How to create a perspective transform using Metal

I have a quad made up of two triangles rendered using indexed primitives. How can I create a transform where only one corner of the quad is stretched, like the perspective tool in most drawing apps?

For example:

The only idea that comes to my mind (without knowing the actual transform to do, since it's definitely not uniform) would be to try to use CIPerspectiveTransform.

Thank you! I didn't realize there was a core image filter for this - it works out perfectly!

How to create a perspective transform using Metal
 
 
Q