freeing resources?

Blitz3D Forums/Blitz3D Beginners Area/freeing resources?

Pete Carter(Posted 2006) [#1]
i have a 2.5d scrolling shooter like r-type delta or Einhander in style. ive been making the space stations etc you fly throught in 3d world studio. making lots of standard size sections i can place next to each other in blitz.

i want have quite alot of detailed models and textures so i need a good routine for freeing meshes as they go out of the left of the screen and loading the next mesh just before it comes into view at the right off the screen.

has anyone done this before and whats a good way of doing this? i know trial and error is a good way to learn but i have limited time and i want to finish this game.

Pete


Stevie G(Posted 2006) [#2]
Peter,

Assume you're building re-usable mesh sections in each level?

Would not recommend loading stuff dynamically as this will be very Slooooow and halt program execution. There is no native way for blitz to stream the loading of a mesh.

Instead load all the mesh sections required for the level at the outset and hide them all. Create the level by placing instances of the sections in a row. Blitz will automatically handle the culling of sections which are not on screen although it may be quicker hiding and showing the relevant parts manually.

Stevie


Sir Gak(Posted 2006) [#3]
Yes, loading files from harddrive during runtime is a very slo-o-w proposition. Stevie G's solution is good.


Pete Carter(Posted 2006) [#4]
thanks ok, but if i do that, im going run out of memory for textures real quick, as the memory isnt freed up when the meshes are not rendered are they? ill have to run some tests.

so for all blitz3d games you have to load all meshes etc for the whole level into memory. no wonder everyone keeps banging on about DXTC. any other info on this subject would be handy

Pete


Ross C(Posted 2006) [#5]
What happens, from tests and other peoples info, that, you load your resources in blitz. Anything that is viewed in the camera view, is put into VRAM. Anything that is not, is kept in system RAM. Load up your code, and check out it's system RAM usuage in the task manager, or any other RAM managing app. You'll find all the resources are loaded into system RAM.


Pete Carter(Posted 2006) [#6]
ok so if i only show small sections at a time i should be ok for memory. even on older graphics cards. i guess you can limit what is rendered by shortening the camera range? this could be easyer than i thought then.

Pete


Ross C(Posted 2006) [#7]
Yeah, alot of this is done for you. But, just be wary of computers with little RAM :o)


Andy(Posted 2006) [#8]
>so for all blitz3d games you have to load all meshes etc
>for the whole level into memory.

Of course not, but it's dificult to add dynamic ressource management if your game is already halfway finished.

emulating threading is inefficient, slow and dirty, but it works. As for your purpose, I would go with the suggestions made, as you really shouldn't need to load resources dynamically.

>no wonder everyone keeps banging on about DXTC. any other
>info on this subject would be handy

Even with dynamic resource loading, DXTC would be great. A richer and more vibrant world could be built.

EDIT: You can see an example here.
http://www.blitzbasic.com/codearcs/codearcs.php?code=1531


Andy


Pete Carter(Posted 2006) [#9]
thanks everyone you have given me lots to think about!

Pete


Pete Carter(Posted 2006) [#10]
ive done some tests and ive got a spacestation section and a space ship. ive set it up so the ship is visible to start with then it slowly moves with the camera following along side, at this point the ship is loaded in Vram and the spacestation in system ram, as it moves close to the spacestation blitz loads the spacestation into vram. the only thing is that once you move away from the space station it is not removed from vram an just stays there? is there any way to remove it from vram?

Pete


puki(Posted 2006) [#11]
This is an interesting thread.

Out of interest, what happens if you try to 'FreeEntity' it?

I wonder if there is potential to combine 'FreeEntity' (assuming it clears the entity from VRAM) with 'CopyEntity' to work around this and put something exclusively back into system RAM.


Pete Carter(Posted 2006) [#12]
it stays in vram, well it did in my test. this is what i want to know, does blitz3d start clearing out the freed stuff from vram at some point or does it just fill up and crash?

Pete

it would be great if Mr Sibly could give us some detail on how blitz deals with vram/system ram?


big10p(Posted 2006) [#13]
I'd assume that blitz frees VRAM when the last entity that references it is freed.


Ross C(Posted 2006) [#14]
I think it leaves things in there until something new needs to go in. I guess it's for speed. There's no point clearing out the VRAM unless something new needs to go in there.

I had a thought about streameing in textures ;o) AGAIN

Basically, you break your textures into say, 32x32 or smaller squares and load each of these chunks in, bit by bit. Then, copyrect these to the main texture. Since blitz is loading and putting these to a texture for you, the copyrect command isn't actually THAT slow. Plus, you could use the Force to VRAM flag, beause each texture piece would get freed immediately after copying.