Jump to content
  • Advertisement
Sign in to follow this  

glBindAttribLocationARB Memory Leak

This topic is 4521 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

alright, after about 3 hours looking for this leak, i've finally found it, but can't stop it. i've got a render function that enables a shader, binds all the attributes etc, then i use glDrawElements(...) to render... then i disable the shader and its bindings. anyway, i'm using glEnableVertexAttribArrayARB(locTangent); to bind the tangent and bitangent arrays to the shader. and glDisableVertexAttribArrayARB(locTangent); to unbind. the truble is, my memory usage is going up around 120k for tangents, and 120k for bitangents every second. do i need to do this some other way????

Share this post


Link to post
Share on other sites
Advertisement
the codes all a bit oo, but here goes...



before rendering, i use the follwing to setup all the shader bindings.





use_Vertices(pRootObject);
use_Normals(pRootObject);
use_Tangents( pRootObject, pShader);
use_Bitangents( pRootObject, pShader);
pShader->enable();



then i render the array

ad then i disable everything.



disable_Vertices(pRootObject);
disable_Normals(pRootObject);
disable_Tangents( pShader );
disable_Bitangents( pShader );
pShader->disable();





the diable/use bitangent/tangent functions are the pretty much the same, so i'll just post one of each.


void COctree::use_Tangents(t3DObject* pObject, CShader* pShader){
if(pShader){
int locTangent = -1;
locTangent = pShader->getAttributeLocation("tangent");
pShader->bindAttributeLocation("tangent", locTangent);
glEnableVertexAttribArrayARB(locTangent);
glVertexAttribPointerARB( locTangent, 3, GL_FLOAT, false, 0, pObject->pTangents );
}
}

void COctree::disable_Tangents(CShader* pShader){
if(pShader){
int locTangent = -1;
locTangent = pShader->getAttributeLocation("tangent");
glDisableVertexAttribArrayARB(locTangent);
}
}








and the pShader bind function is....



// MEMORY LEAK
// MEMORY LEAK
// MEMORY LEAK
void CShader::bindAttributeLocation(char* strName, UINT index){

glBindAttribLocationARB(glsl_program, index, strName);

}








i hope this helps...

[Edited by - phantom on January 3, 2006 1:45:46 PM]

Share this post


Link to post
Share on other sites
hmmm, I dont know if its the reason, howver your code is a little crazy...

Firstly, you can only bind BEFORE the shader is linked.
After linking you can query, binding after linking wont have any effect until the next time the shader is linked.

Also, once you query an attribute location it will stay the same until next time the shader is recompiled & linked, at which point it might change. Thus constantly querying for the location is a waste of time and probably going to hurt your performance.

Share this post


Link to post
Share on other sites
thanks a lot, that's fixed it.

you're right, i've been lazy just to get it working.

i'm now storing the tangent and bitangent attribute locations for each shader in the shader wrapper. it's stopped the memory leak.

cheers.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!