s1ddok/Alloy

How to use MTLOffscreenRenderer?

rostopira opened this issue · 3 comments

I want to use MTLOffscreenRenderer to produce CVPixelBuffer
I've tried to copy bytes from it's texture using getBytes, but no luck
Also texture.bufferBytesPerRow returns zero
Could you add a little example?
Thanks in advance

are you getting error or all pixels are black? can you share the sample code you try to use? I could guide you on what's wrong with the usage

if you are getting runtime error, make sure you use MTLTexture with shared storage mode for offscreen rendering.

You may also be interested in convenient MTLTexture <> CVPixelBuffer conversion code in Alloy

I've found out that the issue in pixel format I've used
It's unrelated to the library, so I've asked question on SO and closing the issue
In case you can take a look, here it is: https://stackoverflow.com/questions/66578837/fragment-shader-return-type-for-bgra8unorm-pixel-format