|
From: Keith W. <kw...@cs...> - 2004-08-03 17:27:48
|
I'm trying to make certain I totally understand what happens when I dup trimesh data. As usual, I'm working with Queeg. When I pass an existing QGTriMesh into the copy ctor of another QGTriMesh, it makes the following call to copy the attribute set: mTriMeshData.triMeshAttributeSet = Q3Object_Duplicate( srcData.triMeshAttributeSet ); I have put some debug code in after making the copy where I pull out the shader and the texture from both TriMeshes: TQ3TriMeshData* triMeshData = groupTriMeshes[k]->GetTriMeshData(); TQ3SurfaceShaderObject shader; Q3AttributeSet_Get(triMeshData->triMeshAttributeSet, kQ3AttributeTypeSurfaceShader, &shader); TQ3TextureObject texture; Q3TextureShader_GetTexture(shader, &texture); TQ3TriMeshData* triMeshData1 = (ot->prototypeTriMeshes)[k]->GetTriMeshData(); TQ3SurfaceShaderObject shader1; Q3AttributeSet_Get(triMeshData1->triMeshAttributeSet, kQ3AttributeTypeSurfaceShader, &shader1); TQ3TextureObject texture1; Q3TextureShader_GetTexture(shader, &texture1); What I get in the debugger is unique addresses for the two shaders, but the same address for the two textures. So copying the trimesh data creates a second new shader, but only copies a pointer or reference to the texture. I am right so far, right? So am I correct in assuming that this means the shader now has two copies in RAM, but that the texture will only have one copy in VRAM? Obviously, VRAM is in short supply, and this is a nice feature, assuming I'm right...but I'm wondering if I can get any increase in efficiency by using one shader for both TriMeshes? Would that decrease the RAM requirements? More seriously, I would like to minimize the time required to duplicate a trimesh, so that it stands the least chance of disturbing the framerate. I assume that copying a reference to the shader would be faster than copying the entire shader structure, but how would I go about doing this? Clearly, throwing away the copy and inserting a reference to the original into the new TriMesh after making the new TriMesh isn't going to do any good. In fact, that takes extra time, only to save RAM, but not saving time. Can I copying the trimesh attribute data without copying the shader structure? Would one expect to see any speed improvements as a result of this? Is this worth the trouble? Fundamentally, I need to know for certain that I am right in my assumption that there is only one copy of the texture in VRAM even if I have thousands of these objects, assuming their (unique) shaders all use the same texture pointer. Thanks. ________________________________________________________________________ Keith Wiley kw...@cs... http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley "Yet mark his perfect self-contentment, and hence learn his lesson, that to be self-contented is to be vile and ignorant, and that to aspire is better than to be blindly and impotently happy." -- Edwin A. Abbott, Flatland ________________________________________________________________________ |