kakashidinho/metalangle

Multiple Render Targets support

JustFreePirate opened this issue · 6 comments

Hi!

On the main page it says that multiple render targets are supported, but I when I tried to render to a framebuffer with 4 RGAB32F draw buffers I got this error:
-[MTLRenderPipelineDescriptorInternal validateWithDevice:]:2623: failed assertion `This set of render targets requires 64 bytes of pixel storage. This device supports 16 bytes.'

I tested it on iPad Air with Apple A7 (OS 12.4.9 (16H5)) with using OpenGL ES 3.0 on MetalANGLE.
I looked up the Metal Feature Set Table (https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf) for this chip and found out that it supports only 128bit of maximum total render target size, per pixel, when using multiple color render targets.
So I assume that it does not support natively 4 render targets with RGBA32F format, it can only handle up to 4 render targets with RGBA8 format.

As far as I know, there are no such thing as "maximum total render target size, per pixel, when using multiple color render targets" in OpenGL ES spec. So there is no way to fully support multiple render targets for all texture formats, or am I missing something?

Yes, unfortunately, I overlooked this Metal's limitation on older GPUs. If you want to use 4 RGBA32F render targets, you need to use Apple GPU Family 4 and later (iPhone X+).
This limitation actually doesn't really violate OpenGL ES 3.0 spec. Because by default, GL_RGAB32F is not mandated to be color renderable on all devices (you can view the list of color renderable formats' reference here https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexStorage2D.xhtml)

Actually, I took a look again, GL_RGAB32F is not mandated to be renderable but GL_RGAB32UI is, and MetalANGLE probably won't support 4 render targets of GL_RGAB32UI on Apple A7 due to pixel storage limit as you mentioned. So yeah, On older devices, MetalANGLE is not fully compliant. I could just limit the GLES 3.0 to GPU family 4 and later but decided to enable it for every device, because the other GLES 3.0 features are still useful for general use cases (3D, array, R/G textures, etc).

Are you trying to implement deferred rendering? I think traditional deferred rendering doesn't perform well on mobile GPUs. I would try to implement frame buffer fetch extension in future to allow in-tile memory version of deferred rendering as mentioned here https://community.arm.com/developer/tools-software/graphics/b/blog/posts/deferred-shading-on-mobile

Thank you for your response!

Now it is all clear to me. Just wanted to be sure.
Can you posibly mention that multiple render targets are not 100% supported on the main page? I think it could help other people not to get this problem

I am using MRT for GPU particles

Done.