jhh1198 Posted July 4, 2017 Share Posted July 4, 2017 Hello, everyone. I've been playing around a lot with Pixi.js trying to find the best ways for memory optimization. Using Pixi's loader, I load my images. Some images are very large and for the first time creating and adding them to the stage, my game freezes for a moment. After reading around, I realized that freeze is Pixi uploading the texture to the GPU. Now, my question is, would it be ideal to add in a method to pixi's loader that after the texture loads, it uploads it to the GPU? That would stop the brief freeze. I have already used Pixi's built in method to upload to the GPU and the freeze is gone. What would be the pros and cons of doing this for every texture loaded? Thank you! Quote Link to comment Share on other sites More sharing options...
Exca Posted July 4, 2017 Share Posted July 4, 2017 If you know that you will use all your textures always and that they can fit into gpu then it is very valid strategy to upload everything. Having that embedded in the loader on the other hand I think is not good. As many projects use a lot of textures but they might have for example different textures for different levels and uploading all of them might take too much memory. I have currently a custom wrapper that does all of the loading and when loader is ready, it goes through all the resources and uploads those files that are marked to be uploaded, which in most cases where I use pixi is everything. Quote Link to comment Share on other sites More sharing options...
megmut Posted July 4, 2017 Share Posted July 4, 2017 I don't know if you are aware of this, but there is a plugin on PIXI. The namespace is PIXI.prepare, and the method, upload. I use this sometimes when preparing states and making sure all the assets are correctly on the GPU memory. You can see more here as well as an example: http://pixijs.download/release/docs/PIXI.prepare.html jhh1198 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 4, 2017 Share Posted July 4, 2017 I feel like we need big article on that problem. Its one of most common problems and even I don't understand what happens there completely. Quote Link to comment Share on other sites More sharing options...
jhh1198 Posted July 4, 2017 Author Share Posted July 4, 2017 Thank you for your help, guys! I have already created a "states" like wrapper for Pixi so that I can upload and unload images for specific levels. I looked at Phaser's source to see how they did it. I think as long as I'm keeping track of the textures in the GPU and removing them when not used, everything should be good. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.