PDA

View Full Version : Geoshader placeholder and memory


haggi
July 4th, 2006, 16:58
I'm just testing how I can save memory with placeholder nodes.

I'm creating a grid ob cubes, first I create the placeholders, and the placeholder instances call the construction of a simple cube.

In my scene I only have the geometry for the geometry shader and default light and a camera.

This method should allow me to use quite a lot of objects without wasting to much memory. But with a grid of 500 by 500 cubes, the memory needed is more than 1 GByte.
After all placeholders are built, ray.exe needs more than 600mb, I think that is a little bit too much.

Below is a part of my placeholder code that is built in shader function.


for&#40; i = 0; i < zei; i++&#41;
&#123;
for&#40; k = 0; k < spa; k++&#41;
&#123;
sprintf_s&#40;iname, "Dummy%d_%d", i, k&#41;;
int id = &#40;i * spa&#41; + k;
sprintf_s&#40;oname, "Dummy%d", objCount++&#41;;
obj = mi_api_object_begin&#40;mi_mem_strdup&#40;oname&#41;&#41;;
obj->visible = obj->shadow = obj->trace = miTRUE;
mi_api_basis_list_clear&#40;&#41;;
obj->bbox_min&#46;x = obj->bbox_min&#46;y = obj->bbox_min&#46;z = -1;
obj->bbox_max&#46;x = obj->bbox_max&#46;y = obj->bbox_max&#46;z = 1;
mi_api_object_callback&#40;makegobject, 0&#41;;
resultObj = mi_api_object_end&#40;&#41;;

inst = mi_api_instance_begin&#40;mi_mem_strdup&#40;iname&#41;&#41;;

inst->tf&#46;global_to_local&#91;12&#93; = i * 1;
inst->tf&#46;global_to_local&#91;14&#93; = k * 1;
mi_matrix_invert&#40;inst->tf&#46;local_to_global, inst->tf&#46;global_to_local&#41;;

resultInst = mi_api_instance_end&#40;mi_mem_strdup&#40;oname&#41;, 0, 0&#41;;
// instances done
geoAddResult = mi_geoshader_add_result&#40;result, resultInst&#41;;
&#125;
&#125;
mi_info&#40;"---------- Haggi Shader End ---------------"&#41;;


does anyone have an idea how so save a little bit more memory so that I can create more objects?

bart
July 4th, 2006, 17:25
As I said on the shader mailing list ...

Please remember that placeholders make things flushable. It won't flush a placeholder from memory unless it needs to. It only knows it needs to when memory used approaches the memory limit. What is your memory limit set to?

Other related questions:
What is your task size?
Do your materials have a lot of reflectivity?

I assume eventually that the objects will be more complex than cubes. For each cube, you have a small amount of actual source geometry, but an allocation needs to take place. So, there's lots of overhead for little return. Better to have less medium-size source geometry objects, than the many small-size source geometry objects.