It renders as expected. However your texture background's is black just like your text colour. Because CGContext is premultiplying alpha.
If you change the context's background to red for example, you will see it.
CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast|kCGImageByteOrder32Big);
CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);
CGContextFillRect(context, CGRectMake(0, 0, width, height));
To bypass CGContext all together, try rendering directly to an MTLTexture using CIContext's render(_: to: commandBuffer: bounds: colorSpace:), you can find more info here: Apple Developer Doc
Topic:
Graphics & Games
SubTopic:
General
Tags: