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

Remove Material texture cache #2850

Merged
merged 2 commits into from
Jun 30, 2015
Merged

Remove Material texture cache #2850

merged 2 commits into from
Jun 30, 2015

Conversation

mramato
Copy link
Contributor

@mramato mramato commented Jun 30, 2015

The Material texture cache caused many more problems than it solved, so this removes it until a complete solution can be found.

This fix exposed several bad tests that were actually using the default texture instead of waiting for an image material uniform to load. These tests have been fixed.

This fix also exposed another bug as well, which caused a material rendered with the default texture and then destroyed to end up destroying the default texture. Since textures are not reference counted, I simply added an isDefault flag for now and had Material.destroy only destroy the texture if it was not the default texture.

This PR supercesedes #2843 and #2633. Also fixes #2821

The Material texture cache caused many more problems than it solved, so
this removes it until a complete solution can be found.

This fix exposed several bad tests that were actually using the default
texture instead of waiting for an image material uniform to load.  These
tests have been fixed.

This fix also exposed another bug as well, which caused a material
rendered with the default texture and then destroyed to end up destroying
the default texture.  Since textures are not reference counted, I simply
added an `isDefault` flag for now and had Material.destroy only destroy
the texture if it was not the default texture.
@@ -148,6 +148,7 @@ define([
this._preMultiplyAlpha = preMultiplyAlpha;
this._flipY = flipY;
this._sampler = undefined;
this.isDefault = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of polluting Texture and Context with this, can this be handled all in Material?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way to avoid everyone having to handle it differently, but since Material is the only thing using defaultTexture right now, yes we can handle it all in Material.

Cache the default texture and use reference comparison to avoid
destroying it.
@mramato
Copy link
Contributor Author

mramato commented Jun 30, 2015

Ready for another look.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jun 30, 2015

Thanks.

pjcozzi added a commit that referenced this pull request Jun 30, 2015
…exture-cache

Remove Material texture cache
@pjcozzi pjcozzi merged commit 385da3b into master Jun 30, 2015
@pjcozzi pjcozzi deleted the remove-material-texture-cache branch June 30, 2015 21:56
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

Successfully merging this pull request may close these issues.

Entity canvas materials don't behave as expected
2 participants