Jump to content

Environment.SourceImage and GPU memory use? 🤔

Recommended Posts

        // Summary:
        //     Gets the source image to use with Direct2D.
        // Remarks:
        //     You should only retrieve this image if it will actually be used for rendering,
        //     as it will consume GPU memory once initialized.
        //     This is equivalent to:
        //     this.Environment.Document.Layers[this.Environment.SourceLayerIndex].Image


Should I be concerned about this? If I want to pass the current layer into a shader, is this the right way to get it, or is there some other, better way?


SrgbToLinearEffect background = new(dc);


Edited by Robot Graffiti
Link to comment
Share on other sites

That's exactly how you use it :) 


Where you mostly need to be concerned is when you're using multiple layer images from this.Environment.Document.Layers[i].Image. You shouldn't grab all of the layer images, you should only grab exactly the layer images you need for rendering based on the property values in the token (from the UI). If an image only has a few layers, it's probably not a big deal. But if the image has 100 layers (which is not uncommon), you might run into trouble.

  • Like 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html


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.

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.

  • Create New...