From de8334416da16d4de43a272350c62528ff733d23 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sun, 27 Jun 2021 21:43:21 +0800 Subject: [PATCH] Improve Sprite programState update logic --- cocos/2d/CCSprite.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 6149802491..0eae684762 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -418,7 +418,9 @@ void Sprite::setTexture(Texture2D *texture) } } - bool needsUpdatePS = _texture == nullptr || _texture->getSamplerFlags() != texture->getSamplerFlags(); + bool needsUpdatePS = + (!_programState || _programState->getProgram()->getProgramType() < backend::ProgramType::CUSTOM_PROGRAM) && + (_texture == nullptr || _texture->getSamplerFlags() != texture->getSamplerFlags()); if (_renderMode != RenderMode::QUAD_BATCHNODE) { @@ -433,6 +435,8 @@ void Sprite::setTexture(Texture2D *texture) if (needsUpdatePS) setProgramState(backend::ProgramType::POSITION_TEXTURE_COLOR); + else + updateProgramStateTexture(_texture); } Texture2D* Sprite::getTexture() const