Jump to content

Can someone give me some advices? - slow rendering


pdn
 Share

Recommended Posts

Can someone help with my project? I am trying to make a gradient blur plugin something like that, but I just can't make it faster. Do anyone have advices for me? I am using the pdn internal Gaussian Blur kernel. See the attached project.

Link to comment
Share on other sites

Remember that Render is called multiple times with many different arguments throughout the entire rendering process. You need to precalculate your surface so that you only calculate the path blur it on the first call of the render loop (after your dialog properties have changed). Also remember that this function can be called simultaneously on multiple threads, and there's usually no good way around that (by which I mean the workarounds tend to have more caveats than they're worth).

~~

Link to comment
Share on other sites

As a get{} process for a public variable (with a private version solely for caching purposes), i.e.:

private Surface _Dataz = new Surface;
public Surface Dataz // Readonly, public variable; private _Dataz is read/writable.
{
   get
   {
       if (NeedToRecalculate) // Where NeedToRecalculate represents a boolean value of whether or not we should recalculate;
                              // i.e., if our EffectConfigToken has changed--and you need to set this NeedToRecalculate inside 
                              // the render loop to ensure that the ConfigToken values are pertinent.
       {
           // Calculate your surface, store it to _Dataz and return the Surface.
           // Be sure to use _Dataz as your surface when calculating this, as you will double your memory otherwise
       }
       else return _Dataz;
   }
}

And it's your job to figure out how to do this in VB.NET ;)

~~

Link to comment
Share on other sites

I have found a easy way to advoid the rendering process to be multi-threaded, I simply add "SingleThreaded" in the "Sub New":

Public Sub New()
   	MyBase.New(StaticName, StaticIcon, StaticSubMenuName, Effects.EffectFlags.Configurable Or Effects.EffectFlags.SingleThreaded)
End Sub

It really works!

Link to comment
Share on other sites

Or you could just put the one-time calculation stuff in OnSetRenderInfo. Using single-threaded mode is not going to help your performance problems in the least. On my system, your plugin would now be up to 6x slower!

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

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

forumSig_bmwE60.jpg

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.

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.

 Share

×
×
  • Create New...