MTLTextureDescriptor* desc = [MTLTextureDescriptor new];
desc.usage = MTLTextureUsageRenderTarget | MTLTextureUsagePixelFormatView;
desc.pixelFormat = MTLPixelFormatRGBA8Unorm;
desc.width = (NSUInteger)m_width;
desc.height = (NSUInteger)m_height;
desc.textureType = MTLTextureType2D;
id<MTLDevice> device = static_cast<id<MTLDevice>>(mtlContext.fDevice.get());
m_surfaceTexture = [device newTextureWithDescriptor:desc];
info.fTexture = sk_cfp<const void*>(m_surfaceTexture);
GrBackendRenderTarget target(m_width, m_height, info);
m_gpuSurface = (SkSurface::MakeFromBackendRenderTarget(m_grContext.get(), target, kBottomLeft_GrSurfaceOrigin, colorType, nullptr, &props));
Notice that the texture format that I use here is "MTLPixelFormatRGBA8Unorm", I want to use "MTLPixelFormatBGRA8Unorm", but apparently that is not supported and returns a NULL surface. "MTLPixelFormatRGBA8Unorm" is not supported by the CAMetalLayer, so my CAMetalLayer still remains on "MTLPixelFormatBGRA8Unorm". So, once the skia rendering is over I have to take this new texture I created and use a simple rendering pipeline to swap the colour channels. Is there a better way to do this?
I see a similar "SkSurface::MakeFromCAMetalLayer", as I understand, it takes the drawable during initialisation, extracts it's texture and directly renders on it. But I do not see a way that I can reuse the same surface across multiple frames since this does not query the "nextDrawable" during consecutive draws. Also, as I remember Apple suggests holding "CAMetalDrawable" instances for the lowest possible time, if we are going to hold a drawable through out the render phase, I believe this should negatively impact performance.
Is there something missing in my understanding? Does skia have any inbuilt functionality that can show the rendered texture on the screen? Is there a better way to do it?
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/414258df-ffb0-4266-972f-e01ca2a6effan%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CAHOuermMdwu-7RBNNMLQ_rEoMLPO_7gSL3Y5hC%3Ds-Tz6TcmL0g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/bd68dd3e-67aa-4735-8b4c-97c748bf6cd8n%40googlegroups.com.