Jump to content

Uploading texture to GPU after loading


jhh1198
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...