소스 검색

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)

RH 4 년 전
부모
커밋
f06fd410e8
1개의 변경된 파일4개의 추가작업 그리고 5개의 파일을 삭제
  1. 4 5
      spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp

+ 4 - 5
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");
 	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;
-		CC_SAFE_RETAIN(pipelinePS);
+		pipelinePS = programState->clone();
 
 
 		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);
-    renderer->addCommand(command);
+	command->init(globalOrder, texture, blendType, triangles, mv, flags);
+	renderer->addCommand(command);
 	return command;
 	return command;
 }
 }