At this point - (id) createMTLTextureFromGLTexture:(Texture *) tex looks to be hacked to death.
The work should be done in the GL side to get this format correct, there is just too much work going on in createMTLTextureFromGLTexture to get it right.
The GL framework should query the Metal side if a texture can be created with the parameters given, if it fails it should inform the GL framework to create a backing of the correct format that will allow createMTLTextureFromGLTexture to work correctly and not fail.
Calls to Metal should be simple and not expected to fail, its the job of the framework to provide a texture even if it has to create an additional backing store to get the data in the right format for Metal.
At this point - (id) createMTLTextureFromGLTexture:(Texture *) tex looks to be hacked to death.
The work should be done in the GL side to get this format correct, there is just too much work going on in createMTLTextureFromGLTexture to get it right.
The GL framework should query the Metal side if a texture can be created with the parameters given, if it fails it should inform the GL framework to create a backing of the correct format that will allow createMTLTextureFromGLTexture to work correctly and not fail.
Calls to Metal should be simple and not expected to fail, its the job of the framework to provide a texture even if it has to create an additional backing store to get the data in the right format for Metal.