Fix to address issue introduced in PR #1787 where the same ProgramState was being used for each attachment, but would cause problems if the attachments did not use the same texture. (#1801)

This commit is contained in:
RH 2020-10-27 19:34:31 +11:00 committed by GitHub
parent 5a1d53bb16
commit f06fd410e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,11 +163,10 @@ cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer
CCASSERT(programState, "programState should not be null"); CCASSERT(programState, "programState should not be null");
auto& pipelinePS = command->getPipelineDescriptor().programState; auto& pipelinePS = command->getPipelineDescriptor().programState;
if (pipelinePS != programState) if (pipelinePS == nullptr || pipelinePS->getProgram() != programState->getProgram())
{ {
CC_SAFE_RELEASE(pipelinePS); CC_SAFE_RELEASE(pipelinePS);
pipelinePS = programState; pipelinePS = programState->clone();
CC_SAFE_RETAIN(pipelinePS);
updateProgramStateLayout(pipelinePS); updateProgramStateLayout(pipelinePS);
} }
@ -175,8 +174,8 @@ cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer
pipelinePS->setUniform(_locMVP, projectionMat.m, sizeof(projectionMat.m)); pipelinePS->setUniform(_locMVP, projectionMat.m, sizeof(projectionMat.m));
pipelinePS->setTexture(_locTexture, 0, texture->getBackendTexture()); pipelinePS->setTexture(_locTexture, 0, texture->getBackendTexture());
command->init(globalOrder, texture, blendType, triangles, mv, flags); command->init(globalOrder, texture, blendType, triangles, mv, flags);
renderer->addCommand(command); renderer->addCommand(command);
return command; return command;
} }