Graphics optimisation

Due to the amount of recent moaning about the speed of drawing vertical lines, etc, I did a quick bit of profiling and found a good optimisation I could make. It should speed up some of the slower ops by several times - let me know if it helps!

Cool, nice and snappy. Also, the Mac project is super-clean now, only one warning. If you change the Mac camera code, line 387:

It builds 100% clean.

This fix, or possibly the Mac magnifier fix solved some visual trails I was getting with a magnifiercomponent (probably just at odd mag ratios) mostly. There’s still a half-transparent 1-pixel line left behind drags sometimes.

(This didn’t fully solve my magnifier problem, FYI. I’m still trying to pin it down)

Bruce

Thanks. The magnifier is really best at integer magnification factors, I wouldn’t be at all surprised if there were slight inaccuracies at fractional ones.

Hmm. If I go to the juce demo, and select Tiled RGB, crank the scale up to full, the whole computer bogs right down. If I enable rotate animation, you can see it redrawing in bursts.The draw time becomes unreliable - it rarely updates itself.

Would you regard that as ‘normal’? Shouldn’t culling remove most data and make it a fairly simple scale? The Tiled ARGB doesn’t have the same problem.

Bruce

[quote=“Bruce Wheaton”]Hmm. If I go to the juce demo, and select Tiled RGB, crank the scale up to full, the whole computer bogs right down. If I enable rotate animation, you can see it redrawing in bursts.The draw time becomes unreliable - it rarely updates itself.

Would you regard that as ‘normal’? Shouldn’t culling remove most data and make it a fairly simple scale? The Tiled ARGB doesn’t have the same problem.

Bruce[/quote]

I checked out the latest and tested with my screen-full vertical line. The release version is much better. Thanks.

[quote]Hmm. If I go to the juce demo, and select Tiled RGB, crank the scale up to full, the whole computer bogs right down. If I enable rotate animation, you can see it redrawing in bursts.The draw time becomes unreliable - it rarely updates itself.

Would you regard that as ‘normal’? Shouldn’t culling remove most data and make it a fairly simple scale? The Tiled ARGB doesn’t have the same problem.[/quote]

Is this on the mac or PC? Trying it in my PC virtual machine, the render time stays pretty constant regardless of what scale I set it to…

It’s a MacBook Pro, 2.16 MHz running Leopard. There’s only 128 MB of VRAM (ATI 1600) - if juce is using CG now, is that an issue?

Bruce

No, shouldn’t be an issue. Try changing the rendering engine from CG to software-based and see what that does.

Sorry, remind me - is there a compiler switch?

I see I can create a Graphics Context with a specific renderer, but I don’t see a master switch, and I can’t see anything in the docs that tells me.

Bruce

I set the use_CG flag to zero, and yes, the problem goes away - no lock-ups and draw time stays under 40 ms.

Bruce

The juce demo has an option on its menu, so you can flip between them. Have a look at how that works.

Yup. That’s easier. At 6.38 zoom, 37ms versus 550ms with CG.

Damn, that’s bizarre! I think I never saw it before because I was usually building for 10.4, where it doesn’t happen - in 10.5 there’s a new function CGContextDrawTiledImage which must be crapping out for some reason. I guess I’ll have to avoid using that function for factors > 1…

Cool. Sadly, it didn’t seem to fix my magnifying problem. I looked through that, and my structure is like the jucer (for obvious reasons) just some extra classes in the views. Even when I disable creating most objects, and disable drawing, I get that same sort of clog. :frowning:

You could try it with the software renderer in case it’s some other bug in CG.

Jules, this problem is back/still there in the tip.

If I run juce demo, go to Tiled Image - RGB and zoom all the way in, the app clogs completely.

Bruce

What a piece of junk. It only happens if you do a 10.6-only build - I guess I must have thought it was working ok in 10.6 when in fact it isn’t. Easy enough to put the workaround back in, I’ll do that.

I’m doing a 10.5 build and getting it (deployment 10.4). Are you going to check in a fix to that?

And, is there any chance there’s other, similar CG bugs that I may be running into? My Magnifier problem has extremely similar symptoms - an apparent freeze up when doing zoom operations.

I did, at some point, jump through every hoop I could to recreate that in the jucer (which my code is based on) and couldn’t do it - I was forced to assume that some vagary of component embedding is exposing some problem.

Thanks,

Bruce

In those builds it should already fall back to doing it manually. I’ve updated the tip now if you want to try it.

Don’t think the magnifier stuff would be related to this, as I don’t think it uses tiling. Most likely you were hitting a bug that I fixed last week, where clearing the image in certain situations could overflow and actually corrupt some memory.

It did fix the zoom RGB tiled problem - snappy as anything now.

My Mag problem is beating me around the head, face and neck. It seems to improve a hair when I drop the viewport size down at/below 2048, and I can reproduce some sort of slowdown and flakey mouse clicks in jucer by making a 5760 wide component and zooming to see it all.

Need to fix some Rectangle related problems to work properly with the tip and see what’s going on. Thanks for changing the UTF8 type, BTW - I just took out a few hundred casts!

Bruce