Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pixelFormat failed assertion ONLY when running on simulators #68

Open
lirbar opened this issue Nov 15, 2021 · 5 comments
Open

pixelFormat failed assertion ONLY when running on simulators #68

lirbar opened this issue Nov 15, 2021 · 5 comments

Comments

@lirbar
Copy link

lirbar commented Nov 15, 2021

MetalAngle is amazing work. Thank you so much Le Hoang Quyen!

We integrated MetalAngle and everything works great when running on devices. Tested on 15.1 of iOS, iPadOS, tvOS and macOS (using Mac Catalyst).

But when running on all corresponding simulators, we get the following error:
MTLDebugValidateMTLPixelFormat:1433: failed assertion `pixelFormat (40) is not a valid MTLPixelFormat.'

on the first run of the following line:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _scalingTextureWidth, _scalingTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0); printOpenGLError();

We get The following similar error:
MTLDebugValidateMTLPixelFormat:1433: failed assertion `pixelFormat (41) is not a valid MTLPixelFormat.

On the following line:
GLCALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GL_DYNAMIC_TEXTURE_WIDTH, GL_DYNAMIC_TEXTURE_WIDTH, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, dynamicTexturePixels));

As mentioned, these are ONLY when running on simulators.

@kakashidinho
Copy link
Owner

It looks like simulator doesn’t natively support 16 bits rgb format. I didn’t notice this before.
Will have to do some 16->32 bits fallbacks for simulator.
In the meantime you could try to use 32 bits rgb format if you detect you are on simulator as a workaround for now.

@lirbar
Copy link
Author

lirbar commented Nov 16, 2021

Thanks!
Is it a lot of work on your side ? Do you expect to have time for this in the near future ?

I am asking since I am not familiar enough with OpenGL/Metal code to do what you wrote.
Replacing GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_SHORT_5_5_5_1 with
GL_UNSIGNED_BYTE does produce an image - but the colors are all bad.

@kakashidinho
Copy link
Owner

Yes, It would require some works.

btw, if you change the type to GL_UNSIGNED_BYTE , you need to make sure input pixels (e.g. dynamicTexturePixels) are in 32 bits RGB/RGBA format as well.

@lirbar
Copy link
Author

lirbar commented Nov 17, 2021

Thank! Hope you will find the time for this one...

Do you mean I should do the following conversion to my 16bit input pixels ?
https://stackoverflow.com/a/8579650/14139949

@kakashidinho
Copy link
Owner

Thank! Hope you will find the time for this one...

Do you mean I should do the following conversion to my 16bit input pixels ? https://stackoverflow.com/a/8579650/14139949

Yes, normally MetalANGLE should do the conversion for you if the format fallback is implemented. However, it is not implemented yet for simulator. As a workaround for now, you could do it yourself on application layer (before passing to MetalANGLE's GL function)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants