-
Notifications
You must be signed in to change notification settings - Fork 6
Allow VRAM/GPU Loading for desktop target #5
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
base: mobile/main
Are you sure you want to change the base?
Conversation
Why not just use the
Maybe I'm missing something? |
Here's the snippet from the branch where I was experimenting with this functionality: trace('Uploading bitmap data to GPU... ${bitmapData?.image?.premultiplied}');
// Retrieve the render context.
var context:Context3D = FlxG.stage.context3D;
// Create a new texture object using the render context.
var texture:Texture = context.createTexture(bitmapData.width, bitmapData.height, Context3DTextureFormat.BGRA, optimizeForRender);
// TODO: Figure out how to use texture.uploadCompressedTextureFromByteArray to save GPU memory?
// Upload the texture to the GPU.
// This is an expensive operation so don't do it in the UI thread if you can help it.
texture.uploadFromBitmapData(bitmapData);
// Now that the texture is uploaded, the `Texture` object is all we need to render it in-game.
// We can dispose of the BitmapData object now.
bitmapData.dispose();
bitmapData.disposeImage();
// Build a new, optimized BitmapData object using the Texture object.
var output:BitmapData = BitmapData.fromTexture(texture);
return output; Note that this takes the bitmap data (which has already been loaded into memory from the disk), then creates a NEW texture, uploads the bitmap data to it, then creates a new BitmapData from that texture. It looks like PurSnake's approach is trying to remove the BitmapData from the existing Bitmap so you don't have to swap to a new BitmapData like I was doing here. |
Also, important: It would be prudent to make the same pull request to the upstream |
Co-Authored-By: Mihai Alexandru <[email protected]>
Adds ability to load bitmapdata via vram :steamhappy:
But only for desktop targets
Also its part of that Funkin PR