TGLMax2DFBO is 28 Times faster than GrabImage!

BlitzMax Forums/BlitzMax Programming/TGLMax2DFBO is 28 Times faster than GrabImage!

beanage(Posted 2011) [#1]
Hey,

since I badly needs it, I decided to try writing a TMax2DGraphics subclass for FBOs.

I wasnt quite sure if it would turn out to be too much of a hack, but in the end, it all kinda worked out, and you can use Max2D commands to render *directly* to a TImage with code as simple as:

Local myImage:TImage = CreateImage(400, 400)
Local myFBO:TGLMax2DFBO = TGLMax2DFBO.ForImage(myImage)

myFBO.bind()
'max2d render to texture code here ..
myFBO.unbind()

'Standard max2d code here..


Here is a link to the module:
http://www.beanage-labs.com/download/beanage.mod.zip
IIRC, the kudos for the TFBO class I use go to _JIM!

For the heretics, here is a simple demo, performance and functionality test all-in-one. It needs the module to be built:


I guess this technology needs some massive testing, so it would be cool if you guys could just mess around with it a little bit, and tell me how it worked out ;} Oh and if you run the test, maybe you could post your results.. I would be interested in how FBOs perform on some other hardware than my GeForce 9800 :)

[Edit:] Added some documentation to the mod.

Last edited 2011


Oddball(Posted 2011) [#2]
I keep meaning to add render to texture to Odd2D. Your link times out for me so I couldn't test. Sorry.


Jesse(Posted 2011) [#3]
very interesting but mines times out also.


_JIM(Posted 2011) [#4]
I'm so glad my code is of use to someone :)

Also, the whole site seems to be down.


beanage(Posted 2011) [#5]
Aw, sry, the sever was down the last 8 hours, its back online again now!


xlsior(Posted 2011) [#6]
Interesting.

On my PC:

In windowed mode, FBO is 16.58 times faster. *unless* I don't move the mouse *at all*, at that point it's 48.4 times faster (for some reason, the standard grabimage test was really slow if the mouse never moves into the window)

In full-screen mode, FBO are 17-18 times faster on my PC.

Windows 7 x64, ATI Radeon HD4670.

Very interesting, though -- are there any expected issues with this method? e.g. may it not be compatible with all video cards, or should this work on any system?


ErikT(Posted 2011) [#7]
I can't get the thing to build. Do I put the mod in a special sub-directory or something to build it?


Oddball(Posted 2011) [#8]
The file structure should read.
mod/beanage.mod/fbo.mod/
Nice work on this beanage. Any plans on doing a Direct3D7/9 version?


ImaginaryHuman(Posted 2011) [#9]
Of course it's faster than grab image because grab image copies the backbuffer across the graphics bus from gpu memory to main memory which is really slow and can be just as slow as grabbing a pixmap.

glCopySubImage2D() shouldn't be much slower than using an FBO, directly copying the backbuffer into a texture.


ErikT(Posted 2011) [#10]
Thanks Oddball :)

Tried for fun to run it on my netbook with gma 950 and got an Exception Access Violation in this line:
Local MyImageFBO:TGLMax2DFBO = TGLMax2DFBO.ForImage(MyImage)


beanage(Posted 2011) [#11]
Any plans on doing a Direct3D7/9 version?

Honestly, I have no idea how to approach this in Direct3D.. never used it!

glCopySubImage2D() shouldn't be much slower than using an FBO

Well, I still think the detour across the backbuffer is kinda unnecessary, isnt it? Of course, unless you run into T-Rek's kind of troubles..

Last edited 2011


Robb(Posted 2012) [#12]
Does anyone have a mirror for this module? The original site is up, but the download link no longer works. Does Beanage still post here?


AarbronBeast(Posted 2012) [#13]
Anyone? I'd like to check it out as well.


Pineapple(Posted 2012) [#14]
I third this


GW(Posted 2012) [#15]
Just use this: http://www.blitzbasic.com/codearcs/codearcs.php?code=2222


xlsior(Posted 2012) [#16]
Here's a backup: http://www.xlsior.org/temp/beanage.mod.zip


AarbronBeast(Posted 2012) [#17]
Sweet! Many thanks GW and xlsior! I am very grateful for your replies. I'll be looking into them both!


Wings(Posted 2013) [#18]
Here is a backup 2 http://www.tiberion.eu/download/blitzmax/beanage.mod.zip


Hezkore(Posted 2013) [#19]
Someone should really stick a
glScissor 0, 0, g_width, g_height
at the end of Method _reset()