mirror of https://github.com/axmolengine/axmol.git
fix memory leak for ProgramStateRegistry use
This commit is contained in:
parent
0141396fde
commit
1dd638535e
|
@ -150,7 +150,7 @@ bool DrawNode::init()
|
|||
void DrawNode::updateShader()
|
||||
{
|
||||
auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR_LENGTH_TEXTURE);
|
||||
setProgramState(new (std::nothrow) backend::ProgramState(program));
|
||||
attachProgramState(new (std::nothrow) backend::ProgramState(program));
|
||||
_customCommand.getPipelineDescriptor().programState = _programState;
|
||||
setVertexLayout(_customCommand);
|
||||
_customCommand.setDrawType(CustomCommand::DrawType::ARRAY);
|
||||
|
|
|
@ -2131,7 +2131,9 @@ int Node::getAttachedNodeCount()
|
|||
void Node::setProgramStateWithRegistry(backend::ProgramType programType, Texture2D* texture)
|
||||
{
|
||||
auto formatEXT = texture ? texture->getTextureFormatEXT() : 0;
|
||||
setProgramState(backend::ProgramStateRegistry::getInstance()->getProgramState(programType, formatEXT));
|
||||
auto programState = backend::ProgramStateRegistry::getInstance()->newProgramState(programType, formatEXT);
|
||||
setProgramState(programState);
|
||||
programState->release();
|
||||
}
|
||||
|
||||
void Node::updateProgramStateTexture(Texture2D* texture)
|
||||
|
|
|
@ -43,7 +43,7 @@ void ProgramStateRegistry::clearPrograms() {
|
|||
this->_registry.clear();
|
||||
}
|
||||
|
||||
ProgramState* ProgramStateRegistry::getProgramState(ProgramType programType, int textureFormatEXT)
|
||||
ProgramState* ProgramStateRegistry::newProgramState(ProgramType programType, int textureFormatEXT)
|
||||
{
|
||||
uint32_t key = (static_cast<uint32_t>(programType) << 16) | textureFormatEXT;
|
||||
auto it = this->_registry.find(key);
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
void registerProgram(ProgramType programType, int textureFormatEXT, Program*);
|
||||
|
||||
ProgramState* getProgramState(ProgramType programType, int textureFormatEXT);
|
||||
ProgramState* newProgramState(ProgramType programType, int textureFormatEXT);
|
||||
ProgramType getProgramType(ProgramType programType, int textureFormatEXT);
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue