FramebuffferWidget

I notice I should be using these more to minimize unnecessary drawing overhead, but have some questions.

When should you use a frame buffer? Any time a widget or panel has overridden draw()?

How much does it matter? If you draw just does a filled rectangle, is it worth bothering with?

Are there any tricky ways to measure the overhead of drawing, other than instrumenting individual draw functions?

1 Like

you should use the FBW if you do heavy computing to do drawing
(or you do very intricate drawings that donā€™t need frequent refresh)

the overhead is the blitting of the full surface happening at the of the drawing

with mac instrumentation you can measure the full UI thread and going in particular the single draw calls, if needed

in your case a timer measuring the draw should be enough

still I was unable to do a triplebuffer tecnique (til version 0.6 I was still unable to blit an offscreen on top of another offscreen with offset to do image compositions)

I have the same question. I ended up running Instruments on a Mac and saw that, sure enough, constant redraws showed up as substantial slices of the CPU.

But, it looks like with scaling and so forth, FramebufferWidget isnā€™t free (as far as I can tell it allocates 16x the size of the thing it buffers; doubled once for subsampling; doubled again because Iā€™m running on a 4K display). I restructured my code to dirty FramebufferWidget when something needs to be redrawn, and nearly all overridden widgets are backed one.

I wish that there was a way to mark non-FramebufferWidget widgets as dirty, so that they would only get drawn as needed or when the area is invalidated.

If your screen DPI ratio is 2, its oversampling ratio is set to 1, so it should allocate 1x the size of the thing it buffers. No downscaling is needed after drawing. If your DPI ratio is 1, then it would oversample by 2 and then downscale to pixel-perfect in world coordinates.

Then the widget would ā€œflickerā€ as it would only be drawn every time it changes and would be invisible in all other frames.

The ā€˜doubling twiceā€™ was observed by stepping through VCV in the debugger. Both x and y used by FramebufferWidget are 4x the size of child. The zoom factor was set to 100%. I can provide more specifics if that is helpful.

Sure, go ahead

How do you run instruments on your plugin? Can instruments attach to a running instance of VCV? Or do you have to make an xcode project to do it?

Yes, just attach to the Rack process. It should be pretty easy to find your pluginā€™s callstack if you havenā€™t stripped symbols.

yeah, Iā€™ve used the debugger that way, but never Instruments.