-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Fix for incorrect bits per pixel set on texture reload #2138
Conversation
Note this may not be the right fix it the intention is to actually use
Which ends up here:
The problem may be in Looking into this some more to try and figure out why it's happening, since forcing |
The true problem seems to have something to do with the When the FPS texture is first created using pixel format |
The problem has been traced to this method:
The
The Cocos2d-x implementation was this, which never changed the value of the
@halx99 How should this be solved? Should we just use
or alternatively, avoid setting it if it is already has a valid value (greater than 0, and less or equal to 32):
|
I've used this as the fix now, unless there are better suggestions:
This will preserve a valid |
This doesn't seem right, why |
I'm not sure why the code was changed from the Cocos2d-x implementation, which never adjusted those values. If floating point texture can have a more than 32 bits, then I'll change the conditional to simply check for 0. |
better solution is clamp width, height, bitsPerPexel at TextureBackend::updateTextureDescriptor, and don't modify them in initWithZeros |
That can be done, but I'm concerned about this "FIXME" comment in the code:
Is this what you were thinking:
and
|
The comment should be |
correct |
Why is this clamping necessary? Shouldn't these be asserts, since If you have a texture with 0 width, height or bits per pixel, then I'm certain it's a bug? |
Move width, height and bitsperpixel clamping
I'm not sure if it needs to be called on the context loss either. By the way, would you mind if I make the following change too:
|
sure, but please use |
) * Set pixel format of cached FPS texture to correct value * Do not change _bitsPerPixel if it is a valid value * Only set _bitsPerPixel if it is the default value of 0 * Assert that size is not equal to 0 Move width, height and bitsperpixel clamping * Deprecate findVolotileTexture and replace with getOrAddVolatileTexture. * Add missing static specifier * Replace calls to findVolotileTexture with getOrAddVolatileTexture
) * Set pixel format of cached FPS texture to correct value * Do not change _bitsPerPixel if it is a valid value * Only set _bitsPerPixel if it is the default value of 0 * Assert that size is not equal to 0 Move width, height and bitsperpixel clamping * Deprecate findVolotileTexture and replace with getOrAddVolatileTexture. * Add missing static specifier * Replace calls to findVolotileTexture with getOrAddVolatileTexture
Describe your changes
The pixel format of the FPS texture was being set incorrectly, which ended up crashing Android applications after attempting to recover from a GL context loss.The change made simply fixes the pixel format of that texture entry in the texture cache.The true cause of the issue was the bits per pixel setting of the cached texture being overwritten during recovery from the GL context loss.
Issue ticket number and link
#2126
Checklist before requesting a review
For each PR
Add Copyright if it missed:
-
"Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."
I have performed a self-review of my code.
Optional:
For core/new feature PR