提交 33a242ae 编写于 作者: T tschw

WebGLRenderer: Clarified program deallocation.

上级 89fdbd0d
......@@ -715,44 +715,34 @@ THREE.WebGLRenderer = function ( parameters ) {
material.program = undefined;
// only deallocate GL program if this was the last use of shared program
// assumed there is only single copy of any program in the _programs list
// (that's how it's constructed)
for ( var i = 0, n = _programs.length; i !== n; ++ i ) {
var i, il, programInfo;
var deleteProgram = false;
for ( i = 0, il = _programs.length; i < il; i ++ ) {
programInfo = _programs[ i ];
var programInfo = _programs[ i ];
if ( programInfo.program === program ) {
programInfo.usedTimes --;
if ( programInfo.usedTimes === 0 ) {
deleteProgram = true;
}
var newReferenceCount = -- programInfo.usedTimes;
break;
if ( newReferenceCount === 0 ) {
}
// the last meterial that has been using the program let
// go of it, so remove it from the (unordered) _programs
// set and deallocate the GL resource
}
var newLength = n - 1;
if ( deleteProgram === true ) {
_programs[ i ] = _programs[ newLength ];
_programs.pop();
// avoid using array.splice, instead replace with last and pop
_gl.deleteProgram( program );
_programs[ i ] = _programs[ il - 1 ];
_programs.pop();
_infoMemory.programs = newLength;
}
_gl.deleteProgram( program );
break;
_infoMemory.programs --;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册