From f06fd410e809ff7a33ece3b98ec50f95d55413e1 Mon Sep 17 00:00:00 2001 From: RH Date: Tue, 27 Oct 2020 19:34:31 +1100 Subject: [PATCH] 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) --- spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp b/spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp index 62e39c192..34dc83cee 100644 --- a/spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp +++ b/spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp @@ -163,11 +163,10 @@ cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer CCASSERT(programState, "programState should not be null"); auto& pipelinePS = command->getPipelineDescriptor().programState; - if (pipelinePS != programState) + if (pipelinePS == nullptr || pipelinePS->getProgram() != programState->getProgram()) { CC_SAFE_RELEASE(pipelinePS); - pipelinePS = programState; - CC_SAFE_RETAIN(pipelinePS); + pipelinePS = programState->clone(); updateProgramStateLayout(pipelinePS); } @@ -175,8 +174,8 @@ cocos2d::TrianglesCommand* SkeletonBatch::addCommand(cocos2d::Renderer* renderer pipelinePS->setUniform(_locMVP, projectionMat.m, sizeof(projectionMat.m)); pipelinePS->setTexture(_locTexture, 0, texture->getBackendTexture()); - command->init(globalOrder, texture, blendType, triangles, mv, flags); - renderer->addCommand(command); + command->init(globalOrder, texture, blendType, triangles, mv, flags); + renderer->addCommand(command); return command; }