Quoting David C. Jedynak:
> > I can add a way to query the amount of free RAM, but it wouldn't be
> > a definitive answer. Allocation might still fail if the free space is
> > too fragmented. Defragmentation of free space by moving
> > surface buffers
> > around (using hw) has to be implemented in the surface manager which
> > I'd like to rewrite before adding this feature.
>
> Is it possible to "manually" defragment by releasing all surfaces, and
> then recreating each?
Yes, that should work. Freed areas are merged and newly created ones
will be packed at the end of the free space.
There's a tool called "dfbsummon" which shows a real time representation
of the video memory using different colors, much like out from disk
defragmentation programs ;)
But itself uses some of the video memory. So you might at least look
at the code and see how to investigate the internal data of the surface
manager at runtime.
> > Anyways, your application shouldn't die if creation of a video only
> > surface fails. If you encounter a crash or any other bug in DirectFB
> > related to failing creation of video only surfaces, please tell us.
> >
>
> I'll keep an eye out for this. I'm going to be squeezing a fair amount
> of stuff into a 2MB buffer, but it is pretty static (lots of buttons and
> backgrounds, and some "cache slots" for some fixed size runtime load
> images), so I don't expect fragmentation. I'm just looking out for
> stupid bugs on my side for this embedded app, and haven't gotten up the
> enthusiasm yet for adding up (by hand) the pixel counts of all my cached
> images to see if they, plus the front and back buffer exceed my video
> ram space.
If you are using the multi application core, you can use the pretty
debugging tool "dfbdump" which shows a list of created surfaces,
windows, layer contexts etc.
Like this:
[...]
DirectFB uptime: 2 days, 01:46:00
-----------------------------[ Surfaces ]-------------------------------
Reference . Refs Width Height Format Video System Capabilities
------------------------------------------------------------------------
0x00002d04 : 2 592 x 15 A8 10k 9k
0x00002d03 : 9 616 x 460 ARGB 1150k 1107k
0x00002d01 : 2 552 x 16 A8 9k 9k
0x00002d00 : 2 48 x 45 ARGB 12k 9k
0x00002cff : 2 23 x 17 ARGB 3k 2k
0x00002cfe : 2 23 x 17 ARGB 3k 2k
0x00002cfd : 2 15 x 23 ARGB 3k 2k
0x00002cfc : 2 11 x 23 ARGB 3k 1k
0x00002cfb : 2 8 x 17 ARGB 3k 1k
0x00002cfa : 2 8 x 23 ARGB 3k 1k
[...]
0x00000008 : 3 1280 x 1024 RGB16 2560k 2560k�
0x00000006 : 1 48 x 45 ARGB 12k 9k
0x00000004 : 1 1280 x 1024 RGB16 5120k 0k video only double
0x00000002 : 1 1280 x 1024 RGB16 2560k 2560k
------ ------
15610k 10335k -> 25945k total
-----------------------------------[ Windows of Layer 0
]-----------------------------------
Reference . Refs X Y Width Height Opacity ID Capabilities State &
Options
--------------------------------------------------------------------------------------------
0x00000005 : 1 842, 654 48 x 45 0xff 1 * alphachannel GHOST
0x0000000e : 2 992, 8 64 x 64 0xff 5 ^ alphachannel GHOST
0x0000000c : 2 1120, 8 64 x 64 0xff 4 ^ alphachannel GHOST
0x0000000a : 2 1056, 8 64 x 64 0xff 3 ^ alphachannel GHOST
0x00000011 : 7 0, 972 1280 x 52 0x00 6 ^ alphachannel
0x00002d02 : 5 332, 282 616 x 460 0xff 547 - alphachannel FOCUSED
0x00002c06 : 5 623, 275 616 x 460 0xd0 532 - alphachannel
0x0000060d : 2 -100, -100 10 x 10 0xbe 145 -
0x0000002b : 2 0, 990 1280 x 34 0xbe 12 -
0x00002b5f : 2 0, 0 1288 x 994 0xbe 521 -
0x00000025 : 2 -100, -100 1 x 1 0xbe 9 -
0x00000007 : 2 0, 0 1280 x 1024 0x00 2 v
----------------------------------[ Contexts of Layer 0
]-----------------------------------
Reference . Refs Width Height Format Location on screen Regions Active Info
Level
--------------------------------------------------------------------------------------------
0x00000001 : 18 1280 x 1024 RGB16 0.0, 0.0 -> 1.0, 1.0 1 (*) SHARED
N/A
You can easily see if all of your surfaces are allocated in video memory.
> Thanks for the info, and thanks for DirectFB. I'm having a blast with
> it, and am looking forward to contributting some code back once my work
> week drops to a more reasonable 40-50 hours a week and I meet a few
> deadlines.
I also look forward to it!
--
Best regards,
Denis Oliver Kropp
.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/ |
"------------------------------------------"
Convergence GmbH